fix lint errors
This commit is contained in:
parent
86264c1202
commit
85cff22da4
@ -83,7 +83,11 @@ func LoadSourceURI(uri string) []*resource.Document {
|
|||||||
func ImportSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
func ImportSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
||||||
ImportResource = cmd.String("resource", "", "(uri) Add a resource to the document.")
|
ImportResource = cmd.String("resource", "", "(uri) Add a resource to the document.")
|
||||||
ImportMerge = cmd.Bool("merge", false, "Merge resources into a single document.")
|
ImportMerge = cmd.Bool("merge", false, "Merge resources into a single document.")
|
||||||
cmd.Parse(os.Args[2:])
|
e := cmd.Parse(os.Args[2:])
|
||||||
|
if e != nil { // returns ErrHelp
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
var encoder resource.Encoder
|
var encoder resource.Encoder
|
||||||
merged := resource.NewDocument()
|
merged := resource.NewDocument()
|
||||||
documents := make([]*resource.Document, 0, 100)
|
documents := make([]*resource.Document, 0, 100)
|
||||||
@ -117,7 +121,9 @@ func ImportSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
|||||||
|
|
||||||
if *GlobalQuiet {
|
if *GlobalQuiet {
|
||||||
for _, dr := range d.Resources() {
|
for _, dr := range d.Resources() {
|
||||||
output.Write([]byte(dr.Resource().URI()))
|
if _,e := output.Write([]byte(dr.Resource().URI())); e != nil {
|
||||||
|
return e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if *ImportMerge {
|
if *ImportMerge {
|
||||||
@ -140,7 +146,9 @@ func ImportSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ApplySubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
func ApplySubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
||||||
cmd.Parse(os.Args[2:])
|
if e := cmd.Parse(os.Args[2:]); e != nil {
|
||||||
|
return e
|
||||||
|
}
|
||||||
var encoder resource.Encoder
|
var encoder resource.Encoder
|
||||||
documents := make([]*resource.Document, 0, 100)
|
documents := make([]*resource.Document, 0, 100)
|
||||||
for _,source := range cmd.Args() {
|
for _,source := range cmd.Args() {
|
||||||
@ -165,7 +173,9 @@ func ApplySubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
|||||||
}
|
}
|
||||||
if *GlobalQuiet {
|
if *GlobalQuiet {
|
||||||
for _, dr := range d.Resources() {
|
for _, dr := range d.Resources() {
|
||||||
output.Write([]byte(dr.Resource().URI()))
|
if _,e := output.Write([]byte(dr.Resource().URI())); e != nil {
|
||||||
|
return e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if documentGenerateErr := encoder.Encode(d); documentGenerateErr != nil {
|
if documentGenerateErr := encoder.Encode(d); documentGenerateErr != nil {
|
||||||
@ -177,7 +187,9 @@ func ApplySubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DiffSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
func DiffSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
||||||
cmd.Parse(os.Args[2:])
|
if e := cmd.Parse(os.Args[2:]); e != nil {
|
||||||
|
return e
|
||||||
|
}
|
||||||
leftSource := cmd.Arg(0)
|
leftSource := cmd.Arg(0)
|
||||||
rightSource := cmd.Arg(1)
|
rightSource := cmd.Arg(1)
|
||||||
leftDocuments := make([]*resource.Document, 0, 100)
|
leftDocuments := make([]*resource.Document, 0, 100)
|
||||||
|
@ -137,7 +137,10 @@ func (d *Document) Diff(with *Document, output io.Writer) (string, error) {
|
|||||||
for _,diff := range yamldiff.Do(yamlDiff, withDiff, opts...) {
|
for _,diff := range yamldiff.Do(yamlDiff, withDiff, opts...) {
|
||||||
slog.Info("Diff()", "diff", diff)
|
slog.Info("Diff()", "diff", diff)
|
||||||
fmt.Printf("yaml %#v with %#v\n", yamlDiff, withDiff)
|
fmt.Printf("yaml %#v with %#v\n", yamlDiff, withDiff)
|
||||||
output.Write([]byte(diff.Dump()))
|
_,e := output.Write([]byte(diff.Dump()))
|
||||||
|
if e != nil {
|
||||||
|
return "", e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
slog.Info("Document.Diff() ", "document.yaml", ydata, "with.yaml", wdata)
|
slog.Info("Document.Diff() ", "document.yaml", ydata, "with.yaml", wdata)
|
||||||
if stringOutput, ok := output.(*strings.Builder); ok {
|
if stringOutput, ok := output.(*strings.Builder); ok {
|
||||||
|
@ -215,7 +215,8 @@ func TestFileUpdateAttributesFromFileInfo(t *testing.T) {
|
|||||||
info, e := os.Lstat(TempDir)
|
info, e := os.Lstat(TempDir)
|
||||||
assert.Nil(t, e)
|
assert.Nil(t, e)
|
||||||
|
|
||||||
f.UpdateAttributesFromFileInfo(info)
|
updateAttributesErr := f.UpdateAttributesFromFileInfo(info)
|
||||||
|
assert.Nil(t, updateAttributesErr)
|
||||||
assert.Equal(t, DirectoryFile, f.FileType)
|
assert.Equal(t, DirectoryFile, f.FileType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,9 @@ type Ident struct {
|
|||||||
func NewIdent() *Ident {
|
func NewIdent() *Ident {
|
||||||
i := &Ident{}
|
i := &Ident{}
|
||||||
i.authorized = []string{ "*" }
|
i.authorized = []string{ "*" }
|
||||||
i.Generate()
|
if e := i.Generate(); e != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ func (d *HTTP) Type() string { return "http" }
|
|||||||
|
|
||||||
func (h *HTTP) ExtractResources(filter ResourceSelector) ([]*resource.Document, error) {
|
func (h *HTTP) ExtractResources(filter ResourceSelector) ([]*resource.Document, error) {
|
||||||
documents := make([]*resource.Document, 0, 100)
|
documents := make([]*resource.Document, 0, 100)
|
||||||
documents = append(documents, resource.NewDocument())
|
|
||||||
|
|
||||||
resp, err := http.Get(h.Endpoint)
|
resp, err := http.Get(h.Endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -67,12 +66,9 @@ func (h *HTTP) ExtractResources(filter ResourceSelector) ([]*resource.Document,
|
|||||||
decoder := resource.NewYAMLDecoder(sumReadData)
|
decoder := resource.NewYAMLDecoder(sumReadData)
|
||||||
index := 0
|
index := 0
|
||||||
for {
|
for {
|
||||||
doc := documents[index]
|
doc := resource.NewDocument()
|
||||||
e := decoder.Decode(doc)
|
e := decoder.Decode(doc)
|
||||||
if errors.Is(e, io.EOF) {
|
if errors.Is(e, io.EOF) {
|
||||||
if len(documents) > 1 {
|
|
||||||
documents[index] = nil
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if e != nil {
|
if e != nil {
|
||||||
@ -81,18 +77,16 @@ func (h *HTTP) ExtractResources(filter ResourceSelector) ([]*resource.Document,
|
|||||||
if validationErr := doc.Validate(); validationErr != nil {
|
if validationErr := doc.Validate(); validationErr != nil {
|
||||||
return documents, validationErr
|
return documents, validationErr
|
||||||
}
|
}
|
||||||
/*
|
documents = append(documents, doc)
|
||||||
if applyErr := doc.Apply(); applyErr != nil {
|
|
||||||
return documents, applyErr
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
documents = append(documents, resource.NewDocument())
|
|
||||||
index++
|
index++
|
||||||
}
|
}
|
||||||
|
|
||||||
if documentSignature != "" {
|
if documentSignature != "" {
|
||||||
sig := &signature.Ident{}
|
sig := &signature.Ident{}
|
||||||
sig.VerifySum(hash.Sum(nil), []byte(documentSignature))
|
sigErr := sig.VerifySum(hash.Sum(nil), []byte(documentSignature))
|
||||||
|
if sigErr != nil {
|
||||||
|
return documents, sigErr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return documents, nil
|
return documents, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user