From de4d50386d0fa32643c0fc16d9d2613c7229c603 Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Thu, 5 Dec 2019 16:32:17 -0300 Subject: [PATCH 1/7] kyaml: Enable Go linters (lll, stylecheck, unparam, whitespace) --- kyaml/.golangci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kyaml/.golangci.yml b/kyaml/.golangci.yml index a340a84b0..7c89c16ba 100644 --- a/kyaml/.golangci.yml +++ b/kyaml/.golangci.yml @@ -16,7 +16,7 @@ linters: - dupl - errcheck # - funlen -# - gochecknoinits + - gochecknoinits # - goconst # - gocritic - gocyclo @@ -28,19 +28,19 @@ linters: - govet - ineffassign - interfacer -# - lll + - lll - misspell - nakedret - scopelint - staticcheck - structcheck -# - stylecheck + - stylecheck - typecheck - unconvert -# - unparam + - unparam - unused - varcheck -# - whitespace + - whitespace linters-settings: From f2c7066088f9402f5065d3a272062f9625011a2b Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Thu, 5 Dec 2019 22:23:35 -0300 Subject: [PATCH 2/7] Remove leading/trailing newlines following whitespace linter recommendation --- kyaml/kio/filters/container.go | 1 - kyaml/kio/pkgio_writer.go | 1 - kyaml/yaml/fns_test.go | 3 --- kyaml/yaml/walk/associative_sequence.go | 1 - 4 files changed, 6 deletions(-) diff --git a/kyaml/kio/filters/container.go b/kyaml/kio/filters/container.go index aa929a644..a4ec6f156 100644 --- a/kyaml/kio/filters/container.go +++ b/kyaml/kio/filters/container.go @@ -133,7 +133,6 @@ func (c *ContainerFilter) getArgs() []string { args = append(args, "-e", strings.Split(pair, "=")[0]) } return append(args, c.Image) - } // getCommand returns a command which will apply the GrepFilter using the container image diff --git a/kyaml/kio/pkgio_writer.go b/kyaml/kio/pkgio_writer.go index e768e4ab1..91977f7a9 100644 --- a/kyaml/kio/pkgio_writer.go +++ b/kyaml/kio/pkgio_writer.go @@ -128,7 +128,6 @@ func (r LocalPackageWriter) errorIfMissingRequiredAnnotation(nodes []*yaml.RNode } func (r LocalPackageWriter) indexByFilePath(nodes []*yaml.RNode) (map[string][]*yaml.RNode, error) { - outputFiles := map[string][]*yaml.RNode{} for i := range nodes { // parse the file write path diff --git a/kyaml/yaml/fns_test.go b/kyaml/yaml/fns_test.go index 620692dea..cb587b52e 100644 --- a/kyaml/yaml/fns_test.go +++ b/kyaml/yaml/fns_test.go @@ -143,7 +143,6 @@ r: s ` func TestLookup_Fn_create(t *testing.T) { - // primitive node, err := Parse(s) assert.NoError(t, err) @@ -167,7 +166,6 @@ r: s `, assertNoErrorString(t)(node.String())) assert.Equal(t, `h `, assertNoErrorString(t)(rn.String())) - } func TestLookup_Fn_create2(t *testing.T) { @@ -442,7 +440,6 @@ foo: baz assert.Contains(t, err.Error(), "wrong Node Kind") assert.Equal(t, `foo: baz `, assertNoErrorString(t)(node.String())) - } func TestErrorIfInvalid(t *testing.T) { diff --git a/kyaml/yaml/walk/associative_sequence.go b/kyaml/yaml/walk/associative_sequence.go index cd5946939..1ef341607 100644 --- a/kyaml/yaml/walk/associative_sequence.go +++ b/kyaml/yaml/walk/associative_sequence.go @@ -12,7 +12,6 @@ import ( ) func (l *Walker) walkAssociativeSequence() (*yaml.RNode, error) { - // may require initializing the dest node dest, err := l.Sources.setDestNode(l.VisitList(l.Sources, AssociativeList)) if dest == nil || err != nil { From e811da14d8a11aaaaaa54c2606de93caa4f09354 Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Thu, 5 Dec 2019 22:39:29 -0300 Subject: [PATCH 3/7] Rename variable, constants and struct fields following stylecheck linter recommendation --- cmd/config/cmd/cat.go | 2 +- cmd/config/cmd/cmdwrap.go | 2 +- cmd/config/cmd/cmdxargs.go | 2 +- kyaml/kio/byteio_reader.go | 14 +++++++------- kyaml/kio/byteio_reader_test.go | 4 ++-- kyaml/kio/byteio_writer.go | 6 +++--- kyaml/kio/byteio_writer_test.go | 2 +- kyaml/kio/filters/container.go | 2 +- kyaml/kio/filters/fmtr_test.go | 2 +- kyaml/kio/filters/merge.go | 2 +- kyaml/kio/filters/merge3.go | 2 +- kyaml/kio/filters/testyaml/testyaml.go | 2 +- kyaml/kio/tree.go | 4 ++-- kyaml/yaml/types.go | 4 ++-- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/cmd/config/cmd/cat.go b/cmd/config/cmd/cat.go index 2d2138416..4f994c8dd 100644 --- a/cmd/config/cmd/cat.go +++ b/cmd/config/cmd/cat.go @@ -111,7 +111,7 @@ func (r *CatRunner) runE(c *cobra.Command, args []string) error { Writer: c.OutOrStdout(), KeepReaderAnnotations: r.KeepAnnotations, WrappingKind: r.WrapKind, - WrappingApiVersion: r.WrapApiVersion, + WrappingAPIVersion: r.WrapApiVersion, FunctionConfig: functionConfig, Style: yaml.GetStyle(r.Styles...), }) diff --git a/cmd/config/cmd/cmdwrap.go b/cmd/config/cmd/cmdwrap.go index 389fbeaab..822a5e3c2 100644 --- a/cmd/config/cmd/cmdwrap.go +++ b/cmd/config/cmd/cmdwrap.go @@ -134,7 +134,7 @@ func (r *WrapRunner) runE(c *cobra.Command, args []string) error { KeepReaderAnnotations: true, Writer: c.OutOrStdout(), WrappingKind: kio.ResourceListKind, - WrappingApiVersion: kio.ResourceListApiVersion}}}.Execute() + WrappingAPIVersion: kio.ResourceListAPIVersion}}}.Execute() if err != nil { return err } diff --git a/cmd/config/cmd/cmdxargs.go b/cmd/config/cmd/cmdxargs.go index 9767d1549..c9e298f40 100644 --- a/cmd/config/cmd/cmdxargs.go +++ b/cmd/config/cmd/cmdxargs.go @@ -186,7 +186,7 @@ func (r *XArgsRunner) runE(c *cobra.Command, _ []string) error { if version := rw.FunctionConfig.Field("apiVersion"); !yaml.IsFieldEmpty(version) { version.Value.YNode().Value = r.WrapVersion } - rw.WrappingApiVersion = r.WrapVersion + rw.WrappingAPIVersion = r.WrapVersion } return nil }(); err != nil { diff --git a/kyaml/kio/byteio_reader.go b/kyaml/kio/byteio_reader.go index 0161172e0..80e52ef87 100644 --- a/kyaml/kio/byteio_reader.go +++ b/kyaml/kio/byteio_reader.go @@ -17,7 +17,7 @@ import ( const ( ResourceListKind = "ResourceList" - ResourceListApiVersion = "config.kubernetes.io/v1alpha1" + ResourceListAPIVersion = "config.kubernetes.io/v1alpha1" ) // ByteReadWriter reads from an input and writes to an output. @@ -41,7 +41,7 @@ type ByteReadWriter struct { FunctionConfig *yaml.RNode - WrappingApiVersion string + WrappingAPIVersion string WrappingKind string } @@ -52,7 +52,7 @@ func (rw *ByteReadWriter) Read() ([]*yaml.RNode, error) { } val, err := b.Read() rw.FunctionConfig = b.FunctionConfig - rw.WrappingApiVersion = b.WrappingApiVersion + rw.WrappingAPIVersion = b.WrappingAPIVersion rw.WrappingKind = b.WrappingKind return val, errors.Wrap(err) } @@ -63,7 +63,7 @@ func (rw *ByteReadWriter) Write(nodes []*yaml.RNode) error { KeepReaderAnnotations: rw.KeepReaderAnnotations, Style: rw.Style, FunctionConfig: rw.FunctionConfig, - WrappingApiVersion: rw.WrappingApiVersion, + WrappingAPIVersion: rw.WrappingAPIVersion, WrappingKind: rw.WrappingKind, }.Write(nodes) } @@ -88,9 +88,9 @@ type ByteReader struct { // DisableUnwrapping prevents Resources in Lists and ResourceLists from being unwrapped DisableUnwrapping bool - // WrappingApiVersion is set by Read(), and is the apiVersion of the object that + // WrappingAPIVersion is set by Read(), and is the apiVersion of the object that // the read objects were originally wrapped in. - WrappingApiVersion string + WrappingAPIVersion string // WrappingKind is set by Read(), and is the kind of the object that // the read objects were originally wrapped in. @@ -140,7 +140,7 @@ func (r *ByteReader) Read() ([]*yaml.RNode, error) { node.Field("items") != nil { r.WrappingKind = meta.Kind - r.WrappingApiVersion = meta.ApiVersion + r.WrappingAPIVersion = meta.APIVersion // unwrap the list fc := node.Field("functionConfig") diff --git a/kyaml/kio/byteio_reader_test.go b/kyaml/kio/byteio_reader_test.go index a8037bab4..7723ec94f 100644 --- a/kyaml/kio/byteio_reader_test.go +++ b/kyaml/kio/byteio_reader_test.go @@ -86,7 +86,7 @@ elems: `, r.FunctionConfig.MustString()) assert.Equal(t, ResourceListKind, r.WrappingKind) - assert.Equal(t, ResourceListApiVersion, r.WrappingApiVersion) + assert.Equal(t, ResourceListAPIVersion, r.WrappingAPIVersion) } @@ -131,7 +131,7 @@ spec: // verify the function config assert.Nil(t, r.FunctionConfig) assert.Equal(t, "List", r.WrappingKind) - assert.Equal(t, "v1", r.WrappingApiVersion) + assert.Equal(t, "v1", r.WrappingAPIVersion) } // TestByteReader_Read tests the default Read behavior diff --git a/kyaml/kio/byteio_writer.go b/kyaml/kio/byteio_writer.go index 0fe06173f..2a5498519 100644 --- a/kyaml/kio/byteio_writer.go +++ b/kyaml/kio/byteio_writer.go @@ -35,8 +35,8 @@ type ByteWriter struct { // ByteWriter will wrap the Resources in a List .items field. WrappingKind string - // WrappingApiVersion is the apiVersion for WrappingKind - WrappingApiVersion string + // WrappingAPIVersion is the apiVersion for WrappingKind + WrappingAPIVersion string // Sort if set, will cause ByteWriter to sort the the nodes before writing them. Sort bool @@ -102,7 +102,7 @@ func (w ByteWriter) Write(nodes []*yaml.RNode) error { Style: w.Style, Content: []*yaml.Node{ {Kind: yaml.ScalarNode, Value: "apiVersion"}, - {Kind: yaml.ScalarNode, Value: w.WrappingApiVersion}, + {Kind: yaml.ScalarNode, Value: w.WrappingAPIVersion}, {Kind: yaml.ScalarNode, Value: "kind"}, {Kind: yaml.ScalarNode, Value: w.WrappingKind}, {Kind: yaml.ScalarNode, Value: "items"}, items, diff --git a/kyaml/kio/byteio_writer_test.go b/kyaml/kio/byteio_writer_test.go index 62bd3e1ed..27bcf685f 100644 --- a/kyaml/kio/byteio_writer_test.go +++ b/kyaml/kio/byteio_writer_test.go @@ -40,7 +40,7 @@ g: Writer: buff, FunctionConfig: node3, WrappingKind: ResourceListKind, - WrappingApiVersion: ResourceListApiVersion}. + WrappingAPIVersion: ResourceListAPIVersion}. Write([]*yaml.RNode{node2, node1}) if !assert.NoError(t, err) { return diff --git a/kyaml/kio/filters/container.go b/kyaml/kio/filters/container.go index a4ec6f156..a45e96a89 100644 --- a/kyaml/kio/filters/container.go +++ b/kyaml/kio/filters/container.go @@ -78,7 +78,7 @@ func (c *ContainerFilter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) { // write the input err = kio.ByteWriter{ - WrappingApiVersion: kio.ResourceListApiVersion, + WrappingAPIVersion: kio.ResourceListAPIVersion, WrappingKind: kio.ResourceListKind, Writer: in, KeepReaderAnnotations: true, FunctionConfig: c.Config}.Write(input) if err != nil { diff --git a/kyaml/kio/filters/fmtr_test.go b/kyaml/kio/filters/fmtr_test.go index cbfe115b0..2521a7ab5 100644 --- a/kyaml/kio/filters/fmtr_test.go +++ b/kyaml/kio/filters/fmtr_test.go @@ -459,7 +459,7 @@ func TestFormatFileOrDirectory_YamlExtFileWithJson(t *testing.T) { f, err := ioutil.TempFile("", "yamlfmt*.yaml") assert.NoError(t, err) defer os.Remove(f.Name()) - err = ioutil.WriteFile(f.Name(), testyaml.UnformattedJson1, 0600) + err = ioutil.WriteFile(f.Name(), testyaml.UnformattedJSON1, 0600) assert.NoError(t, err) // format the file diff --git a/kyaml/kio/filters/merge.go b/kyaml/kio/filters/merge.go index 65726e2b2..c41164fee 100644 --- a/kyaml/kio/filters/merge.go +++ b/kyaml/kio/filters/merge.go @@ -44,7 +44,7 @@ func (c MergeFilter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) { return nil, err } key := mergeKey{ - apiVersion: meta.ApiVersion, + apiVersion: meta.APIVersion, kind: meta.Kind, namespace: meta.Namespace, name: meta.Name, diff --git a/kyaml/kio/filters/merge3.go b/kyaml/kio/filters/merge3.go index ccc9d50bc..f302eeada 100644 --- a/kyaml/kio/filters/merge3.go +++ b/kyaml/kio/filters/merge3.go @@ -113,7 +113,7 @@ func (ts *tuples) add(node *yaml.RNode) error { for i := range ts.list { t := ts.list[i] if t.meta.Name == nodeMeta.Name && t.meta.Namespace == nodeMeta.Namespace && - t.meta.ApiVersion == nodeMeta.ApiVersion && t.meta.Kind == nodeMeta.Kind { + t.meta.APIVersion == nodeMeta.APIVersion && t.meta.Kind == nodeMeta.Kind { return t.add(node) } } diff --git a/kyaml/kio/filters/testyaml/testyaml.go b/kyaml/kio/filters/testyaml/testyaml.go index f6559d189..67593d026 100644 --- a/kyaml/kio/filters/testyaml/testyaml.go +++ b/kyaml/kio/filters/testyaml/testyaml.go @@ -27,7 +27,7 @@ apiVersion: example.com/v1beta1 kind: MyType2 `) -var UnformattedJson1 = []byte(` +var UnformattedJSON1 = []byte(` { "spec": "a", "status": {"conditions": [3, 1, 2]}, diff --git a/kyaml/kio/tree.go b/kyaml/kio/tree.go index c8a32356c..b96d99d62 100644 --- a/kyaml/kio/tree.go +++ b/kyaml/kio/tree.go @@ -285,8 +285,8 @@ func compareNodes(i, j *yaml.RNode) bool { } // compare apiVersion - if metai.ApiVersion != metaj.ApiVersion { - return metai.ApiVersion < metaj.ApiVersion + if metai.APIVersion != metaj.APIVersion { + return metai.APIVersion < metaj.APIVersion } return true } diff --git a/kyaml/yaml/types.go b/kyaml/yaml/types.go index 49b629db5..3e14575b3 100644 --- a/kyaml/yaml/types.go +++ b/kyaml/yaml/types.go @@ -221,8 +221,8 @@ func (m MapNodeSlice) Values() []*RNode { // ResourceMeta contains the metadata for a both Resource Type and Resource. type ResourceMeta struct { - // ApiVersion is the apiVersion field of a Resource - ApiVersion string `yaml:"apiVersion,omitempty"` + // APIVersion is the apiVersion field of a Resource + APIVersion string `yaml:"apiVersion,omitempty"` // Kind is the kind field of a Resource Kind string `yaml:"kind,omitempty"` // ObjectMeta is the metadata field of a Resource From df7688002a0d3c384dfcc381a747aa1bc2c50d8b Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Thu, 5 Dec 2019 22:44:14 -0300 Subject: [PATCH 4/7] Remove init function following gochecknoinits linter recommendation --- kyaml/yaml/order.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kyaml/yaml/order.go b/kyaml/yaml/order.go index e0726f504..886da5e87 100644 --- a/kyaml/yaml/order.go +++ b/kyaml/yaml/order.go @@ -97,12 +97,11 @@ var WhitelistedListSortFields = map[string]string{ } // FieldOrder indexes fields and maps them to relative precedence -var FieldOrder map[string]int - -func init() { +var FieldOrder = func() map[string]int { // create an index of field orderings - FieldOrder = map[string]int{} + fo := map[string]int{} for i, f := range fieldSortOrder { - FieldOrder[f] = i + 1 + fo[f] = i + 1 } -} + return fo +}() From 849e0f357ab32e428fc4037bac07b54dfc663541 Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Thu, 5 Dec 2019 22:50:37 -0300 Subject: [PATCH 5/7] Unname unused parameters following unparam linter recommendation --- kyaml/kio/pkgio_reader.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kyaml/kio/pkgio_reader.go b/kyaml/kio/pkgio_reader.go index 39a032c75..a618f612c 100644 --- a/kyaml/kio/pkgio_reader.go +++ b/kyaml/kio/pkgio_reader.go @@ -229,7 +229,7 @@ func (r LocalPackageReader) Read() ([]*yaml.RNode, error) { } // readFile reads the ResourceNodes from a file -func (r *LocalPackageReader) readFile(path string, info os.FileInfo) ([]*yaml.RNode, error) { +func (r *LocalPackageReader) readFile(path string, _ os.FileInfo) ([]*yaml.RNode, error) { f, err := os.Open(path) if err != nil { return nil, err @@ -258,7 +258,7 @@ func (r *LocalPackageReader) shouldSkipFile(info os.FileInfo) (bool, error) { } // initReaderAnnotations adds the LocalPackageReader Annotations to r.SetAnnotations -func (r *LocalPackageReader) initReaderAnnotations(path string, info os.FileInfo) { +func (r *LocalPackageReader) initReaderAnnotations(path string, _ os.FileInfo) { if r.SetAnnotations == nil { r.SetAnnotations = map[string]string{} } From a077482e994dcc656256ecba10386ffbde878036 Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Thu, 5 Dec 2019 23:06:19 -0300 Subject: [PATCH 6/7] Rename struct field to solve issue raised by go vet --- kyaml/yaml/fns_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyaml/yaml/fns_test.go b/kyaml/yaml/fns_test.go index cb587b52e..a0a735fd2 100644 --- a/kyaml/yaml/fns_test.go +++ b/kyaml/yaml/fns_test.go @@ -672,7 +672,7 @@ metadata: } assert.Equal(t, ResourceMeta{ Kind: "Deployment", - ApiVersion: "v1/apps", + APIVersion: "v1/apps", ObjectMeta: ObjectMeta{ Name: "foo", Namespace: "bar", From d4fa006ccb97ae75030a2a0ddf0c5b89d6405829 Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Thu, 5 Dec 2019 23:27:01 -0300 Subject: [PATCH 7/7] Remove leading/trailing newlines following whitespace linter recommendation --- kyaml/copyutil/copyutil_test.go | 1 - kyaml/kio/byteio_reader.go | 2 -- kyaml/kio/byteio_reader_test.go | 1 - kyaml/kio/byteio_writer.go | 1 - kyaml/kio/filters/fmtr_test.go | 2 -- kyaml/kio/pkgio_reader_test.go | 2 -- kyaml/yaml/example_test.go | 1 - kyaml/yaml/fns.go | 1 - kyaml/yaml/match.go | 1 - kyaml/yaml/merge3/visitor.go | 1 - 10 files changed, 13 deletions(-) diff --git a/kyaml/copyutil/copyutil_test.go b/kyaml/copyutil/copyutil_test.go index b2025018c..59a25635c 100644 --- a/kyaml/copyutil/copyutil_test.go +++ b/kyaml/copyutil/copyutil_test.go @@ -79,7 +79,6 @@ func TestDiff_additionalDestFiles(t *testing.T) { diff, err := Diff(s, d) assert.NoError(t, err) assert.ElementsMatch(t, diff.List(), []string{"a2"}) - } // TestDiff_srcDestContentsDiffer verifies if the file contents diff --git a/kyaml/kio/byteio_reader.go b/kyaml/kio/byteio_reader.go index 80e52ef87..f7b627c7d 100644 --- a/kyaml/kio/byteio_reader.go +++ b/kyaml/kio/byteio_reader.go @@ -138,7 +138,6 @@ func (r *ByteReader) Read() ([]*yaml.RNode, error) { len(values) == 1 && // Only unwrap if there is only 1 value (meta.Kind == ResourceListKind || meta.Kind == "List") && node.Field("items") != nil { - r.WrappingKind = meta.Kind r.WrappingAPIVersion = meta.APIVersion @@ -154,7 +153,6 @@ func (r *ByteReader) Read() ([]*yaml.RNode, error) { // add items output = append(output, yaml.NewRNode(items.Value.Content()[i])) } - } continue } diff --git a/kyaml/kio/byteio_reader_test.go b/kyaml/kio/byteio_reader_test.go index 7723ec94f..4e0f237d8 100644 --- a/kyaml/kio/byteio_reader_test.go +++ b/kyaml/kio/byteio_reader_test.go @@ -87,7 +87,6 @@ elems: assert.Equal(t, ResourceListKind, r.WrappingKind) assert.Equal(t, ResourceListAPIVersion, r.WrappingAPIVersion) - } func TestByteReader_Read_wrappedList(t *testing.T) { diff --git a/kyaml/kio/byteio_writer.go b/kyaml/kio/byteio_writer.go index 2a5498519..9b56e4e56 100644 --- a/kyaml/kio/byteio_writer.go +++ b/kyaml/kio/byteio_writer.go @@ -54,7 +54,6 @@ func (w ByteWriter) Write(nodes []*yaml.RNode) error { encoder := yaml.NewEncoder(w.Writer) defer encoder.Close() for i := range nodes { - // clean resources by removing annotations set by the Reader if !w.KeepReaderAnnotations { _, err := nodes[i].Pipe(yaml.ClearAnnotation(kioutil.IndexAnnotation)) diff --git a/kyaml/kio/filters/fmtr_test.go b/kyaml/kio/filters/fmtr_test.go index 2521a7ab5..a60aa23a4 100644 --- a/kyaml/kio/filters/fmtr_test.go +++ b/kyaml/kio/filters/fmtr_test.go @@ -145,7 +145,6 @@ spec: // TestFormatInput_service verifies a Service yaml is formatted correctly func TestFormatInput_service(t *testing.T) { - y := ` apiVersion: v1 kind: Service @@ -178,7 +177,6 @@ spec: // TestFormatInput_service verifies a Service yaml is formatted correctly func TestFormatInput_validatingWebhookConfiguration(t *testing.T) { - y := ` apiVersion: admissionregistration.k8s.io/v1beta1 kind: ValidatingWebhookConfiguration diff --git a/kyaml/kio/pkgio_reader_test.go b/kyaml/kio/pkgio_reader_test.go index 64ad089cc..8a446a601 100644 --- a/kyaml/kio/pkgio_reader_test.go +++ b/kyaml/kio/pkgio_reader_test.go @@ -79,7 +79,6 @@ func TestLocalPackageReader_Read_empty(t *testing.T) { assert.Contains(t, err.Error(), "must specify package path") } assert.Nil(t, nodes) - } func TestLocalPackageReader_Read_pkg(t *testing.T) { @@ -207,7 +206,6 @@ func TestLocalPackageReader_Read_pkgOmitAnnotations(t *testing.T) { {path: s.root}, } for _, p := range paths { - // empty path rfr := LocalPackageReader{PackagePath: p.path, OmitReaderAnnotations: true} nodes, err := rfr.Read() diff --git a/kyaml/yaml/example_test.go b/kyaml/yaml/example_test.go index 5d4b28de3..d2a1999e9 100644 --- a/kyaml/yaml/example_test.go +++ b/kyaml/yaml/example_test.go @@ -872,7 +872,6 @@ func ExampleRNode_Elements() { // Element: 2 // name: baz // args: ['run.sh'] - } func ExampleRNode_ElementValues() { diff --git a/kyaml/yaml/fns.go b/kyaml/yaml/fns.go index 1fc2eae83..d2f6218e4 100644 --- a/kyaml/yaml/fns.go +++ b/kyaml/yaml/fns.go @@ -129,7 +129,6 @@ func (c FieldClearer) Filter(rn *RNode) (*RNode, error) { } for i := 0; i < len(rn.Content()); i += 2 { - // if name matches, remove these 2 elements from the list because // they are treated as a fieldName/fieldValue pair. if rn.Content()[i].Value == c.Name { diff --git a/kyaml/yaml/match.go b/kyaml/yaml/match.go index a92203c2d..149716063 100644 --- a/kyaml/yaml/match.go +++ b/kyaml/yaml/match.go @@ -104,7 +104,6 @@ func (p *PathMatcher) doField(rn *RNode) (*RNode, error) { // doSeq iterates over a sequence and appends elements matching the path regex to p.Val func (p *PathMatcher) doSeq(rn *RNode) (*RNode, error) { - // parse the field + match pair var err error p.field, p.matchRegex, err = SplitIndexNameValue(p.Path[0]) diff --git a/kyaml/yaml/merge3/visitor.go b/kyaml/yaml/merge3/visitor.go index ab39cdc8a..7e2f12cc8 100644 --- a/kyaml/yaml/merge3/visitor.go +++ b/kyaml/yaml/merge3/visitor.go @@ -135,7 +135,6 @@ func (m Visitor) getStrValues(nodes walk.Sources) (strValues, error) { if err != nil { return strValues{}, err } - } if nodes.Dest() != nil && nodes.Dest().YNode() != nil { s := nodes.Dest().YNode().Style