From 32fd00700eab87e435c0295907246807cea2559f Mon Sep 17 00:00:00 2001 From: Anne Lau Date: Tue, 19 Apr 2022 13:20:53 -0700 Subject: [PATCH] Fixed imports Co-authored-by: sarjamil --- api/filters/fieldspec/fieldspec.go | 4 ++-- api/filters/replacement/replacement.go | 6 +++--- api/internal/builtins/AnnotationsTransformer.go | 5 ++++- kyaml/{pathsplitterutil => utils}/pathsplitter.go | 2 +- kyaml/{pathsplitterutil => utils}/pathsplitter_test.go | 4 ++-- kyaml/yaml/rnode.go | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) rename kyaml/{pathsplitterutil => utils}/pathsplitter.go (98%) rename kyaml/{pathsplitterutil => utils}/pathsplitter_test.go (96%) diff --git a/api/filters/fieldspec/fieldspec.go b/api/filters/fieldspec/fieldspec.go index 16c112f379..8e4e78ca6e 100644 --- a/api/filters/fieldspec/fieldspec.go +++ b/api/filters/fieldspec/fieldspec.go @@ -5,13 +5,13 @@ package fieldspec import ( "fmt" - "sigs.k8s.io/kustomize/kyaml/pathsplitterutil" "strings" "sigs.k8s.io/kustomize/api/filters/filtersutil" "sigs.k8s.io/kustomize/api/types" "sigs.k8s.io/kustomize/kyaml/errors" "sigs.k8s.io/kustomize/kyaml/resid" + "sigs.k8s.io/kustomize/kyaml/utils" "sigs.k8s.io/kustomize/kyaml/yaml" ) @@ -49,7 +49,7 @@ func (fltr Filter) Filter(obj *yaml.RNode) (*yaml.RNode, error) { if match := isMatchGVK(fltr.FieldSpec, obj); !match { return obj, nil } - fltr.path = pathsplitterutil.PathSplitter(fltr.FieldSpec.Path, "/") + fltr.path = utils.PathSplitter(fltr.FieldSpec.Path, "/") if err := fltr.filter(obj); err != nil { return nil, errors.WrapPrefixf(err, "considering field '%s' of object %s", fltr.FieldSpec.Path, resid.FromRNode(obj)) diff --git a/api/filters/replacement/replacement.go b/api/filters/replacement/replacement.go index 2471b64871..c3b5c488bc 100644 --- a/api/filters/replacement/replacement.go +++ b/api/filters/replacement/replacement.go @@ -6,7 +6,7 @@ package replacement import ( "errors" "fmt" - "sigs.k8s.io/kustomize/kyaml/pathsplitterutil" + utils2 "sigs.k8s.io/kustomize/kyaml/utils" "strings" "sigs.k8s.io/kustomize/api/internal/utils" @@ -115,7 +115,7 @@ func rejectId(rejects []*types.Selector, id *resid.ResId) bool { func applyToNode(node *yaml.RNode, value *yaml.RNode, target *types.TargetSelector) error { for _, fp := range target.FieldPaths { - fieldPath := pathsplitterutil.SmarterPathSplitter(fp, ".") + fieldPath := utils2.SmarterPathSplitter(fp, ".") var t *yaml.RNode var err error if target.Options != nil && target.Options.Create { @@ -200,7 +200,7 @@ func getReplacement(nodes []*yaml.RNode, r *types.Replacement) (*yaml.RNode, err if r.Source.FieldPath == "" { r.Source.FieldPath = types.DefaultReplacementFieldPath } - fieldPath := pathsplitterutil.SmarterPathSplitter(r.Source.FieldPath, ".") + fieldPath := utils2.SmarterPathSplitter(r.Source.FieldPath, ".") rn, err := source.Pipe(yaml.Lookup(fieldPath...)) if err != nil { diff --git a/api/internal/builtins/AnnotationsTransformer.go b/api/internal/builtins/AnnotationsTransformer.go index 7064fa80c0..c932bd6350 100644 --- a/api/internal/builtins/AnnotationsTransformer.go +++ b/api/internal/builtins/AnnotationsTransformer.go @@ -1,6 +1,8 @@ // Code generated by pluginator on AnnotationsTransformer; DO NOT EDIT. // pluginator {unknown 1970-01-01T00:00:00Z } + + package builtins import ( @@ -16,6 +18,7 @@ type AnnotationsTransformerPlugin struct { FieldSpecs []types.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"` } + func (p *AnnotationsTransformerPlugin) Config( _ *resmap.PluginHelpers, c []byte) (err error) { p.Annotations = nil @@ -34,5 +37,5 @@ func (p *AnnotationsTransformerPlugin) Transform(m resmap.ResMap) error { } func NewAnnotationsTransformerPlugin() resmap.TransformerPlugin { - return &AnnotationsTransformerPlugin{} + return &AnnotationsTransformerPlugin{} } diff --git a/kyaml/pathsplitterutil/pathsplitter.go b/kyaml/utils/pathsplitter.go similarity index 98% rename from kyaml/pathsplitterutil/pathsplitter.go rename to kyaml/utils/pathsplitter.go index 55c8f0fb38..aa560299f7 100644 --- a/kyaml/pathsplitterutil/pathsplitter.go +++ b/kyaml/utils/pathsplitter.go @@ -1,7 +1,7 @@ // Copyright 2021 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0 -package pathsplitterutil +package utils import "strings" diff --git a/kyaml/pathsplitterutil/pathsplitter_test.go b/kyaml/utils/pathsplitter_test.go similarity index 96% rename from kyaml/pathsplitterutil/pathsplitter_test.go rename to kyaml/utils/pathsplitter_test.go index 1e3ae880c2..180f3e2595 100644 --- a/kyaml/pathsplitterutil/pathsplitter_test.go +++ b/kyaml/utils/pathsplitter_test.go @@ -1,13 +1,13 @@ // Copyright 2021 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0 -package pathsplitterutil_test +package utils_test import ( - . "sigs.k8s.io/kustomize/kyaml/pathsplitterutil" "testing" "github.com/stretchr/testify/assert" + . "sigs.k8s.io/kustomize/kyaml/utils" ) func TestPathSplitter(t *testing.T) { diff --git a/kyaml/yaml/rnode.go b/kyaml/yaml/rnode.go index 83027c1f7d..28e991fa79 100644 --- a/kyaml/yaml/rnode.go +++ b/kyaml/yaml/rnode.go @@ -9,13 +9,13 @@ import ( "io/ioutil" "log" "regexp" - "sigs.k8s.io/kustomize/kyaml/pathsplitterutil" "strconv" "strings" "sigs.k8s.io/kustomize/kyaml/errors" "sigs.k8s.io/kustomize/kyaml/internal/forked/github.com/go-yaml/yaml" "sigs.k8s.io/kustomize/kyaml/sliceutil" + "sigs.k8s.io/kustomize/kyaml/utils" "sigs.k8s.io/kustomize/kyaml/yaml/internal/k8sgen/pkg/labels" ) @@ -1208,7 +1208,7 @@ func (rn *RNode) GetString(path string) (string, error) { // assuming we keep the var feature in kustomize. // The other end of this is: refvar.go:updateNodeValue. func (rn *RNode) GetFieldValue(path string) (interface{}, error) { - fields := pathsplitterutil.SmarterPathSplitter(path, ".") + fields := utils.SmarterPathSplitter(path, ".") rn, err := rn.Pipe(Lookup(fields...)) if err != nil { return nil, err