From 037ac3b134be9bb94071062f6b549de185a4f8da Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Wed, 19 Aug 2020 11:21:19 -0700 Subject: [PATCH 01/23] add option to continue pipeline when the input is empty --- cmd/config/internal/commands/source.go | 2 +- kyaml/kio/kio.go | 7 +++++- kyaml/kio/kio_test.go | 33 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/cmd/config/internal/commands/source.go b/cmd/config/internal/commands/source.go index 7873956ce..d731aa5c8 100644 --- a/cmd/config/internal/commands/source.go +++ b/cmd/config/internal/commands/source.go @@ -77,6 +77,6 @@ func (r *SourceRunner) runE(c *cobra.Command, args []string) error { inputs = []kio.Reader{&kio.ByteReader{Reader: c.InOrStdin()}} } - err := kio.Pipeline{Inputs: inputs, Outputs: outputs}.Execute() + err := kio.Pipeline{Inputs: inputs, Outputs: outputs, ContinueIfInputEmpty: true}.Execute() return handleError(c, err) } diff --git a/kyaml/kio/kio.go b/kyaml/kio/kio.go index 32bdebb32..c5165ab04 100644 --- a/kyaml/kio/kio.go +++ b/kyaml/kio/kio.go @@ -75,6 +75,11 @@ type Pipeline struct { // Outputs are where the transformed Resource Configuration is written. Outputs []Writer `yaml:"outputs,omitempty"` + + // ContinueIfInputEmpty indicates should pipeline continue when the + // the input result is empty. This is useful when we want to run outputs + // even the input is empty. + ContinueIfInputEmpty bool } // Execute executes each step in the sequence, returning immediately after encountering @@ -99,7 +104,7 @@ func (p Pipeline) ExecuteWithCallback(callback PipelineExecuteCallbackFunc) erro } result = append(result, nodes...) } - if len(result) == 0 { + if len(result) == 0 && !p.ContinueIfInputEmpty { // no inputs to operate on return nil } diff --git a/kyaml/kio/kio_test.go b/kyaml/kio/kio_test.go index d51301d9b..ad4cd70bb 100644 --- a/kyaml/kio/kio_test.go +++ b/kyaml/kio/kio_test.go @@ -4,7 +4,9 @@ package kio_test import ( + "bytes" "reflect" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -75,3 +77,34 @@ func TestPipelineWithCallback(t *testing.T) { ) } } + +func TestContinueIfInputEmpty(t *testing.T) { + actual := &bytes.Buffer{} + output := ByteWriter{ + Sort: true, + WrappingKind: ResourceListKind, + WrappingAPIVersion: ResourceListAPIVersion, + } + output.Writer = actual + + p := Pipeline{ + Outputs: []Writer{output}, + ContinueIfInputEmpty: true, + } + + err := p.Execute() + if err != nil { + t.Fatal(err) + } + + expected := ` +apiVersion: config.kubernetes.io/v1alpha1 +kind: ResourceList +items: [] +` + + if !assert.Equal(t, + strings.TrimSpace(expected), strings.TrimSpace(actual.String())) { + t.FailNow() + } +} From b450b624e8ff259bc52ce85d439b7f58dd548f27 Mon Sep 17 00:00:00 2001 From: Yankee <13623913+yankeexe@users.noreply.github.com> Date: Thu, 20 Aug 2020 08:18:47 +0545 Subject: [PATCH 02/23] Update dead URL to base in glossary. The term `central concept` referring to `base` was a dead link. Updated the link to go to proper definition of base. --- site/content/en/api-reference/kustomization/bases/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/en/api-reference/kustomization/bases/_index.md b/site/content/en/api-reference/kustomization/bases/_index.md index 1d867aec1..77d09108b 100644 --- a/site/content/en/api-reference/kustomization/bases/_index.md +++ b/site/content/en/api-reference/kustomization/bases/_index.md @@ -12,5 +12,5 @@ The `bases` field was deprecated in v2.1.0 Move entries into the [resources](/kustomize/api-reference/kustomization/resources) field. This allows bases - which are still a -[central concept](/kustomize/api-reference/kustomization/glossary#base) - to be +[central concept](/kustomize/api-reference/glossary#base) - to be ordered relative to other input resources. From 501684a9c61f34187ff2bb00c85e5c98da73d91d Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Thu, 20 Aug 2020 11:54:56 -0700 Subject: [PATCH 03/23] remove break after input in pipeline --- cmd/config/internal/commands/source.go | 2 +- kyaml/kio/kio.go | 12 ++----- kyaml/kio/kio_test.go | 47 ++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/cmd/config/internal/commands/source.go b/cmd/config/internal/commands/source.go index d731aa5c8..7873956ce 100644 --- a/cmd/config/internal/commands/source.go +++ b/cmd/config/internal/commands/source.go @@ -77,6 +77,6 @@ func (r *SourceRunner) runE(c *cobra.Command, args []string) error { inputs = []kio.Reader{&kio.ByteReader{Reader: c.InOrStdin()}} } - err := kio.Pipeline{Inputs: inputs, Outputs: outputs, ContinueIfInputEmpty: true}.Execute() + err := kio.Pipeline{Inputs: inputs, Outputs: outputs}.Execute() return handleError(c, err) } diff --git a/kyaml/kio/kio.go b/kyaml/kio/kio.go index c5165ab04..ee53bca40 100644 --- a/kyaml/kio/kio.go +++ b/kyaml/kio/kio.go @@ -75,11 +75,6 @@ type Pipeline struct { // Outputs are where the transformed Resource Configuration is written. Outputs []Writer `yaml:"outputs,omitempty"` - - // ContinueIfInputEmpty indicates should pipeline continue when the - // the input result is empty. This is useful when we want to run outputs - // even the input is empty. - ContinueIfInputEmpty bool } // Execute executes each step in the sequence, returning immediately after encountering @@ -104,10 +99,6 @@ func (p Pipeline) ExecuteWithCallback(callback PipelineExecuteCallbackFunc) erro } result = append(result, nodes...) } - if len(result) == 0 && !p.ContinueIfInputEmpty { - // no inputs to operate on - return nil - } // apply operations var err error @@ -117,6 +108,9 @@ func (p Pipeline) ExecuteWithCallback(callback PipelineExecuteCallbackFunc) erro callback(op) } result, err = op.Filter(result) + // TODO: This len(result) == 0 should be removed and empty result list should be + // handled by outputs. However currently the some writer like LocalPackageReadWriter + // will clear the output directory and which will cause unpredictable results if len(result) == 0 || err != nil { return errors.Wrap(err) } diff --git a/kyaml/kio/kio_test.go b/kyaml/kio/kio_test.go index ad4cd70bb..9a3a9ea27 100644 --- a/kyaml/kio/kio_test.go +++ b/kyaml/kio/kio_test.go @@ -78,7 +78,7 @@ func TestPipelineWithCallback(t *testing.T) { } } -func TestContinueIfInputEmpty(t *testing.T) { +func TestEmptyInput(t *testing.T) { actual := &bytes.Buffer{} output := ByteWriter{ Sort: true, @@ -88,8 +88,7 @@ func TestContinueIfInputEmpty(t *testing.T) { output.Writer = actual p := Pipeline{ - Outputs: []Writer{output}, - ContinueIfInputEmpty: true, + Outputs: []Writer{output}, } err := p.Execute() @@ -108,3 +107,45 @@ items: [] t.FailNow() } } + +func TestEmptyInputWithFilter(t *testing.T) { + actual := &bytes.Buffer{} + output := ByteWriter{ + Sort: true, + WrappingKind: ResourceListKind, + WrappingAPIVersion: ResourceListAPIVersion, + } + output.Writer = actual + + filters := []Filter{ + FilterFunc(func(nodes []*yaml.RNode) ([]*yaml.RNode, error) { + nodes = append(nodes, yaml.NewMapRNode(&map[string]string{ + "foo": "bar", + })) + return nodes, nil + }), + FilterFunc(func(nodes []*yaml.RNode) ([]*yaml.RNode, error) { return nodes, nil }), + } + + p := Pipeline{ + Outputs: []Writer{output}, + Filters: filters, + } + + err := p.Execute() + if err != nil { + t.Fatal(err) + } + + expected := ` +apiVersion: config.kubernetes.io/v1alpha1 +kind: ResourceList +items: +- foo: bar +` + + if !assert.Equal(t, + strings.TrimSpace(expected), strings.TrimSpace(actual.String())) { + t.FailNow() + } +} From edced4b3f6ad396c8f64f20af9ad3a62ca40fa37 Mon Sep 17 00:00:00 2001 From: jregan Date: Thu, 20 Aug 2020 11:15:04 -0700 Subject: [PATCH 04/23] Delete newly orphaned code. --- api/ifc/ifc.go | 47 ++- api/internal/target/kusttarget.go | 5 +- .../target}/multitransformer.go | 6 +- api/k8sdeps/kunstruct/unstructadapter_test.go | 272 ------------------ api/resource/resource.go | 32 --- api/transform/mutatefield.go | 77 ----- api/transform/mutatefield_test.go | 157 ---------- cmd/config/go.sum | 1 + kustomize/go.sum | 2 +- kyaml/go.sum | 1 + kyaml/runfn/runfn_test.go | 6 +- .../patchstrategicmergetransformer/go.sum | 1 + 12 files changed, 50 insertions(+), 557 deletions(-) rename api/{transform => internal/target}/multitransformer.go (92%) delete mode 100644 api/transform/mutatefield.go delete mode 100644 api/transform/mutatefield_test.go diff --git a/api/ifc/ifc.go b/api/ifc/ifc.go index 392e05489..1d12b3eae 100644 --- a/api/ifc/ifc.go +++ b/api/ifc/ifc.go @@ -41,32 +41,63 @@ type Loader interface { // Kunstructured allows manipulation of k8s objects // that do not have Golang structs. type Kunstructured interface { + // Several uses. Copy() Kunstructured + + // Used by Resource.Replace, in turned used by resWrangler.AbsorbAll, + // called by runGenerators to merge maps. Hmm. GetAnnotations() map[string]string - GetBool(path string) (bool, error) + + // Used by ResAccumulator and ReplacementTransformer. GetFieldValue(string) (interface{}, error) - GetFloat64(path string) (float64, error) + + // Used by Resource.OrgId GetGvk() resid.Gvk - GetInt64(path string) (int64, error) + + // Used by resource.Factory.SliceFromBytes GetKind() string + + // Used by Resource.Replace GetLabels() map[string]string - GetMap(path string) (map[string]interface{}, error) + + // Used by Resource.CurId and resource factory. GetName() string + + // Used by special case code used by ResMap.SubsetThatCouldBeReferencedByResource GetSlice(path string) ([]interface{}, error) + + // GetString returns the value of a string field. + // Used by Resource.GetNamespace GetString(string) (string, error) - GetStringMap(path string) (map[string]string, error) - GetStringSlice(string) ([]string, error) + + // Several uses. Map() map[string]interface{} + + // Used by Resource.AsYAML and Resource.String MarshalJSON() ([]byte, error) + + // Used by resWrangler.Select MatchesAnnotationSelector(selector string) (bool, error) + + // Used by resWrangler.Select MatchesLabelSelector(selector string) (bool, error) - Patch(Kunstructured) error + + // Used by Resource.Replace. SetAnnotations(map[string]string) + + // Used by PatchStrategicMergeTransformer. SetGvk(resid.Gvk) + + // Used by Resource.Replace and used to remove "validated by" labels. SetLabels(map[string]string) - SetMap(map[string]interface{}) + + // Used by Resource.Replace. SetName(string) + + // Used by Resource.Replace. SetNamespace(string) + + // Needed, for now, by kyaml/filtersutil.ApplyToJSON. UnmarshalJSON([]byte) error } diff --git a/api/internal/target/kusttarget.go b/api/internal/target/kusttarget.go index 702e25986..c8a60a80a 100644 --- a/api/internal/target/kusttarget.go +++ b/api/internal/target/kusttarget.go @@ -17,7 +17,6 @@ import ( "sigs.k8s.io/kustomize/api/internal/plugins/loader" "sigs.k8s.io/kustomize/api/konfig" "sigs.k8s.io/kustomize/api/resmap" - "sigs.k8s.io/kustomize/api/transform" "sigs.k8s.io/kustomize/api/types" "sigs.k8s.io/yaml" ) @@ -258,8 +257,7 @@ func (kt *KustTarget) runTransformers(ra *accumulator.ResAccumulator) error { return err } r = append(r, lts...) - t := transform.NewMultiTransformer(r) - return ra.Transform(t) + return ra.Transform(newMultiTransformer(r)) } func (kt *KustTarget) configureExternalTransformers(transformers []string) ([]resmap.Transformer, error) { @@ -294,7 +292,6 @@ func (kt *KustTarget) runValidators(ra *accumulator.ResAccumulator) error { } func (kt *KustTarget) removeValidatedByLabel(rm resmap.ResMap) { - resources := rm.Resources() for _, r := range resources { labels := r.GetLabels() diff --git a/api/transform/multitransformer.go b/api/internal/target/multitransformer.go similarity index 92% rename from api/transform/multitransformer.go rename to api/internal/target/multitransformer.go index b517d4717..19d6ed0d8 100644 --- a/api/transform/multitransformer.go +++ b/api/internal/target/multitransformer.go @@ -1,7 +1,7 @@ // Copyright 2019 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0 -package transform +package target import ( "fmt" @@ -17,8 +17,8 @@ type multiTransformer struct { var _ resmap.Transformer = &multiTransformer{} -// NewMultiTransformer constructs a multiTransformer. -func NewMultiTransformer(t []resmap.Transformer) resmap.Transformer { +// newMultiTransformer constructs a multiTransformer. +func newMultiTransformer(t []resmap.Transformer) resmap.Transformer { r := &multiTransformer{ transformers: make([]resmap.Transformer, len(t)), checkConflictEnabled: false} diff --git a/api/k8sdeps/kunstruct/unstructadapter_test.go b/api/k8sdeps/kunstruct/unstructadapter_test.go index 4a582d883..f1a7590e3 100644 --- a/api/k8sdeps/kunstruct/unstructadapter_test.go +++ b/api/k8sdeps/kunstruct/unstructadapter_test.go @@ -466,278 +466,6 @@ func TestGetString(t *testing.T) { } } -func TestGetInt64(t *testing.T) { - tests := []struct { - name string - pathToField string - expectedValue int64 - errorExpected bool - errorMsg string - }{ - { - name: "numberAsValue", - pathToField: "this.is.aNumber", - errorExpected: false, - expectedValue: int64(1000), - }, - { - name: "validStructSubFieldIndexSubfield", - pathToField: "complextree[1].field2[1].intsubfield", - errorExpected: false, - expectedValue: int64(1121), - }, - { - name: "twoFieldsOneMissing", - pathToField: "metadata.banana", - errorExpected: true, - errorMsg: "no field named 'metadata.banana'", - }, - { - name: "validStructSubFieldOutOfBoundIndex", - pathToField: "these[1].field2[99]", - errorExpected: true, - errorMsg: "no field named 'these[1].field2[99]'", - }, - { - name: "validDownwardAPISpecs", - pathToField: `spec.ports['port']`, - errorExpected: false, - expectedValue: int64(80), - }, - } - - for _, test := range tests { - s, err := kunstructured.GetInt64(test.pathToField) - if test.errorExpected { - compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg) - continue - } - if err != nil { - unExpectedError(t, test.name, test.pathToField, err) - } - compareValues(t, test.name, test.pathToField, test.expectedValue, s) - } -} - -func TestGetFloat64(t *testing.T) { - tests := []struct { - name string - pathToField string - expectedValue float64 - errorExpected bool - errorMsg string - }{ - { - name: "floatAsValue", - pathToField: "this.is.aFloat", - errorExpected: false, - expectedValue: float64(1.001), - }, - { - name: "validStructSubFieldIndexSubfield", - pathToField: "complextree[1].field2[1].floatsubfield", - errorExpected: false, - expectedValue: float64(1.1121), - }, - { - name: "validDownwardAPIThis", - pathToField: `this.is[aFloat]`, - errorExpected: false, - expectedValue: float64(1.001), - }, - { - name: "twoFieldsOneMissing", - pathToField: "metadata.banana", - errorExpected: true, - errorMsg: "no field named 'metadata.banana'", - }, - { - name: "validStructSubFieldOutOfBoundIndex", - pathToField: "these[1].field2[99]", - errorExpected: true, - errorMsg: "index 99 is out of bounds", - }, - } - - for _, test := range tests { - s, err := kunstructured.GetFloat64(test.pathToField) - if test.errorExpected { - compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg) - continue - } - if err != nil { - unExpectedError(t, test.name, test.pathToField, err) - } - compareValues(t, test.name, test.pathToField, test.expectedValue, s) - } -} - -func TestGetBool(t *testing.T) { - tests := []struct { - name string - pathToField string - expectedValue bool - errorExpected bool - errorMsg string - }{ - { - name: "boolAsValue", - pathToField: "this.is.aBool", - errorExpected: false, - expectedValue: true, - }, - { - name: "validStructSubFieldIndexSubfield", - pathToField: "complextree[1].field2[1].boolfield", - errorExpected: false, - expectedValue: false, - }, - { - name: "twoFieldsOneMissing", - pathToField: "metadata.banana", - errorExpected: true, - errorMsg: "no field named 'metadata.banana'", - }, - { - name: "validStructSubFieldOutOfBoundIndex", - pathToField: "these[1].field2[99]", - errorExpected: true, - errorMsg: "no field named 'these[1].field2[99]'", - }, - } - - for _, test := range tests { - s, err := kunstructured.GetBool(test.pathToField) - if test.errorExpected { - compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg) - continue - } - if err != nil { - unExpectedError(t, test.name, test.pathToField, err) - } - compareValues(t, test.name, test.pathToField, test.expectedValue, s) - } -} - -func TestGetStringMap(t *testing.T) { - tests := []struct { - name string - pathToField string - errorExpected bool - errorMsg string - }{ - { - name: "validStringMap", - pathToField: "those[2]", - errorExpected: false, - }, - { - name: "twoFieldsOneMissing", - pathToField: "metadata.banana", - errorExpected: true, - errorMsg: "no field named 'metadata.banana'", - }, - { - name: "validStructSubFieldOutOfBoundIndex", - pathToField: "these[1].field2[99]", - errorExpected: true, - errorMsg: "no field named 'these[1].field2[99]'", - }, - } - - for _, test := range tests { - _, err := kunstructured.GetStringMap(test.pathToField) - if test.errorExpected { - compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg) - continue - } - if err != nil { - unExpectedError(t, test.name, test.pathToField, err) - } - } -} - -func TestGetMap(t *testing.T) { - tests := []struct { - name string - pathToField string - errorExpected bool - errorMsg string - }{ - { - name: "validMap", - pathToField: "those[2]", - errorExpected: false, - }, - { - name: "validStructSubFieldIndexSubfield", - pathToField: "complextree[1].field2[1]", - errorExpected: false, - }, - { - name: "twoFieldsOneMissing", - pathToField: "metadata.banana", - errorExpected: true, - errorMsg: "no field named 'metadata.banana'", - }, - { - name: "validStructSubFieldOutOfBoundIndex", - pathToField: "these[1].field2[99]", - errorExpected: true, - errorMsg: "no field named 'these[1].field2[99]'", - }, - } - - for _, test := range tests { - _, err := kunstructured.GetMap(test.pathToField) - if test.errorExpected { - compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg) - continue - } - if err != nil { - unExpectedError(t, test.name, test.pathToField, err) - } - } -} - -func TestGetStringSlice(t *testing.T) { - tests := []struct { - name string - pathToField string - errorExpected bool - errorMsg string - }{ - { - name: "validStringSlice", - pathToField: "that", - errorExpected: false, - }, - { - name: "twoFieldsOneMissing", - pathToField: "metadata.banana", - errorExpected: true, - errorMsg: "no field named 'metadata.banana'", - }, - { - name: "validStructSubFieldOutOfBoundIndex", - pathToField: "these[1].field2[99]", - errorExpected: true, - errorMsg: "no field named 'these[1].field2[99]'", - }, - } - - for _, test := range tests { - _, err := kunstructured.GetStringSlice(test.pathToField) - if test.errorExpected { - compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg) - continue - } - if err != nil { - unExpectedError(t, test.name, test.pathToField, err) - } - } -} - func TestGetSlice(t *testing.T) { tests := []struct { name string diff --git a/api/resource/resource.go b/api/resource/resource.go index 7b1abab40..109276c72 100644 --- a/api/resource/resource.go +++ b/api/resource/resource.go @@ -86,26 +86,14 @@ func (r *Resource) Copy() ifc.Kunstructured { return r.kunStr.Copy() } -func (r *Resource) GetBool(p string) (bool, error) { - return r.kunStr.GetBool(p) -} - func (r *Resource) GetFieldValue(f string) (interface{}, error) { return r.kunStr.GetFieldValue(f) } -func (r *Resource) GetFloat64(p string) (float64, error) { - return r.kunStr.GetFloat64(p) -} - func (r *Resource) GetGvk() resid.Gvk { return r.kunStr.GetGvk() } -func (r *Resource) GetInt64(p string) (int64, error) { - return r.kunStr.GetInt64(p) -} - func (r *Resource) GetKind() string { return r.kunStr.GetKind() } @@ -114,10 +102,6 @@ func (r *Resource) GetLabels() map[string]string { return r.kunStr.GetLabels() } -func (r *Resource) GetMap(p string) (map[string]interface{}, error) { - return r.kunStr.GetMap(p) -} - func (r *Resource) GetName() string { return r.kunStr.GetName() } @@ -130,14 +114,6 @@ func (r *Resource) GetString(p string) (string, error) { return r.kunStr.GetString(p) } -func (r *Resource) GetStringMap(p string) (map[string]string, error) { - return r.kunStr.GetStringMap(p) -} - -func (r *Resource) GetStringSlice(p string) ([]string, error) { - return r.kunStr.GetStringSlice(p) -} - func (r *Resource) Map() map[string]interface{} { return r.kunStr.Map() } @@ -154,10 +130,6 @@ func (r *Resource) MatchesAnnotationSelector(selector string) (bool, error) { return r.kunStr.MatchesAnnotationSelector(selector) } -func (r *Resource) Patch(other ifc.Kunstructured) error { - return r.kunStr.Patch(other) -} - func (r *Resource) SetAnnotations(m map[string]string) { r.kunStr.SetAnnotations(m) } @@ -170,10 +142,6 @@ func (r *Resource) SetLabels(m map[string]string) { r.kunStr.SetLabels(m) } -func (r *Resource) SetMap(m map[string]interface{}) { - r.kunStr.SetMap(m) -} - func (r *Resource) SetName(n string) { r.kunStr.SetName(n) } diff --git a/api/transform/mutatefield.go b/api/transform/mutatefield.go deleted file mode 100644 index 3b50c6c72..000000000 --- a/api/transform/mutatefield.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2019 The Kubernetes Authors. -// SPDX-License-Identifier: Apache-2.0 - -package transform - -import ( - "fmt" - "log" - "strings" -) - -type mutateFunc func(interface{}) (interface{}, error) - -func MutateField( - m map[string]interface{}, - pathToField []string, - createIfNotPresent bool, - fns ...mutateFunc) error { - if len(pathToField) == 0 { - return nil - } - - firstPathSegment, isArray := getFirstPathSegment(pathToField) - - _, found := m[firstPathSegment] - if !found { - if !createIfNotPresent || isArray { - return nil - } - m[firstPathSegment] = map[string]interface{}{} - } - - if len(pathToField) == 1 { - var err error - for _, fn := range fns { - m[firstPathSegment], err = fn(m[firstPathSegment]) - if err != nil { - return err - } - } - return nil - } - - v := m[firstPathSegment] - newPathToField := pathToField[1:] - switch typedV := v.(type) { - case nil: - log.Printf( - "nil value at `%s` ignored in mutation attempt", - strings.Join(pathToField, ".")) - return nil - case map[string]interface{}: - return MutateField(typedV, newPathToField, createIfNotPresent, fns...) - case []interface{}: - for i := range typedV { - item := typedV[i] - typedItem, ok := item.(map[string]interface{}) - if !ok { - return fmt.Errorf("%#v is expected to be %T", item, typedItem) - } - err := MutateField(typedItem, newPathToField, createIfNotPresent, fns...) - if err != nil { - return err - } - } - return nil - default: - return fmt.Errorf("%#v is not expected to be a primitive type", typedV) - } -} - -func getFirstPathSegment(pathToField []string) (string, bool) { - if strings.HasSuffix(pathToField[0], "[]") { - return pathToField[0][:len(pathToField[0])-2], true - } - return pathToField[0], false -} diff --git a/api/transform/mutatefield_test.go b/api/transform/mutatefield_test.go deleted file mode 100644 index 8fdafc68c..000000000 --- a/api/transform/mutatefield_test.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2019 The Kubernetes Authors. -// SPDX-License-Identifier: Apache-2.0 - -package transform_test - -import ( - "fmt" - "testing" - - "sigs.k8s.io/kustomize/api/ifc" - "sigs.k8s.io/kustomize/api/k8sdeps/kunstruct" - . "sigs.k8s.io/kustomize/api/transform" -) - -type noopMutator struct { - wasCalled bool - errorToReturn error -} - -var errExpected = fmt.Errorf("oops") - -const originalValue = "tomato" -const newValue = "notThe" + originalValue - -func (m *noopMutator) mutate(_ interface{}) (interface{}, error) { - m.wasCalled = true - return newValue, m.errorToReturn -} - -func makeTestDeployment() ifc.Kunstructured { - factory := kunstruct.NewKunstructuredFactoryImpl() - return factory.FromMap( - map[string]interface{}{ - "group": "apps", - "apiVersion": "v1", - "kind": "Deployment", - "metadata": map[string]interface{}{ - "name": originalValue, - }, - "spec": map[string]interface{}{ - "template": map[string]interface{}{ - "env": []interface{}{ - map[string]interface{}{ - "name": "HELLO", - "value": "hi there", - }, - map[string]interface{}{ - "name": "GOODBYE", - "value": "adios!", - }, - }, - "metadata": map[string]interface{}{ - "labels": map[string]interface{}{ - "vegetable": originalValue, - }, - }, - "spec": map[string]interface{}{ - "containers": []interface{}{ - map[string]interface{}{ - "name": "tangerine", - "image": originalValue, - }, - }, - }, - }, - }, - }) -} - -func getFieldValue(t *testing.T, obj ifc.Kunstructured, fieldName string) string { - v, err := obj.GetString(fieldName) - if err != nil { - t.Fatalf("unexpected field error: %v", err) - } - return v -} - -func TestNoPath(t *testing.T) { - obj := makeTestDeployment() - m := &noopMutator{} - err := MutateField( - obj.Map(), []string{}, false, m.mutate) - if m.wasCalled { - t.Fatalf("mutator should not have been called.") - } - if err != nil { - t.Fatalf("unexpected error: %v", err) - } -} - -func TestHappyPath(t *testing.T) { - obj := makeTestDeployment() - v := getFieldValue(t, obj, "metadata.name") - if v != originalValue { - t.Fatalf("unexpected original value: %v", v) - } - v = getFieldValue(t, obj, "spec.template.metadata.labels.vegetable") - if v != originalValue { - t.Fatalf("unexpected original value: %v", v) - } - - m := &noopMutator{} - err := MutateField( - obj.Map(), []string{"metadata", "name"}, false, m.mutate) - if !m.wasCalled { - t.Fatalf("mutator should have been called.") - } - if err != nil { - t.Fatalf("unexpected mutate error: %v", err) - } - v = getFieldValue(t, obj, "metadata.name") - if v != newValue { - t.Fatalf("unexpected new value: %v", v) - } - - m = &noopMutator{} - err = MutateField( - obj.Map(), []string{"spec", "template", "metadata", "labels", "vegetable"}, false, m.mutate) - if !m.wasCalled { - t.Fatalf("mutator should have been called.") - } - if err != nil { - t.Fatalf("unexpected mutate error: %v", err) - } - v = getFieldValue(t, obj, "spec.template.metadata.labels.vegetable") - if v != newValue { - t.Fatalf("unexpected new value: %v", v) - } -} - -func TestWithError(t *testing.T) { - obj := makeTestDeployment() - m := noopMutator{errorToReturn: errExpected} - err := MutateField( - obj.Map(), []string{"metadata", "name"}, false, m.mutate) - if !m.wasCalled { - t.Fatalf("mutator was not called!") - } - if err != errExpected { - t.Fatalf("unexpected error: %v", err) - } -} - -func TestWithNil(t *testing.T) { - obj := makeTestDeployment() - foo := obj.Map()["spec"] - foo = foo.(map[string]interface{})["template"] - foo = foo.(map[string]interface{})["metadata"] - foo.(map[string]interface{})["labels"] = nil - - m := &noopMutator{} - err := MutateField( - obj.Map(), []string{"spec", "template", "metadata", "labels", "vegetable"}, false, m.mutate) - if err != nil { - t.Fatalf("Unexpected error: %v", err) - } -} diff --git a/cmd/config/go.sum b/cmd/config/go.sum index fb2f74a86..fe59a915f 100644 --- a/cmd/config/go.sum +++ b/cmd/config/go.sum @@ -369,6 +369,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/kustomize/go.sum b/kustomize/go.sum index 230ea3a57..f5b591a41 100644 --- a/kustomize/go.sum +++ b/kustomize/go.sum @@ -239,7 +239,6 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -459,6 +458,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/kyaml/go.sum b/kyaml/go.sum index 3f59e9e66..d4af2875b 100644 --- a/kyaml/go.sum +++ b/kyaml/go.sum @@ -185,6 +185,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/kyaml/runfn/runfn_test.go b/kyaml/runfn/runfn_test.go index 333b641be..fd9237209 100644 --- a/kyaml/runfn/runfn_test.go +++ b/kyaml/runfn/runfn_test.go @@ -920,10 +920,10 @@ func TestCmd_Execute_enableLogSteps(t *testing.T) { logs := &bytes.Buffer{} instance := RunFns{ - Path: dir, + Path: dir, functionFilterProvider: getFilterProvider(t), - LogSteps: true, - LogWriter: logs, + LogSteps: true, + LogWriter: logs, } if !assert.NoError(t, instance.Execute()) { t.FailNow() diff --git a/plugin/builtin/patchstrategicmergetransformer/go.sum b/plugin/builtin/patchstrategicmergetransformer/go.sum index a3f4c9b1d..648e4f233 100644 --- a/plugin/builtin/patchstrategicmergetransformer/go.sum +++ b/plugin/builtin/patchstrategicmergetransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= From d03cf061e864670fcc1f392ae64c1506b53769cd Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Tue, 18 Aug 2020 12:48:41 -0700 Subject: [PATCH 05/23] Update kyaml to specify user for function --- kyaml/fn/runtime/container/container.go | 11 ++++++++-- kyaml/fn/runtime/container/container_test.go | 20 +++++++++++++++++++ kyaml/fn/runtime/runtimeutil/functiontypes.go | 3 +++ kyaml/runfn/runfn.go | 9 +++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/kyaml/fn/runtime/container/container.go b/kyaml/fn/runtime/container/container.go index 209aba93d..223290a3d 100644 --- a/kyaml/fn/runtime/container/container.go +++ b/kyaml/fn/runtime/container/container.go @@ -133,6 +133,9 @@ type Filter struct { // StorageMounts is a list of storage options that the container will have mounted. StorageMounts []runtimeutil.StorageMount `yaml:"mounts,omitempty"` + // User username used to run the application in container, + User string + Exec runtimeexec.Filter } @@ -174,14 +177,18 @@ func (c *Filter) getCommand() (string, []string) { if c.Network != "" { network = c.Network } - + // run as nobody by default + user := c.User + if user == "" { + user = "nobody" + } args := []string{"run", "--rm", // delete the container afterward "-i", "-a", "STDIN", "-a", "STDOUT", "-a", "STDERR", // attach stdin, stdout, stderr "--network", network, // added security options - "--user", "nobody", // run as nobody + "--user", user, "--security-opt=no-new-privileges", // don't allow the user to escalate privileges // note: don't make fs readonly because things like heredoc rely on writing tmp files } diff --git a/kyaml/fn/runtime/container/container_test.go b/kyaml/fn/runtime/container/container_test.go index fdf037fab..fd2d99bc3 100644 --- a/kyaml/fn/runtime/container/container_test.go +++ b/kyaml/fn/runtime/container/container_test.go @@ -88,6 +88,26 @@ metadata: }, }, }, + { + name: "root user", + functionConfig: `apiVersion: apps/v1 +kind: Deployment +metadata: + name: foo +`, + expectedArgs: []string{ + "run", + "--rm", + "-i", "-a", "STDIN", "-a", "STDOUT", "-a", "STDERR", + "--network", "none", + "--user", "root", + "--security-opt=no-new-privileges", + }, + instance: Filter{ + Image: "example.com:version", + User: "root", + }, + }, } for i := range tests { diff --git a/kyaml/fn/runtime/runtimeutil/functiontypes.go b/kyaml/fn/runtime/runtimeutil/functiontypes.go index 29bb9be73..038bdb80e 100644 --- a/kyaml/fn/runtime/runtimeutil/functiontypes.go +++ b/kyaml/fn/runtime/runtimeutil/functiontypes.go @@ -52,6 +52,9 @@ type ContainerSpec struct { // Mounts are the storage or directories to mount into the container StorageMounts []StorageMount `json:"mounts,omitempty" yaml:"mounts,omitempty"` + + // User is the username/uid that application runs as in continer + User string `json:"user,omitempty" yaml:"user,omitempty"` } // ContainerNetwork diff --git a/kyaml/runfn/runfn.go b/kyaml/runfn/runfn.go index 5c3b99fb7..5351d82f4 100644 --- a/kyaml/runfn/runfn.go +++ b/kyaml/runfn/runfn.go @@ -87,6 +87,9 @@ type RunFns struct { // this is a variable so it can be mocked in tests functionFilterProvider func( filter runtimeutil.FunctionSpec, api *yaml.RNode) (kio.Filter, error) + + // User username used to run the application in container, + User string } // Execute runs the command @@ -380,11 +383,17 @@ func (r *RunFns) ffp(spec runtimeutil.FunctionSpec, api *yaml.RNode) (kio.Filter atomic.AddUint32(&r.resultsCount, 1) } if !r.DisableContainers && spec.Container.Image != "" { + // command line username has higher priority + user := spec.Container.User + if r.User != "" { + user = r.User + } // TODO: Add a test for this behavior cf := &container.Filter{ Image: spec.Container.Image, Network: spec.Network, StorageMounts: r.StorageMounts, + User: user, } cf.Exec.FunctionConfig = api cf.Exec.GlobalScope = r.GlobalScope From b6900ead22c8138bb1db1a74d4ffa331dc7a1319 Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Thu, 20 Aug 2020 17:01:03 -0700 Subject: [PATCH 06/23] update TODO with issue number --- kyaml/kio/kio.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kyaml/kio/kio.go b/kyaml/kio/kio.go index ee53bca40..91efde1d9 100644 --- a/kyaml/kio/kio.go +++ b/kyaml/kio/kio.go @@ -108,8 +108,8 @@ func (p Pipeline) ExecuteWithCallback(callback PipelineExecuteCallbackFunc) erro callback(op) } result, err = op.Filter(result) - // TODO: This len(result) == 0 should be removed and empty result list should be - // handled by outputs. However currently the some writer like LocalPackageReadWriter + // TODO (issue 2872): This len(result) == 0 should be removed and empty result list should be + // handled by outputs. However currently some writer like LocalPackageReadWriter // will clear the output directory and which will cause unpredictable results if len(result) == 0 || err != nil { return errors.Wrap(err) From a1cd23c91d7a2f19be2a1ece00cb3d6efb8e0f2d Mon Sep 17 00:00:00 2001 From: Morten Torkildsen Date: Thu, 20 Aug 2020 19:34:12 -0700 Subject: [PATCH 07/23] Bump cli-utils version to v0.19.0 --- cmd/config/configcobra/live.go | 4 ++-- cmd/config/go.mod | 2 +- cmd/config/go.sum | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/config/configcobra/live.go b/cmd/config/configcobra/live.go index 3ba237d96..a2c826967 100644 --- a/cmd/config/configcobra/live.go +++ b/cmd/config/configcobra/live.go @@ -54,9 +54,9 @@ func GetLive(name string) *cobra.Command { cmd.AddCommand( applyCmd, initcmd.NewCmdInit(ioStreams), - preview.NewCmdPreview(f, ioStreams), + preview.GetPreviewRunner(f, ioStreams).Command, diff.NewCmdDiff(f, ioStreams), - destroy.NewCmdDestroy(f, ioStreams)) + destroy.GetDestroyRunner(f, ioStreams).Command) return cmd } diff --git a/cmd/config/go.mod b/cmd/config/go.mod index e419e4de1..677eac651 100644 --- a/cmd/config/go.mod +++ b/cmd/config/go.mod @@ -14,7 +14,7 @@ require ( k8s.io/cli-runtime v0.17.3 k8s.io/client-go v0.17.3 k8s.io/kubectl v0.0.0-20191219154910-1528d4eea6dd - sigs.k8s.io/cli-utils v0.18.0 + sigs.k8s.io/cli-utils v0.19.0 sigs.k8s.io/kustomize/kyaml v0.6.0 ) diff --git a/cmd/config/go.sum b/cmd/config/go.sum index fe59a915f..2eefbef24 100644 --- a/cmd/config/go.sum +++ b/cmd/config/go.sum @@ -617,6 +617,8 @@ modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= sigs.k8s.io/cli-utils v0.18.0 h1:PPFUhhwKsdMiYYm1DY9lZursNWSAEj8FYgMCZKVvOkQ= sigs.k8s.io/cli-utils v0.18.0/go.mod h1:B7KdqkSkHNIUn3cFbaR4aKUZMKtr+Benboi1w/HW/Fg= +sigs.k8s.io/cli-utils v0.19.0 h1:lAoR5okhSV/dIusodaQp5VbDpHMcKnvjqKYHU+AB3a4= +sigs.k8s.io/cli-utils v0.19.0/go.mod h1:B7KdqkSkHNIUn3cFbaR4aKUZMKtr+Benboi1w/HW/Fg= sigs.k8s.io/controller-runtime v0.4.0 h1:wATM6/m+3w8lj8FXNaO6Fs/rq/vqoOjO1Q116Z9NPsg= sigs.k8s.io/controller-runtime v0.4.0/go.mod h1:ApC79lpY3PHW9xj/w9pj+lYkLgwAAUZwfXkME1Lajns= sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= From faef5714bfc3a378c17e57e74a438f9a38f3a5d7 Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Fri, 21 Aug 2020 18:11:47 +0000 Subject: [PATCH 08/23] Feed generated changelog as input to goreleaser. --- releasing/cloudbuild.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/releasing/cloudbuild.sh b/releasing/cloudbuild.sh index 5b7da209f..e7aec2e7f 100755 --- a/releasing/cloudbuild.sh +++ b/releasing/cloudbuild.sh @@ -34,6 +34,12 @@ echo "Remaining args: $remainingArgs" module=${fullTag%/*} echo "module=$module" +# Obtain most recent commit hash associated with the module. +lastCommitHash=$(git log --tags=$module -1 --oneline --no-walk --pretty=format:%h) + +# Generate the changelog for this release using commit hashes and commit messages. +cl=$(git log $lastCommitHash.. --pretty=oneline --abbrev-commit --no-decorate --no-color -- $module) + # Take everything after the last slash. # This should be something like "v1.2.3". semVer=`echo $fullTag | sed "s|$module/||"` @@ -111,4 +117,4 @@ EOF cat $configFile -/bin/goreleaser release --config=$configFile --rm-dist --skip-validate $remainingArgs +/bin/goreleaser release --config=$configFile --rm-dist --skip-validate $remainingArgs --release-notes <"$cl" From 451c5c32c9c83e643708d91a97df11aef67d171d Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Fri, 21 Aug 2020 12:05:11 -0700 Subject: [PATCH 09/23] code review --- kyaml/fn/runtime/container/container.go | 24 ++--------- kyaml/fn/runtime/container/container_test.go | 42 +++++++++++++------ kyaml/fn/runtime/runtimeutil/functiontypes.go | 25 ++++++++--- kyaml/runfn/runfn.go | 28 ++++++++----- kyaml/runfn/runfn_test.go | 4 +- 5 files changed, 73 insertions(+), 50 deletions(-) diff --git a/kyaml/fn/runtime/container/container.go b/kyaml/fn/runtime/container/container.go index 223290a3d..9f34f1512 100644 --- a/kyaml/fn/runtime/container/container.go +++ b/kyaml/fn/runtime/container/container.go @@ -123,18 +123,7 @@ import ( //    ├── deployment_foo.yaml //    └── service_bar.yaml type Filter struct { - - // Image is the container image to use to create a container. - Image string `yaml:"image,omitempty"` - - // Network is the container network to use. - Network string `yaml:"network,omitempty"` - - // StorageMounts is a list of storage options that the container will have mounted. - StorageMounts []runtimeutil.StorageMount `yaml:"mounts,omitempty"` - - // User username used to run the application in container, - User string + runtimeutil.ContainerSpec `json:",inline" yaml:",inline"` Exec runtimeexec.Filter } @@ -174,13 +163,8 @@ func (c *Filter) getCommand() (string, []string) { // was run from the cli. network := "none" - if c.Network != "" { - network = c.Network - } - // run as nobody by default - user := c.User - if user == "" { - user = "nobody" + if c.Network.Name != "" { + network = c.Network.Name } args := []string{"run", "--rm", // delete the container afterward @@ -188,7 +172,7 @@ func (c *Filter) getCommand() (string, []string) { "--network", network, // added security options - "--user", user, + "--user", c.User.String(), "--security-opt=no-new-privileges", // don't allow the user to escalate privileges // note: don't make fs readonly because things like heredoc rely on writing tmp files } diff --git a/kyaml/fn/runtime/container/container_test.go b/kyaml/fn/runtime/container/container_test.go index fd2d99bc3..bd6f0e6b3 100644 --- a/kyaml/fn/runtime/container/container_test.go +++ b/kyaml/fn/runtime/container/container_test.go @@ -38,7 +38,12 @@ metadata: "--user", "nobody", "--security-opt=no-new-privileges", }, - instance: Filter{Image: "example.com:version"}, + instance: Filter{ + ContainerSpec: runtimeutil.ContainerSpec{ + Image: "example.com:version", + User: "nobody", + }, + }, }, { @@ -56,7 +61,15 @@ metadata: "--user", "nobody", "--security-opt=no-new-privileges", }, - instance: Filter{Image: "example.com:version", Network: "test-1"}, + instance: Filter{ + ContainerSpec: runtimeutil.ContainerSpec{ + Image: "example.com:version", + Network: runtimeutil.ContainerNetwork{ + Name: "test-1", + }, + User: "nobody", + }, + }, }, { @@ -79,12 +92,15 @@ metadata: "--mount", fmt.Sprintf("type=%s,source=%s,target=%s,readonly", "tmpfs", "", "/local/"), }, instance: Filter{ - Image: "example.com:version", - StorageMounts: []runtimeutil.StorageMount{ - {MountType: "bind", Src: "/mount/path", DstPath: "/local/"}, - {MountType: "bind", Src: "/mount/pathrw", DstPath: "/localrw/", ReadWriteMode: true}, - {MountType: "volume", Src: "myvol", DstPath: "/local/"}, - {MountType: "tmpfs", Src: "", DstPath: "/local/"}, + ContainerSpec: runtimeutil.ContainerSpec{ + Image: "example.com:version", + StorageMounts: []runtimeutil.StorageMount{ + {MountType: "bind", Src: "/mount/path", DstPath: "/local/"}, + {MountType: "bind", Src: "/mount/pathrw", DstPath: "/localrw/", ReadWriteMode: true}, + {MountType: "volume", Src: "myvol", DstPath: "/local/"}, + {MountType: "tmpfs", Src: "", DstPath: "/local/"}, + }, + User: "nobody", }, }, }, @@ -104,8 +120,10 @@ metadata: "--security-opt=no-new-privileges", }, instance: Filter{ - Image: "example.com:version", - User: "root", + ContainerSpec: runtimeutil.ContainerSpec{ + Image: "example.com:version", + User: "root", + }, }, }, } @@ -203,7 +221,7 @@ metadata: } } func TestFilter_String(t *testing.T) { - instance := Filter{Image: "foo"} + instance := Filter{ContainerSpec: runtimeutil.ContainerSpec{Image: "foo"}} if !assert.Equal(t, "foo", instance.String()) { t.FailNow() } @@ -234,7 +252,7 @@ func TestFilter_ExitCode(t *testing.T) { func TestIgnoreEnv(t *testing.T) { os.Setenv(tmpDirEnvKey, "") - fltr := Filter{Image: "example.com:version"} + fltr := Filter{ContainerSpec: runtimeutil.ContainerSpec{Image: "example.com:version"}} _, args := fltr.getCommand() for _, arg := range args { if arg == tmpDirEnvKey { diff --git a/kyaml/fn/runtime/runtimeutil/functiontypes.go b/kyaml/fn/runtime/runtimeutil/functiontypes.go index 038bdb80e..7eb1c7056 100644 --- a/kyaml/fn/runtime/runtimeutil/functiontypes.go +++ b/kyaml/fn/runtime/runtimeutil/functiontypes.go @@ -18,11 +18,23 @@ const ( var functionAnnotationKeys = []string{FunctionAnnotationKey, oldFunctionAnnotationKey} +// ContainerUser is a type for username/uid used in container +type ContainerUser string + +func (u *ContainerUser) String() string { + return string(*u) +} + +func (u *ContainerUser) IsEmpty() bool { + return string(*u) == "" +} + +const ( + UserNobody ContainerUser = "nobody" +) + // FunctionSpec defines a spec for running a function type FunctionSpec struct { - // Network is the name of the network to use from a container - Network string `json:"network,omitempty" yaml:"network,omitempty"` - DeferFailure bool `json:"deferFailure,omitempty" yaml:"deferFailure,omitempty"` // Container is the spec for running a function as a container @@ -54,13 +66,16 @@ type ContainerSpec struct { StorageMounts []StorageMount `json:"mounts,omitempty" yaml:"mounts,omitempty"` // User is the username/uid that application runs as in continer - User string `json:"user,omitempty" yaml:"user,omitempty"` + User ContainerUser `json:"user,omitempty" yaml:"user,omitempty"` } // ContainerNetwork type ContainerNetwork struct { // Required specifies that function requires a network Required bool `json:"required,omitempty" yaml:"required,omitempty"` + + // Name is the name of the network to use from a container + Name string `json:"name,omitempty" yaml:"name,omitempty"` } // StarlarkSpec defines how to run a function as a starlark program @@ -113,7 +128,7 @@ func GetFunctionSpec(n *yaml.RNode) *FunctionSpec { } if fn := getFunctionSpecFromAnnotation(n, meta); fn != nil { - fn.Network = "" + fn.Container.Network.Name = "" fn.StorageMounts = []StorageMount{} return fn } diff --git a/kyaml/runfn/runfn.go b/kyaml/runfn/runfn.go index 5351d82f4..c757967e2 100644 --- a/kyaml/runfn/runfn.go +++ b/kyaml/runfn/runfn.go @@ -89,7 +89,7 @@ type RunFns struct { filter runtimeutil.FunctionSpec, api *yaml.RNode) (kio.Filter, error) // User username used to run the application in container, - User string + User runtimeutil.ContainerUser } // Execute runs the command @@ -280,8 +280,17 @@ func (r RunFns) getFunctionFilters(global bool, fns ...*yaml.RNode) ( // TODO(eddiezane): Provide error info about which function needs the network return fltrs, errors.Errorf("network required but not enabled with --network") } - spec.Network = r.NetworkName + spec.Container.Network.Name = r.NetworkName } + // command line username has higher priority + if r.User != "" { + spec.Container.User = r.User + } + // default user is nobody + if spec.Container.User.IsEmpty() { + spec.Container.User = runtimeutil.UserNobody + } + c, err := r.functionFilterProvider(*spec, api) if err != nil { return nil, err @@ -383,17 +392,14 @@ func (r *RunFns) ffp(spec runtimeutil.FunctionSpec, api *yaml.RNode) (kio.Filter atomic.AddUint32(&r.resultsCount, 1) } if !r.DisableContainers && spec.Container.Image != "" { - // command line username has higher priority - user := spec.Container.User - if r.User != "" { - user = r.User - } // TODO: Add a test for this behavior cf := &container.Filter{ - Image: spec.Container.Image, - Network: spec.Network, - StorageMounts: r.StorageMounts, - User: user, + ContainerSpec: runtimeutil.ContainerSpec{ + Image: spec.Container.Image, + Network: spec.Container.Network, + StorageMounts: r.StorageMounts, + User: spec.Container.User, + }, } cf.Exec.FunctionConfig = api cf.Exec.GlobalScope = r.GlobalScope diff --git a/kyaml/runfn/runfn_test.go b/kyaml/runfn/runfn_test.go index fd9237209..8599609fc 100644 --- a/kyaml/runfn/runfn_test.go +++ b/kyaml/runfn/runfn_test.go @@ -60,7 +60,7 @@ kind: return } filter, _ := instance.functionFilterProvider(spec, api) - cf := &container.Filter{Image: "example.com:version"} + cf := &container.Filter{ContainerSpec: runtimeutil.ContainerSpec{Image: "example.com:version"}} cf.Exec.FunctionConfig = api assert.Equal(t, cf, filter) } @@ -90,7 +90,7 @@ kind: return } filter, _ := instance.functionFilterProvider(spec, api) - cf := &container.Filter{Image: "example.com:version"} + cf := &container.Filter{ContainerSpec: runtimeutil.ContainerSpec{Image: "example.com:version"}} cf.Exec.FunctionConfig = api cf.Exec.GlobalScope = true assert.Equal(t, cf, filter) From d5f868c5c74ee859c47037127f6d0e16f6744a17 Mon Sep 17 00:00:00 2001 From: jregan Date: Fri, 21 Aug 2020 15:26:54 -0700 Subject: [PATCH 10/23] Gvk.ParseGroupVersion function. --- api/ifc/ifc.go | 9 +++-- api/resid/gvk.go | 11 ++++-- api/resid/gvk_test.go | 24 +++++++++++++ api/resource/resource.go | 77 ++++++++-------------------------------- cmd/config/go.sum | 2 -- kustomize/go.sum | 4 +-- 6 files changed, 56 insertions(+), 71 deletions(-) diff --git a/api/ifc/ifc.go b/api/ifc/ifc.go index 1d12b3eae..b17da2c59 100644 --- a/api/ifc/ifc.go +++ b/api/ifc/ifc.go @@ -44,8 +44,10 @@ type Kunstructured interface { // Several uses. Copy() Kunstructured - // Used by Resource.Replace, in turned used by resWrangler.AbsorbAll, - // called by runGenerators to merge maps. Hmm. + // Used by Resource.Replace, which in turn is used in many places, e.g. + // - resource.Resource.Merge + // - resWrangler.appendReplaceOrMerge (AbsorbAll) + // - api.internal.k8sdeps.transformer.patch.conflictdetector GetAnnotations() map[string]string // Used by ResAccumulator and ReplacementTransformer. @@ -63,7 +65,8 @@ type Kunstructured interface { // Used by Resource.CurId and resource factory. GetName() string - // Used by special case code used by ResMap.SubsetThatCouldBeReferencedByResource + // Used by special case code in + // ResMap.SubsetThatCouldBeReferencedByResource GetSlice(path string) ([]interface{}, error) // GetString returns the value of a string field. diff --git a/api/resid/gvk.go b/api/resid/gvk.go index d8ff6610d..4b5ab0e77 100644 --- a/api/resid/gvk.go +++ b/api/resid/gvk.go @@ -22,8 +22,15 @@ func FromKind(k string) Gvk { } } -// GvkFromString makes a Gvk with a string, -// which is constructed by String() function +// ParseGroupVersion parses a KRM metadata apiVersion field. +func ParseGroupVersion(apiVersion string) (group, version string) { + if i := strings.Index(apiVersion, "/"); i > -1 { + return apiVersion[:i], apiVersion[i+1:] + } + return "", apiVersion +} + +// GvkFromString makes a Gvk from the output of Gvk.String(). func GvkFromString(s string) Gvk { values := strings.Split(s, fieldSep) g := values[0] diff --git a/api/resid/gvk_test.go b/api/resid/gvk_test.go index 440109d9e..5ef2bf6dc 100644 --- a/api/resid/gvk_test.go +++ b/api/resid/gvk_test.go @@ -113,6 +113,30 @@ func TestString(t *testing.T) { } } +func TestParseGroupVersion(t *testing.T) { + tests := []struct { + input string + g string + v string + }{ + {input: "", g: "", v: ""}, + {input: "v1", g: "", v: "v1"}, + {input: "apps/v1", g: "apps", v: "v1"}, + {input: "/v1", g: "", v: "v1"}, + {input: "apps/", g: "apps", v: ""}, + {input: "/apps/", g: "", v: "apps/"}, + } + for _, tc := range tests { + g, v := ParseGroupVersion(tc.input) + if g != tc.g { + t.Errorf("%s: expected group '%s', got '%s'", tc.input, tc.g, g) + } + if v != tc.v { + t.Errorf("%s: expected version '%s', got '%s'", tc.input, tc.v, v) + } + } +} + func TestSelectByGVK(t *testing.T) { type testCase struct { description string diff --git a/api/resource/resource.go b/api/resource/resource.go index 109276c72..61a2aee8c 100644 --- a/api/resource/resource.go +++ b/api/resource/resource.go @@ -14,55 +14,9 @@ import ( "sigs.k8s.io/yaml" ) -// Resource is a representation of a Kubernetes Resource Model object paired -// with metadata used by kustomize. -// -// At time of writing Resource is changing from being based on an object -// sitting behind -// -// sigs.k8s.io/kustomize/api/ifc.Unstructured -// -// to being based on an instance of -// -// sigs.k8s.io/kustomize/kyaml/yaml.RNode -// -// Ultimately, use of the Resource struct in kustomize should be entirely -// replaced by instances of RNode for direct use in kyaml, with all metadata -// stored directly in the RNodes as short-lived annotations, to be deleted -// before final output as part of a final filtration step. Using annotations -// will allow pipelined KRM Config Functions to share metadata that would -// otherwise be hidden in kustomize-only structures. -// -// ifc.Unstructured is an interface hiding an instance of -// sigs.k8s.io/kustomize/api/k8sdeps/kunstruct.UnstructAdapter -// which in turn adapts an instance of -// k8s.io/apimachinery/pkg/apis/meta/v1/unstructured -// to the ifc.Unstructured interface. This latter code handles -// mutations in the old code. -// -// The rule in kustomize development has been -// api/ -// k8sdeps/ ifc/ krusty/ theRest/ -// -// 1) Depend on k8s.io/ only via sigs.k8s.io/kustomize/api/k8sdeps. -// -// 2) Instances created in k8sdeps/ can only be injected into theRest/ -// behind interfaces defined in ifc/, arranged by a small bit of code -// in krusty/. Nothing in theRest/ can import k8sdeps/. -// -// This was to allow for importing kustomize code into kubectl, which also -// depends on k8s.io/apimachinery, albeit via a strange, old arrangement -// predating Go modules. The idea was to copy the k8sdeps/ tree into kubectl -// via a large PR, and depend on the rest via vendoring (and a small copy of -// krusty/ code). Over 2019, however, kubectl underwent large code changes -// including a switch to Go modules, and an attempt to extract it from the -// k8s repo, and this made large kustomize integration PRs hard to get through -// code review. -// -// The new plan is to eliminate k8sdeps/ entirely, along with its k8s.io/ -// dependence, switch to kyaml, and thus allow kustomize to be imported into -// kubectl via normal Go module imports. -// +// Resource is a representation of a Kubernetes Resource Model (KRM) object +// paired with metadata used by kustomize. +// For more history, see sigs.k8s.io/kustomize/api/ifc.Unstructured type Resource struct { kunStr ifc.Kunstructured originalName string @@ -75,7 +29,7 @@ type Resource struct { } func (r *Resource) ResetPrimaryData(incoming *Resource) { - r.kunStr = incoming.kunStr.Copy() + r.kunStr = incoming.Copy() } func (r *Resource) GetAnnotations() map[string]string { @@ -173,7 +127,7 @@ type ResCtxMatcher func(ResCtx) bool // DeepCopy returns a new copy of resource func (r *Resource) DeepCopy() *Resource { rc := &Resource{ - kunStr: r.kunStr.Copy(), + kunStr: r.Copy(), } rc.copyOtherFields(r) return rc @@ -181,11 +135,10 @@ func (r *Resource) DeepCopy() *Resource { // Replace performs replace with other resource. func (r *Resource) Replace(other *Resource) { - r.kunStr.SetLabels(mergeStringMaps(other.kunStr.GetLabels(), r.kunStr.GetLabels())) - r.kunStr.SetAnnotations( - mergeStringMaps(other.kunStr.GetAnnotations(), r.kunStr.GetAnnotations())) - r.kunStr.SetName(other.GetName()) - r.kunStr.SetNamespace(other.GetNamespace()) + r.SetLabels(mergeStringMaps(other.GetLabels(), r.GetLabels())) + r.SetAnnotations(mergeStringMaps(other.GetAnnotations(), r.GetAnnotations())) + r.SetName(other.GetName()) + r.SetNamespace(other.GetNamespace()) r.copyOtherFields(other) } @@ -226,7 +179,7 @@ func (r *Resource) KunstructEqual(o *Resource) bool { // Merge performs merge with other resource. func (r *Resource) Merge(other *Resource) { r.Replace(other) - mergeConfigmap(r.kunStr.Map(), other.Map(), r.Map()) + mergeConfigmap(r.Map(), other.Map(), r.Map()) } func (r *Resource) copyRefBy() []resid.ResId { @@ -352,7 +305,7 @@ func (r *Resource) setOriginalNs(n string) *Resource { // String returns resource as JSON. func (r *Resource) String() string { - bs, err := r.kunStr.MarshalJSON() + bs, err := r.MarshalJSON() if err != nil { return "<" + err.Error() + ">" } @@ -362,7 +315,7 @@ func (r *Resource) String() string { // AsYAML returns the resource in Yaml form. // Easier to read than JSON. func (r *Resource) AsYAML() ([]byte, error) { - json, err := r.kunStr.MarshalJSON() + json, err := r.MarshalJSON() if err != nil { return nil, err } @@ -387,7 +340,7 @@ func (r *Resource) NeedHashSuffix() bool { // GetNamespace returns the namespace the resource thinks it's in. func (r *Resource) GetNamespace() string { - namespace, _ := r.kunStr.GetString("metadata.namespace") + namespace, _ := r.GetString("metadata.namespace") // if err, namespace is empty, so no need to check. return namespace } @@ -397,7 +350,7 @@ func (r *Resource) GetNamespace() string { // TODO: compute this once and save it in the resource. func (r *Resource) OrgId() resid.ResId { return resid.NewResIdWithNamespace( - r.kunStr.GetGvk(), r.GetOriginalName(), r.GetOriginalNs()) + r.GetGvk(), r.GetOriginalName(), r.GetOriginalNs()) } // CurId returns a ResId for the resource using the @@ -405,7 +358,7 @@ func (r *Resource) OrgId() resid.ResId { // This should be unique in any ResMap. func (r *Resource) CurId() resid.ResId { return resid.NewResIdWithNamespace( - r.kunStr.GetGvk(), r.kunStr.GetName(), r.GetNamespace()) + r.GetGvk(), r.GetName(), r.GetNamespace()) } // GetRefBy returns the ResIds that referred to current resource diff --git a/cmd/config/go.sum b/cmd/config/go.sum index 2eefbef24..712cb5346 100644 --- a/cmd/config/go.sum +++ b/cmd/config/go.sum @@ -615,8 +615,6 @@ modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= -sigs.k8s.io/cli-utils v0.18.0 h1:PPFUhhwKsdMiYYm1DY9lZursNWSAEj8FYgMCZKVvOkQ= -sigs.k8s.io/cli-utils v0.18.0/go.mod h1:B7KdqkSkHNIUn3cFbaR4aKUZMKtr+Benboi1w/HW/Fg= sigs.k8s.io/cli-utils v0.19.0 h1:lAoR5okhSV/dIusodaQp5VbDpHMcKnvjqKYHU+AB3a4= sigs.k8s.io/cli-utils v0.19.0/go.mod h1:B7KdqkSkHNIUn3cFbaR4aKUZMKtr+Benboi1w/HW/Fg= sigs.k8s.io/controller-runtime v0.4.0 h1:wATM6/m+3w8lj8FXNaO6Fs/rq/vqoOjO1Q116Z9NPsg= diff --git a/kustomize/go.sum b/kustomize/go.sum index f5b591a41..849400f19 100644 --- a/kustomize/go.sum +++ b/kustomize/go.sum @@ -742,8 +742,8 @@ modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/cli-utils v0.18.0 h1:PPFUhhwKsdMiYYm1DY9lZursNWSAEj8FYgMCZKVvOkQ= -sigs.k8s.io/cli-utils v0.18.0/go.mod h1:B7KdqkSkHNIUn3cFbaR4aKUZMKtr+Benboi1w/HW/Fg= +sigs.k8s.io/cli-utils v0.19.0 h1:lAoR5okhSV/dIusodaQp5VbDpHMcKnvjqKYHU+AB3a4= +sigs.k8s.io/cli-utils v0.19.0/go.mod h1:B7KdqkSkHNIUn3cFbaR4aKUZMKtr+Benboi1w/HW/Fg= sigs.k8s.io/controller-runtime v0.4.0 h1:wATM6/m+3w8lj8FXNaO6Fs/rq/vqoOjO1Q116Z9NPsg= sigs.k8s.io/controller-runtime v0.4.0/go.mod h1:ApC79lpY3PHW9xj/w9pj+lYkLgwAAUZwfXkME1Lajns= sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= From 24beeb429db22003debf9b82a1f1094c4f625fda Mon Sep 17 00:00:00 2001 From: jregan Date: Fri, 21 Aug 2020 17:58:26 -0700 Subject: [PATCH 11/23] RNode copier --- kyaml/yaml/rnode.go | 10 ++++++++ kyaml/yaml/rnode_test.go | 28 ++++++++++++++++++++++ kyaml/yaml/types.go | 17 ++++++++++++++ kyaml/yaml/types_test.go | 51 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+) diff --git a/kyaml/yaml/rnode.go b/kyaml/yaml/rnode.go index 6cefce016..982b452c4 100644 --- a/kyaml/yaml/rnode.go +++ b/kyaml/yaml/rnode.go @@ -168,6 +168,16 @@ type RNode struct { Match []string } +// Copy returns a distinct copy. +func (rn *RNode) Copy() *RNode { + if rn == nil { + return nil + } + result := *rn + result.value = CopyYNode(rn.value) + return &result +} + var ErrMissingMetadata = fmt.Errorf("missing Resource metadata") // Field names diff --git a/kyaml/yaml/rnode_test.go b/kyaml/yaml/rnode_test.go index ab4037ee6..295e180f7 100644 --- a/kyaml/yaml/rnode_test.go +++ b/kyaml/yaml/rnode_test.go @@ -4,6 +4,7 @@ package yaml import ( + "reflect" "strings" "testing" @@ -206,6 +207,33 @@ func TestIsMissingOrNull(t *testing.T) { } } +func TestCopy(t *testing.T) { + rn := RNode{ + fieldPath: []string{"fp1", "fp2"}, + value: &Node{ + Kind: 200, + }, + Match: []string{"m1", "m2"}, + } + rnC := rn.Copy() + if !reflect.DeepEqual(&rn, rnC) { + t.Fatalf("copy %v is not deep equal to %v", rnC, rn) + } + tmp := rn.value.Kind + rn.value.Kind = 666 + if reflect.DeepEqual(rn, rnC) { + t.Fatalf("changing component should break equality") + } + rn.value.Kind = tmp + if !reflect.DeepEqual(&rn, rnC) { + t.Fatalf("should be back to normal") + } + rn.fieldPath[0] = "Different" + if reflect.DeepEqual(rn, rnC) { + t.Fatalf("changing fieldpath should break equality") + } +} + func TestFieldRNodes(t *testing.T) { testCases := []struct { testName string diff --git a/kyaml/yaml/types.go b/kyaml/yaml/types.go index ab233fcba..e39086571 100644 --- a/kyaml/yaml/types.go +++ b/kyaml/yaml/types.go @@ -12,6 +12,23 @@ import ( "sigs.k8s.io/kustomize/kyaml/sets" ) +// CopyYNode returns a distinct copy of its argument. +// Use https://github.com/jinzhu/copier instead? +func CopyYNode(n *yaml.Node) *yaml.Node { + if n == nil { + return nil + } + c := *n + if len(n.Content) > 0 { + // Using Go 'copy' here doesn't yield independent slices. + c.Content = make([]*Node, len(n.Content)) + for i, item := range n.Content { + c.Content[i] = CopyYNode(item) + } + } + return &c +} + // IsYNodeTaggedNull returns true if the node is explicitly tagged Null. func IsYNodeTaggedNull(n *yaml.Node) bool { return n != nil && n.Tag == NodeTagNull diff --git a/kyaml/yaml/types_test.go b/kyaml/yaml/types_test.go index 8358fcd46..7182cac86 100644 --- a/kyaml/yaml/types_test.go +++ b/kyaml/yaml/types_test.go @@ -4,9 +4,60 @@ package yaml import ( + "reflect" "testing" ) +func TestCopyYNode(t *testing.T) { + ynSub1 := Node{ + Kind: 100, + } + ynSub2 := Node{ + Kind: 200, + } + ynSub3 := Node{ + Kind: 300, + } + yn := Node{ + Kind: 5000, + Style: 6000, + Tag: "red", + Value: "green", + Anchor: "blue", + Alias: &ynSub3, + Content: []*Node{&ynSub1, &ynSub2}, + HeadComment: "apple", + LineComment: "peach", + FootComment: "banana", + Line: 7000, + Column: 8000, + } + ynAddr := &yn + if !reflect.DeepEqual(&yn, ynAddr) { + t.Fatalf("truly %v should equal %v", &yn, ynAddr) + } + ynC := CopyYNode(&yn) + if !reflect.DeepEqual(yn.Content, ynC.Content) { + t.Fatalf("copy content %v is not deep equal to %v", ynC, yn) + } + if !reflect.DeepEqual(&yn, ynC) { + t.Fatalf("\noriginal: %v\n copy: %v\nShould be equal.", yn, ynC) + } + tmp := yn.Content[0].Kind + yn.Content[0].Kind = 666 + if reflect.DeepEqual(&yn, ynC) { + t.Fatalf("changing component should break equality") + } + yn.Content[0].Kind = tmp + if !reflect.DeepEqual(&yn, ynC) { + t.Fatalf("should be okay now") + } + yn.Tag = "Different" + if yn.Tag == ynC.Tag { + t.Fatalf("field aliased!") + } +} + func TestIsYNodeTaggedNull(t *testing.T) { if IsYNodeTaggedNull(nil) { t.Fatalf("nil cannot be tagged null") From 1d914017728194543593b714794d82bda872f944 Mon Sep 17 00:00:00 2001 From: jregan Date: Sat, 22 Aug 2020 06:40:59 -0700 Subject: [PATCH 12/23] Simplify use of the Merginator. --- .../PatchStrategicMergeTransformer.go | 2 +- .../merginator.go} | 50 +++++++++++++------ api/internal/k8sdeps/transformer/factory.go | 25 ---------- api/internal/plugins/fnplugin/fnplugin.go | 4 +- api/internal/target/kusttarget.go | 6 +-- api/internal/target/maker_test.go | 10 ++-- api/krusty/kustomizer.go | 21 ++++---- api/loader/fileloader.go | 4 +- api/loader/loader.go | 4 +- api/resmap/factory.go | 18 ++++--- api/resmap/merginator.go | 13 +++++ api/resmap/patchfactory.go | 15 ------ api/testutils/kusttest/harnessenhanced.go | 15 +++--- api/types/kustomization_test.go | 8 +-- .../PatchStrategicMergeTransformer.go | 2 +- releasing/releasing/gitrunner.go | 6 +-- releasing/releasing/moduleversion.go | 6 +-- 17 files changed, 104 insertions(+), 105 deletions(-) rename api/internal/k8sdeps/{transformer/patch/conflictdetector.go => merge/merginator.go} (79%) delete mode 100644 api/internal/k8sdeps/transformer/factory.go create mode 100644 api/resmap/merginator.go delete mode 100644 api/resmap/patchfactory.go diff --git a/api/builtins/PatchStrategicMergeTransformer.go b/api/builtins/PatchStrategicMergeTransformer.go index e7636a71e..fe2693aed 100644 --- a/api/builtins/PatchStrategicMergeTransformer.go +++ b/api/builtins/PatchStrategicMergeTransformer.go @@ -64,7 +64,7 @@ func (p *PatchStrategicMergeTransformerPlugin) Config( } func (p *PatchStrategicMergeTransformerPlugin) Transform(m resmap.ResMap) error { - patches, err := p.h.ResmapFactory().MergePatches(p.loadedPatches) + patches, err := p.h.ResmapFactory().Merge(p.loadedPatches) if err != nil { return err } diff --git a/api/internal/k8sdeps/transformer/patch/conflictdetector.go b/api/internal/k8sdeps/merge/merginator.go similarity index 79% rename from api/internal/k8sdeps/transformer/patch/conflictdetector.go rename to api/internal/k8sdeps/merge/merginator.go index 6c79794d5..627908f23 100644 --- a/api/internal/k8sdeps/transformer/patch/conflictdetector.go +++ b/api/internal/k8sdeps/merge/merginator.go @@ -1,7 +1,7 @@ // Copyright 2019 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0 -package patch +package merge import ( "encoding/json" @@ -20,18 +20,20 @@ import ( type conflictDetector interface { hasConflict(patch1, patch2 *resource.Resource) (bool, error) - findConflict(conflictingPatchIdx int, patches []*resource.Resource) (*resource.Resource, error) + findConflict( + conflictingPatchIdx int, + patches []*resource.Resource) (*resource.Resource, error) mergePatches(patch1, patch2 *resource.Resource) (*resource.Resource, error) } type jsonMergePatch struct { - rf *resource.Factory + resourceFactory *resource.Factory } var _ conflictDetector = &jsonMergePatch{} func newJMPConflictDetector(rf *resource.Factory) conflictDetector { - return &jsonMergePatch{rf: rf} + return &jsonMergePatch{resourceFactory: rf} } func (jmp *jsonMergePatch) hasConflict( @@ -40,7 +42,8 @@ func (jmp *jsonMergePatch) hasConflict( } func (jmp *jsonMergePatch) findConflict( - conflictingPatchIdx int, patches []*resource.Resource) (*resource.Resource, error) { + conflictingPatchIdx int, + patches []*resource.Resource) (*resource.Resource, error) { for i, patch := range patches { if i == conflictingPatchIdx { continue @@ -77,7 +80,7 @@ func (jmp *jsonMergePatch) mergePatches( } mergedMap := make(map[string]interface{}) err = json.Unmarshal(mergedBytes, &mergedMap) - return jmp.rf.FromMap(mergedMap), err + return jmp.resourceFactory.FromMap(mergedMap), err } type strategicMergePatch struct { @@ -94,13 +97,15 @@ func newSMPConflictDetector( return &strategicMergePatch{lookupPatchMeta: lookupPatchMeta, rf: rf}, err } -func (smp *strategicMergePatch) hasConflict(p1, p2 *resource.Resource) (bool, error) { +func (smp *strategicMergePatch) hasConflict( + p1, p2 *resource.Resource) (bool, error) { return strategicpatch.MergingMapsHaveConflicts( p1.Map(), p2.Map(), smp.lookupPatchMeta) } func (smp *strategicMergePatch) findConflict( - conflictingPatchIdx int, patches []*resource.Resource) (*resource.Resource, error) { + conflictingPatchIdx int, + patches []*resource.Resource) (*resource.Resource, error) { for i, patch := range patches { if i == conflictingPatchIdx { continue @@ -122,10 +127,12 @@ func (smp *strategicMergePatch) findConflict( return nil, nil } -func (smp *strategicMergePatch) mergePatches(patch1, patch2 *resource.Resource) (*resource.Resource, error) { +func (smp *strategicMergePatch) mergePatches( + patch1, patch2 *resource.Resource) (*resource.Resource, error) { if hasDeleteDirectiveMarker(patch2.Map()) { if hasDeleteDirectiveMarker(patch1.Map()) { - return nil, fmt.Errorf("cannot merge patches both containing '$patch: delete' directives") + return nil, fmt.Errorf( + "cannot merge patches both containing '$patch: delete' directives") } patch1, patch2 = patch2, patch1 } @@ -134,10 +141,21 @@ func (smp *strategicMergePatch) mergePatches(patch1, patch2 *resource.Resource) return smp.rf.FromMap(mergeJSONMap), err } -// MergePatches merge and index patches by OrgId. -// It errors out if there is conflict between patches. -func MergePatches(patches []*resource.Resource, - rf *resource.Factory) (resmap.ResMap, error) { +type merginatorImpl struct { + rf *resource.Factory +} + +// NewMerginator returns a new implementation of resmap.Merginator. +func NewMerginator(rf *resource.Factory) resmap.Merginator { + return &merginatorImpl{rf: rf} +} + +var _ resmap.Merginator = (*merginatorImpl)(nil) + +// Merge merges the incoming resources into a new resmap.ResMap. +// Returns an error on conflict. +func (m *merginatorImpl) Merge( + patches []*resource.Resource) (resmap.ResMap, error) { rc := resmap.New() for ix, patch := range patches { id := patch.OrgId() @@ -156,9 +174,9 @@ func MergePatches(patches []*resource.Resource, } var cd conflictDetector if err != nil { - cd = newJMPConflictDetector(rf) + cd = newJMPConflictDetector(m.rf) } else { - cd, err = newSMPConflictDetector(versionedObj, rf) + cd, err = newSMPConflictDetector(versionedObj, m.rf) if err != nil { return nil, err } diff --git a/api/internal/k8sdeps/transformer/factory.go b/api/internal/k8sdeps/transformer/factory.go deleted file mode 100644 index 622c4a6cf..000000000 --- a/api/internal/k8sdeps/transformer/factory.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2019 The Kubernetes Authors. -// SPDX-License-Identifier: Apache-2.0 - -// Package transformer provides transformer factory -package transformer - -import ( - "sigs.k8s.io/kustomize/api/internal/k8sdeps/transformer/patch" - "sigs.k8s.io/kustomize/api/resmap" - "sigs.k8s.io/kustomize/api/resource" -) - -// FactoryImpl makes patch transformer and name hash transformer -type FactoryImpl struct{} - -// NewFactoryImpl makes a new factoryImpl instance -func NewFactoryImpl() *FactoryImpl { - return &FactoryImpl{} -} - -func (p *FactoryImpl) MergePatches(patches []*resource.Resource, - rf *resource.Factory) ( - resmap.ResMap, error) { - return patch.MergePatches(patches, rf) -} diff --git a/api/internal/plugins/fnplugin/fnplugin.go b/api/internal/plugins/fnplugin/fnplugin.go index 72dbf4271..3d0ad10dd 100644 --- a/api/internal/plugins/fnplugin/fnplugin.go +++ b/api/internal/plugins/fnplugin/fnplugin.go @@ -173,11 +173,11 @@ func (p *FnPlugin) invokePlugin(input []byte) ([]byte, error) { // TODO(donnyxia): This is actually not used by generator and only used to bypass a kio limitation. // Need better solution. if input == nil { - yaml, err := functionConfig.String() + yml, err := functionConfig.String() if err != nil { return nil, err } - input = []byte(yaml) + input = []byte(yml) } // Configure and Execute Fn. We don't need to convert resources to ResourceList here diff --git a/api/internal/target/kusttarget.go b/api/internal/target/kusttarget.go index c8a60a80a..d5d1626c9 100644 --- a/api/internal/target/kusttarget.go +++ b/api/internal/target/kusttarget.go @@ -27,7 +27,6 @@ type KustTarget struct { ldr ifc.Loader validator ifc.Validator rFactory *resmap.Factory - tFactory resmap.PatchFactory pLdr *loader.Loader } @@ -36,13 +35,11 @@ func NewKustTarget( ldr ifc.Loader, validator ifc.Validator, rFactory *resmap.Factory, - tFactory resmap.PatchFactory, pLdr *loader.Loader) *KustTarget { return &KustTarget{ ldr: ldr, validator: validator, rFactory: rFactory, - tFactory: tFactory, pLdr: pLdr, } } @@ -350,8 +347,7 @@ func (kt *KustTarget) accumulateComponents( func (kt *KustTarget) accumulateDirectory( ra *accumulator.ResAccumulator, ldr ifc.Loader, isComponent bool) (*accumulator.ResAccumulator, error) { defer ldr.Cleanup() - subKt := NewKustTarget( - ldr, kt.validator, kt.rFactory, kt.tFactory, kt.pLdr) + subKt := NewKustTarget(ldr, kt.validator, kt.rFactory, kt.pLdr) err := subKt.Load() if err != nil { return nil, errors.Wrapf( diff --git a/api/internal/target/maker_test.go b/api/internal/target/maker_test.go index 461ba4f8f..7e85832df 100644 --- a/api/internal/target/maker_test.go +++ b/api/internal/target/maker_test.go @@ -7,7 +7,7 @@ import ( "testing" "sigs.k8s.io/kustomize/api/filesys" - "sigs.k8s.io/kustomize/api/internal/k8sdeps/transformer" + "sigs.k8s.io/kustomize/api/internal/k8sdeps/merge" pLdr "sigs.k8s.io/kustomize/api/internal/plugins/loader" "sigs.k8s.io/kustomize/api/internal/target" "sigs.k8s.io/kustomize/api/k8sdeps/kunstruct" @@ -35,17 +35,17 @@ func makeKustTargetWithRf( t *testing.T, fSys filesys.FileSystem, root string, - resFact *resource.Factory) *target.KustTarget { - rf := resmap.NewFactory(resFact, transformer.NewFactoryImpl()) - pc := konfig.DisabledPluginConfig() + resourceFactory *resource.Factory) *target.KustTarget { ldr, err := fLdr.NewLoader(fLdr.RestrictionRootOnly, root, fSys) if err != nil { t.Fatal(err) } + rf := resmap.NewFactory( + resourceFactory, merge.NewMerginator(resourceFactory)) + pc := konfig.DisabledPluginConfig() return target.NewKustTarget( ldr, valtest_test.MakeFakeValidator(), rf, - transformer.NewFactoryImpl(), pLdr.NewLoader(pc, rf)) } diff --git a/api/krusty/kustomizer.go b/api/krusty/kustomizer.go index 12671f5de..07fbc9145 100644 --- a/api/krusty/kustomizer.go +++ b/api/krusty/kustomizer.go @@ -8,7 +8,7 @@ import ( "sigs.k8s.io/kustomize/api/builtins" "sigs.k8s.io/kustomize/api/filesys" - "sigs.k8s.io/kustomize/api/internal/k8sdeps/transformer" + "sigs.k8s.io/kustomize/api/internal/k8sdeps/merge" pLdr "sigs.k8s.io/kustomize/api/internal/plugins/loader" "sigs.k8s.io/kustomize/api/internal/target" "sigs.k8s.io/kustomize/api/k8sdeps/kunstruct" @@ -49,11 +49,11 @@ func MakeKustomizer(fSys filesys.FileSystem, o *Options) *Kustomizer { // on any number of internal paths (e.g. the filesystem may contain // multiple overlays, and Run can be called on each of them). func (b *Kustomizer) Run(path string) (resmap.ResMap, error) { - pf := transformer.NewFactoryImpl() - rf := resmap.NewFactory( - resource.NewFactory( - kunstruct.NewKunstructuredFactoryImpl()), - pf) + resourceFactory := resource.NewFactory( + kunstruct.NewKunstructuredFactoryImpl()) + resmapFactory := resmap.NewFactory( + resourceFactory, + merge.NewMerginator(resourceFactory)) lr := fLdr.RestrictionNone if b.options.LoadRestrictions == types.LoadRestrictionsRootOnly { lr = fLdr.RestrictionRootOnly @@ -66,9 +66,8 @@ func (b *Kustomizer) Run(path string) (resmap.ResMap, error) { kt := target.NewKustTarget( ldr, validator.NewKustValidator(), - rf, - pf, - pLdr.NewLoader(b.options.PluginConfig, rf), + resmapFactory, + pLdr.NewLoader(b.options.PluginConfig, resmapFactory), ) err = kt.Load() if err != nil { @@ -84,7 +83,9 @@ func (b *Kustomizer) Run(path string) (resmap.ResMap, error) { } if b.options.AddManagedbyLabel { t := builtins.LabelTransformerPlugin{ - Labels: map[string]string{konfig.ManagedbyLabelKey: fmt.Sprintf("kustomize-%s", provenance.GetProvenance().Version)}, + Labels: map[string]string{ + konfig.ManagedbyLabelKey: fmt.Sprintf( + "kustomize-%s", provenance.GetProvenance().Version)}, FieldSpecs: []types.FieldSpec{{ Path: "metadata/labels", CreateIfNotPresent: true, diff --git a/api/loader/fileloader.go b/api/loader/fileloader.go index 8e5b3113a..2d8e126da 100644 --- a/api/loader/fileloader.go +++ b/api/loader/fileloader.go @@ -199,7 +199,9 @@ func (fl *fileLoader) New(path string) (ifc.Loader, error) { } root, errDir := demandDirectoryRoot(fl.fSys, fl.root.Join(path)) if errDir != nil { - return nil, fmt.Errorf("Error loading %s with git: %v, dir: %v, get: %v", path, errGit, errDir, errGet) + return nil, fmt.Errorf( + "error loading %s with git: %v, dir: %v, get: %v", + path, errGit, errDir, errGet) } if errDir := fl.errIfGitContainmentViolation(root); errDir != nil { return nil, errDir diff --git a/api/loader/loader.go b/api/loader/loader.go index daab26943..7c9255477 100644 --- a/api/loader/loader.go +++ b/api/loader/loader.go @@ -39,5 +39,7 @@ func NewLoader( return newLoaderAtConfirmedDir(lr, root, fSys, nil, git.ClonerUsingGitExec, getRemoteTarget), nil } - return nil, fmt.Errorf("Error creating new loader with git: %v, dir: %v, get: %v", errGit, errDir, errGet) + return nil, fmt.Errorf( + "error creating new loader with git: %v, dir: %v, get: %v", + errGit, errDir, errGet) } diff --git a/api/resmap/factory.go b/api/resmap/factory.go index 90ee58c37..37a05ab6d 100644 --- a/api/resmap/factory.go +++ b/api/resmap/factory.go @@ -14,12 +14,12 @@ import ( // Factory makes instances of ResMap. type Factory struct { resF *resource.Factory - tf PatchFactory + pm Merginator } // NewFactory returns a new resmap.Factory. -func NewFactory(rf *resource.Factory, tf PatchFactory) *Factory { - return &Factory{resF: rf, tf: tf} +func NewFactory(rf *resource.Factory, pm Merginator) *Factory { + return &Factory{resF: rf, pm: pm} } // RF returns a resource.Factory. @@ -87,6 +87,7 @@ func (rmF *Factory) NewResMapFromConfigMapArgs( return newResMapFromResourceSlice(resources) } +// FromConfigMapArgs creates a new ResMap containing one ConfigMap. func (rmF *Factory) FromConfigMapArgs( kvLdr ifc.KvLoader, args types.ConfigMapArgs) (ResMap, error) { res, err := rmF.resF.MakeConfigMap(kvLdr, &args) @@ -111,6 +112,7 @@ func (rmF *Factory) NewResMapFromSecretArgs( return newResMapFromResourceSlice(resources) } +// FromSecretArgs creates a new ResMap containing one secret. func (rmF *Factory) FromSecretArgs( kvLdr ifc.KvLoader, args types.SecretArgs) (ResMap, error) { res, err := rmF.resF.MakeSecret(kvLdr, &args) @@ -120,12 +122,14 @@ func (rmF *Factory) FromSecretArgs( return rmF.FromResource(res), nil } -func (rmF *Factory) MergePatches(patches []*resource.Resource) ( - ResMap, error) { - return rmF.tf.MergePatches(patches, rmF.resF) +// Merge creates a new ResMap by merging incoming resources. +// Error if conflict found. +func (rmF *Factory) Merge(patches []*resource.Resource) (ResMap, error) { + return rmF.pm.Merge(patches) } -func newResMapFromResourceSlice(resources []*resource.Resource) (ResMap, error) { +func newResMapFromResourceSlice( + resources []*resource.Resource) (ResMap, error) { result := New() for _, res := range resources { err := result.Append(res) diff --git a/api/resmap/merginator.go b/api/resmap/merginator.go new file mode 100644 index 000000000..10d7377c5 --- /dev/null +++ b/api/resmap/merginator.go @@ -0,0 +1,13 @@ +// Copyright 2019 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package resmap + +import "sigs.k8s.io/kustomize/api/resource" + +// Merginator merges resources. +type Merginator interface { + // Merge creates a new ResMap by merging incoming resources. + // Error if conflict found. + Merge([]*resource.Resource) (ResMap, error) +} diff --git a/api/resmap/patchfactory.go b/api/resmap/patchfactory.go deleted file mode 100644 index 9af1ac045..000000000 --- a/api/resmap/patchfactory.go +++ /dev/null @@ -1,15 +0,0 @@ -/// Copyright 2019 The Kubernetes Authors. -// SPDX-License-Identifier: Apache-2.0 - -// Package patch holds miscellaneous interfaces used by kustomize. -package resmap - -import ( - "sigs.k8s.io/kustomize/api/resource" -) - -// PatchFactory makes transformers that require k8sdeps. -type PatchFactory interface { - MergePatches(patches []*resource.Resource, - rf *resource.Factory) (ResMap, error) -} diff --git a/api/testutils/kusttest/harnessenhanced.go b/api/testutils/kusttest/harnessenhanced.go index f40320b0f..405af5230 100644 --- a/api/testutils/kusttest/harnessenhanced.go +++ b/api/testutils/kusttest/harnessenhanced.go @@ -8,7 +8,7 @@ import ( "sigs.k8s.io/kustomize/api/filesys" "sigs.k8s.io/kustomize/api/ifc" - "sigs.k8s.io/kustomize/api/internal/k8sdeps/transformer" + "sigs.k8s.io/kustomize/api/internal/k8sdeps/merge" pLdr "sigs.k8s.io/kustomize/api/internal/plugins/loader" "sigs.k8s.io/kustomize/api/k8sdeps/kunstruct" "sigs.k8s.io/kustomize/api/konfig" @@ -46,16 +46,17 @@ func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced { if err != nil { t.Fatal(err) } - - rf := resmap.NewFactory( - resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()), - transformer.NewFactoryImpl()) + resourceFactory := resource.NewFactory( + kunstruct.NewKunstructuredFactoryImpl()) + resmapFactory := resmap.NewFactory( + resourceFactory, + merge.NewMerginator(resourceFactory)) result := &HarnessEnhanced{ Harness: MakeHarness(t), pte: pte, - rf: rf, - pl: pLdr.NewLoader(pc, rf)} + rf: resmapFactory, + pl: pLdr.NewLoader(pc, resmapFactory)} // Point the file loader to the root ('/') of the in-memory file system. result.ResetLoaderRoot(filesys.Separator) diff --git a/api/types/kustomization_test.go b/api/types/kustomization_test.go index 57373ee5b..0533fa432 100644 --- a/api/types/kustomization_test.go +++ b/api/types/kustomization_test.go @@ -5,9 +5,11 @@ import ( ) func fixKustomizationPostUnmarshallingCheck(k, e *Kustomization) bool { - return (k.Kind == e.Kind && k.APIVersion == e.APIVersion && - len(k.Resources) == len(e.Resources) && k.Resources[0] == e.Resources[0] && - k.Bases == nil) + return k.Kind == e.Kind && + k.APIVersion == e.APIVersion && + len(k.Resources) == len(e.Resources) && + k.Resources[0] == e.Resources[0] && + k.Bases == nil } func TestFixKustomizationPostUnmarshalling(t *testing.T) { diff --git a/plugin/builtin/patchstrategicmergetransformer/PatchStrategicMergeTransformer.go b/plugin/builtin/patchstrategicmergetransformer/PatchStrategicMergeTransformer.go index 4f61f031d..c8b36eff4 100644 --- a/plugin/builtin/patchstrategicmergetransformer/PatchStrategicMergeTransformer.go +++ b/plugin/builtin/patchstrategicmergetransformer/PatchStrategicMergeTransformer.go @@ -68,7 +68,7 @@ func (p *plugin) Config( } func (p *plugin) Transform(m resmap.ResMap) error { - patches, err := p.h.ResmapFactory().MergePatches(p.loadedPatches) + patches, err := p.h.ResmapFactory().Merge(p.loadedPatches) if err != nil { return err } diff --git a/releasing/releasing/gitrunner.go b/releasing/releasing/gitrunner.go index 78033acd7..2d2bc956e 100644 --- a/releasing/releasing/gitrunner.go +++ b/releasing/releasing/gitrunner.go @@ -63,14 +63,14 @@ func (gr *gitRunner) DeleteWorktreeDir() error { func (gr *gitRunner) WorktreePath() (string, error) { if gr.worktreePath == "" { - return "", fmt.Errorf("Empty worktree path") + return "", fmt.Errorf("empty worktree path") } return gr.worktreePath, nil } func (gr *gitRunner) OriginalGitPath() (string, error) { if gr.originalGitPath == "" { - return "", fmt.Errorf("Empty git path") + return "", fmt.Errorf("empty git path") } return gr.originalGitPath, nil } @@ -107,7 +107,7 @@ func (gr *gitRunner) CheckRemoteExistence(remote string) error { regString := fmt.Sprintf("(?m)^\\s*%s\\s*$", remote) reg := regexp.MustCompile(regString) if !reg.MatchString(string(stdoutStderr)) { - return fmt.Errorf("Cannot find remote named %s", remote) + return fmt.Errorf("cannot find remote named %s", remote) } logDebug("Remote %s exists", remote) return nil diff --git a/releasing/releasing/moduleversion.go b/releasing/releasing/moduleversion.go index 5370262ad..af4a5ecab 100644 --- a/releasing/releasing/moduleversion.go +++ b/releasing/releasing/moduleversion.go @@ -29,7 +29,7 @@ func (v *moduleVersion) Bump(t string) error { } else if t == "patch" { v.patch++ } else { - return fmt.Errorf("Invalid version type: %s", t) + return fmt.Errorf("invalid version type: %s", t) } return nil } @@ -37,14 +37,14 @@ func (v *moduleVersion) Bump(t string) error { func newModuleVersionFromString(vs string) (moduleVersion, error) { v := moduleVersion{} if len(vs) < 1 { - return v, fmt.Errorf("Invalid version string %s", vs) + return v, fmt.Errorf("invalid version string %s", vs) } if vs[0] == 'v' { vs = vs[1:] } versions := strings.Split(vs, ".") if len(versions) != 3 { - return v, fmt.Errorf("Invalid version string %s", vs) + return v, fmt.Errorf("invalid version string %s", vs) } major, err := strconv.Atoi(versions[0]) if err != nil { From 40dc90b3b1a30653ec4ecf18b22b80149db47a85 Mon Sep 17 00:00:00 2001 From: Jeff Regan Date: Sat, 22 Aug 2020 17:45:16 -0700 Subject: [PATCH 13/23] Update cloudbuild.sh --- releasing/cloudbuild.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/releasing/cloudbuild.sh b/releasing/cloudbuild.sh index e7aec2e7f..b6e02d2c0 100755 --- a/releasing/cloudbuild.sh +++ b/releasing/cloudbuild.sh @@ -35,10 +35,14 @@ module=${fullTag%/*} echo "module=$module" # Obtain most recent commit hash associated with the module. -lastCommitHash=$(git log --tags=$module -1 --oneline --no-walk --pretty=format:%h) +lastCommitHash=$( + git log --tags=$module -1 --oneline --no-walk --pretty=format:%h) -# Generate the changelog for this release using commit hashes and commit messages. -cl=$(git log $lastCommitHash.. --pretty=oneline --abbrev-commit --no-decorate --no-color -- $module) +# Generate the changelog for this release +# using commit hashes and commit messages. +cl=$( + git log $lastCommitHash.. --pretty=oneline \ + --abbrev-commit --no-decorate --no-color -- $module) # Take everything after the last slash. # This should be something like "v1.2.3". From cc5617c0485cda3888b70aa6e40366cdd78d906c Mon Sep 17 00:00:00 2001 From: Jeffrey Regan Date: Sat, 22 Aug 2020 18:07:09 -0700 Subject: [PATCH 14/23] Tweak cloudbuild.sh release note handling --- releasing/cloudbuild.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/releasing/cloudbuild.sh b/releasing/cloudbuild.sh index b6e02d2c0..ceab40a3b 100755 --- a/releasing/cloudbuild.sh +++ b/releasing/cloudbuild.sh @@ -36,13 +36,16 @@ echo "module=$module" # Obtain most recent commit hash associated with the module. lastCommitHash=$( - git log --tags=$module -1 --oneline --no-walk --pretty=format:%h) + git log --tags=$module -1 \ + --oneline --no-walk --pretty=format:%h) # Generate the changelog for this release # using commit hashes and commit messages. -cl=$( - git log $lastCommitHash.. --pretty=oneline \ - --abbrev-commit --no-decorate --no-color -- $module) +changeLog=$(mktemp) +git log $lastCommitHash.. \ + --pretty=oneline \ + --abbrev-commit --no-decorate --no-color \ + -- $module > $changeLog # Take everything after the last slash. # This should be something like "v1.2.3". @@ -121,4 +124,8 @@ EOF cat $configFile -/bin/goreleaser release --config=$configFile --rm-dist --skip-validate $remainingArgs --release-notes <"$cl" +/bin/goreleaser release \ + --config=$configFile \ + --rm-dist \ + --skip-validate $remainingArgs \ + --release-notes $changeLog From 1dffc7577b22c0c9d140d09839bcb472e25a79ef Mon Sep 17 00:00:00 2001 From: jregan Date: Sat, 22 Aug 2020 17:03:52 -0700 Subject: [PATCH 15/23] Unpin transformers from kyaml. --- api/go.mod | 4 +- api/internal/crawl/go.sum | 5 +- api/k8sdeps/kunstruct/factory.go | 6 +- cmd/config/go.mod | 2 +- .../examples/application-cr/image/go.mod | 2 +- .../examples/application-cr/image/go.sum | 5 +- .../injection-tshirt-sizes/image/go.mod | 2 +- .../injection-tshirt-sizes/image/go.sum | 5 +- .../examples/template-go-nginx/image/go.mod | 2 +- .../examples/template-go-nginx/image/go.sum | 5 +- .../examples/validator-kubeval/image/go.mod | 2 +- .../examples/validator-kubeval/image/go.sum | 5 +- .../validator-resource-requests/image/go.mod | 2 +- .../validator-resource-requests/image/go.sum | 5 +- hack/pinUnpinPluginApiDep.sh | 59 ++++++++++++------- plugin/builtin/annotationstransformer/go.mod | 4 +- plugin/builtin/annotationstransformer/go.sum | 3 +- plugin/builtin/configmapgenerator/go.sum | 5 +- plugin/builtin/hashtransformer/go.sum | 5 +- plugin/builtin/imagetagtransformer/go.mod | 4 +- plugin/builtin/imagetagtransformer/go.sum | 3 +- plugin/builtin/labeltransformer/go.mod | 4 +- plugin/builtin/labeltransformer/go.sum | 3 +- plugin/builtin/legacyordertransformer/go.sum | 5 +- plugin/builtin/namespacetransformer/go.mod | 4 +- plugin/builtin/namespacetransformer/go.sum | 3 +- .../builtin/patchjson6902transformer/go.mod | 4 +- .../builtin/patchjson6902transformer/go.sum | 3 +- .../patchstrategicmergetransformer/go.mod | 4 +- plugin/builtin/patchtransformer/go.mod | 4 +- plugin/builtin/patchtransformer/go.sum | 3 +- plugin/builtin/prefixsuffixtransformer/go.mod | 4 +- plugin/builtin/prefixsuffixtransformer/go.sum | 3 +- plugin/builtin/replicacounttransformer/go.mod | 4 +- plugin/builtin/replicacounttransformer/go.sum | 3 +- plugin/builtin/secretgenerator/go.sum | 5 +- plugin/builtin/valueaddtransformer/go.mod | 4 +- plugin/builtin/valueaddtransformer/go.sum | 3 +- .../v1/bashedconfigmap/go.sum | 5 +- .../v1/chartinflator/go.sum | 5 +- .../v1/dateprefixer/go.sum | 5 +- .../someteam.example.com/v1/gogetter/go.sum | 5 +- .../v1/printpluginenv/go.sum | 5 +- .../v1/replacementtransformer/go.sum | 5 +- .../v1/secretsfromdatabase/go.sum | 5 +- .../v1/sedtransformer/go.sum | 5 +- .../v1/someservicegenerator/go.sum | 5 +- .../v1/stringprefixer/go.sum | 5 +- .../someteam.example.com/v1/validator/go.sum | 5 +- 49 files changed, 151 insertions(+), 102 deletions(-) diff --git a/api/go.mod b/api/go.mod index 33fbd83c1..45ebb6b92 100644 --- a/api/go.mod +++ b/api/go.mod @@ -16,8 +16,8 @@ require ( k8s.io/apimachinery v0.17.0 k8s.io/client-go v0.17.0 k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) -replace sigs.k8s.io/kustomize/kyaml v0.5.0 => ../kyaml +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../kyaml diff --git a/api/internal/crawl/go.sum b/api/internal/crawl/go.sum index 83e59140d..76875dfcb 100644 --- a/api/internal/crawl/go.sum +++ b/api/internal/crawl/go.sum @@ -338,6 +338,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -523,8 +524,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/api/k8sdeps/kunstruct/factory.go b/api/k8sdeps/kunstruct/factory.go index f26f93dd4..cebfa1910 100644 --- a/api/k8sdeps/kunstruct/factory.go +++ b/api/k8sdeps/kunstruct/factory.go @@ -17,7 +17,11 @@ import ( "sigs.k8s.io/kustomize/api/types" ) -// KunstructuredFactoryImpl hides construction using apimachinery types. +// KunstructuredFactoryImpl makes instances of UnstructAdapter. +// These instances in turn adapt structs in +// k8s.io/apimachinery/pkg/apis/meta/v1/unstructured +// to implement ifc.Kunstructured. +// This factory is meant to implement ifc.KunstructuredFactory. type KunstructuredFactoryImpl struct { hasher *kustHash } diff --git a/cmd/config/go.mod b/cmd/config/go.mod index 677eac651..5760028b4 100644 --- a/cmd/config/go.mod +++ b/cmd/config/go.mod @@ -15,7 +15,7 @@ require ( k8s.io/client-go v0.17.3 k8s.io/kubectl v0.0.0-20191219154910-1528d4eea6dd sigs.k8s.io/cli-utils v0.19.0 - sigs.k8s.io/kustomize/kyaml v0.6.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 ) replace sigs.k8s.io/kustomize/kyaml => ../../kyaml diff --git a/functions/examples/application-cr/image/go.mod b/functions/examples/application-cr/image/go.mod index 5887a4da6..fedb72164 100644 --- a/functions/examples/application-cr/image/go.mod +++ b/functions/examples/application-cr/image/go.mod @@ -5,6 +5,6 @@ go 1.14 require ( k8s.io/apimachinery v0.18.3 sigs.k8s.io/application v0.8.2 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) diff --git a/functions/examples/application-cr/image/go.sum b/functions/examples/application-cr/image/go.sum index 70c6555ec..90fbd22a9 100644 --- a/functions/examples/application-cr/image/go.sum +++ b/functions/examples/application-cr/image/go.sum @@ -327,6 +327,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -558,8 +559,8 @@ sigs.k8s.io/application v0.8.2 h1:XB7C33f7eW+1MbCJXoZa0+nP+R+S/VbAvYfCd3ufP1I= sigs.k8s.io/application v0.8.2/go.mod h1:Mv+ht9RE/QNtITYCzRbt3XTIN6t6so6cInmiyg6wOIg= sigs.k8s.io/controller-runtime v0.4.0 h1:wATM6/m+3w8lj8FXNaO6Fs/rq/vqoOjO1Q116Z9NPsg= sigs.k8s.io/controller-runtime v0.4.0/go.mod h1:ApC79lpY3PHW9xj/w9pj+lYkLgwAAUZwfXkME1Lajns= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA= sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06 h1:zD2IemQ4LmOcAumeiyDWXKUI2SO0NYDe3H6QGvPOVgU= diff --git a/functions/examples/injection-tshirt-sizes/image/go.mod b/functions/examples/injection-tshirt-sizes/image/go.mod index 750f0b6a5..79e172cea 100644 --- a/functions/examples/injection-tshirt-sizes/image/go.mod +++ b/functions/examples/injection-tshirt-sizes/image/go.mod @@ -2,4 +2,4 @@ module sigs.k8s.io/kustomize/functions/examples/injection-tshirt-sizes go 1.14 -require sigs.k8s.io/kustomize/kyaml v0.5.0 +require sigs.k8s.io/kustomize/kyaml v0.6.1 diff --git a/functions/examples/injection-tshirt-sizes/image/go.sum b/functions/examples/injection-tshirt-sizes/image/go.sum index a36a83a8f..7d9e085c8 100644 --- a/functions/examples/injection-tshirt-sizes/image/go.sum +++ b/functions/examples/injection-tshirt-sizes/image/go.sum @@ -174,6 +174,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -262,5 +263,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo= gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= diff --git a/functions/examples/template-go-nginx/image/go.mod b/functions/examples/template-go-nginx/image/go.mod index 5285dd911..a9fb0fdc6 100644 --- a/functions/examples/template-go-nginx/image/go.mod +++ b/functions/examples/template-go-nginx/image/go.mod @@ -2,4 +2,4 @@ module sigs.k8s.io/kustomize/functions/examples/template-go-nginx go 1.14 -require sigs.k8s.io/kustomize/kyaml v0.5.0 +require sigs.k8s.io/kustomize/kyaml v0.6.1 diff --git a/functions/examples/template-go-nginx/image/go.sum b/functions/examples/template-go-nginx/image/go.sum index f430623ac..d29da1e84 100644 --- a/functions/examples/template-go-nginx/image/go.sum +++ b/functions/examples/template-go-nginx/image/go.sum @@ -175,6 +175,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -263,5 +264,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo= gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= diff --git a/functions/examples/validator-kubeval/image/go.mod b/functions/examples/validator-kubeval/image/go.mod index f51c906ae..68cbf7e0e 100644 --- a/functions/examples/validator-kubeval/image/go.mod +++ b/functions/examples/validator-kubeval/image/go.mod @@ -4,5 +4,5 @@ go 1.14 require ( github.com/instrumenta/kubeval v0.0.0-20190918223246-8d013ec9fc56 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 ) diff --git a/functions/examples/validator-kubeval/image/go.sum b/functions/examples/validator-kubeval/image/go.sum index b2a963b79..53e175d03 100644 --- a/functions/examples/validator-kubeval/image/go.sum +++ b/functions/examples/validator-kubeval/image/go.sum @@ -195,6 +195,7 @@ github.com/spf13/viper v1.1.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7Sr github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -293,7 +294,7 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo= gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/functions/examples/validator-resource-requests/image/go.mod b/functions/examples/validator-resource-requests/image/go.mod index 3dff0a616..2c74dc5e8 100644 --- a/functions/examples/validator-resource-requests/image/go.mod +++ b/functions/examples/validator-resource-requests/image/go.mod @@ -2,4 +2,4 @@ module sigs.k8s.io/kustomize/functions/examples/validator-resource-requests go 1.14 -require sigs.k8s.io/kustomize/kyaml v0.5.0 +require sigs.k8s.io/kustomize/kyaml v0.6.1 diff --git a/functions/examples/validator-resource-requests/image/go.sum b/functions/examples/validator-resource-requests/image/go.sum index 53b2259ad..2171add52 100644 --- a/functions/examples/validator-resource-requests/image/go.sum +++ b/functions/examples/validator-resource-requests/image/go.sum @@ -168,6 +168,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -256,5 +257,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo= gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= diff --git a/hack/pinUnpinPluginApiDep.sh b/hack/pinUnpinPluginApiDep.sh index 42471d189..1e07d202b 100755 --- a/hack/pinUnpinPluginApiDep.sh +++ b/hack/pinUnpinPluginApiDep.sh @@ -6,13 +6,13 @@ # released version of the kustomize API, # run this from the repo root: # -# ./hack/pinUnpinPluginApiDep.sh pin v0.2.0 +# ./hack/pinUnpinPluginApiDep.sh pin api v0.2.0 # # To replace fixed dependence with # dependence on local filesystem (HEAD) # run this from the repo root: # -# ./hack/pinUnpinPluginApiDep.sh unPin +# ./hack/pinUnpinPluginApiDep.sh unPin api # # All plugins, even plugins not written in Go, # have a unit test written in Go that depends @@ -30,29 +30,26 @@ # they are just examples - but likely should # remain unpinned too. Nothing in the outside # world should depend on these plugin modules, -# so there's no reason for them to be properly -# pinned. -# -# An external plugin author will obviously -# want to pin their plugin to some set of fixed -# dependencies, and the go.mod files for the -# plugins in this repo are just examples of how -# to do so. +# so there's no reason for them to be pinned. set -o errexit set -o nounset -set -o pipefail +#set -o pipefail function doUnPin { - oldV=$(grep -m 1 sigs.k8s.io/kustomize/api go.mod | awk '{print $NF}') - go mod edit -replace=sigs.k8s.io/kustomize/api@${oldV}=$1 + oldV=$(grep -m 1 sigs.k8s.io/kustomize/${module} go.mod | awk '{print $NF}') + if [ ! -z $oldV ]; then + go mod edit -replace=sigs.k8s.io/kustomize/${module}@${oldV}=$1 + fi go mod tidy } function doPin { - oldV=$(grep -m 1 sigs.k8s.io/kustomize/api go.mod | awk '{print $NF}') - go mod edit -dropreplace=sigs.k8s.io/kustomize/api@${oldV} - go mod edit -require=sigs.k8s.io/kustomize/api@$1 + oldV=$(grep -m 1 sigs.k8s.io/kustomize/${module} go.mod | awk '{print $NF}') + if [ ! -z $oldV ]; then + go mod edit -dropreplace=sigs.k8s.io/kustomize/${module}@${oldV} + go mod edit -require=sigs.k8s.io/kustomize/${module}@$1 + fi go mod tidy } @@ -65,28 +62,46 @@ function forEachGoMod { } function unPin { - forEachGoMod doUnPin ./plugin/builtin ../../../api - forEachGoMod doUnPin ./plugin/someteam.example.com/v1 ../../../../api + echo "Unpinning $module" + forEachGoMod doUnPin ./plugin/builtin ../../../${module} + forEachGoMod doUnPin ./plugin/someteam.example.com/v1 ../../../../${module} } function pin { - forEachGoMod doPin ./plugin/builtin $version - forEachGoMod doPin ./plugin/someteam.example.com/v1 $version + echo "Pinning $module to $version" + forEachGoMod doPin ./plugin/builtin ${version} + forEachGoMod doPin ./plugin/someteam.example.com/v1 ${version} } +if [ "$#" -eq 0 ]; then + echo "Pin or unpin plugins, e.g." + echo " " + echo " ./hack/pinUnpinPluginApiDep.sh pin api v0.2.0" + echo " " + echo " ./hack/pinUnpinPluginApiDep.sh unPin api" + echo " " + exit 1 +fi + operation=$1 if [[ ("$operation" != "pin") && ("$operation" != "unPin") ]]; then echo "unknown operation $operation" exit 1 fi +module=$2 +if [[ ("$module" != "api") && ("$module" != "kyaml") ]]; then + echo "unknown module $module" + exit 1 +fi + version="unnecessary" if [ "$operation" == "pin" ]; then - if [ "$#" -le 1 ]; then + if [ "$#" -le 2 ]; then echo "Specify version to pin, e.g. '$0 pin v0.2.0'" exit 1 fi - version=$2 + version=$3 fi $operation diff --git a/plugin/builtin/annotationstransformer/go.mod b/plugin/builtin/annotationstransformer/go.mod index ff3d65c12..d8af218dd 100644 --- a/plugin/builtin/annotationstransformer/go.mod +++ b/plugin/builtin/annotationstransformer/go.mod @@ -4,8 +4,10 @@ go 1.14 require ( sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace sigs.k8s.io/kustomize/api v0.5.1 => ../../../api + +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml diff --git a/plugin/builtin/annotationstransformer/go.sum b/plugin/builtin/annotationstransformer/go.sum index f9bfb4492..648e4f233 100644 --- a/plugin/builtin/annotationstransformer/go.sum +++ b/plugin/builtin/annotationstransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,6 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/configmapgenerator/go.sum b/plugin/builtin/configmapgenerator/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/builtin/configmapgenerator/go.sum +++ b/plugin/builtin/configmapgenerator/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/hashtransformer/go.sum b/plugin/builtin/hashtransformer/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/builtin/hashtransformer/go.sum +++ b/plugin/builtin/hashtransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/imagetagtransformer/go.mod b/plugin/builtin/imagetagtransformer/go.mod index d823142de..9e8903422 100644 --- a/plugin/builtin/imagetagtransformer/go.mod +++ b/plugin/builtin/imagetagtransformer/go.mod @@ -4,8 +4,10 @@ go 1.14 require ( sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace sigs.k8s.io/kustomize/api v0.5.1 => ../../../api + +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml diff --git a/plugin/builtin/imagetagtransformer/go.sum b/plugin/builtin/imagetagtransformer/go.sum index f9bfb4492..648e4f233 100644 --- a/plugin/builtin/imagetagtransformer/go.sum +++ b/plugin/builtin/imagetagtransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,6 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/labeltransformer/go.mod b/plugin/builtin/labeltransformer/go.mod index 7c6474966..257a42a7f 100644 --- a/plugin/builtin/labeltransformer/go.mod +++ b/plugin/builtin/labeltransformer/go.mod @@ -4,8 +4,10 @@ go 1.14 require ( sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace sigs.k8s.io/kustomize/api v0.5.1 => ../../../api + +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml diff --git a/plugin/builtin/labeltransformer/go.sum b/plugin/builtin/labeltransformer/go.sum index f9bfb4492..648e4f233 100644 --- a/plugin/builtin/labeltransformer/go.sum +++ b/plugin/builtin/labeltransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,6 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/legacyordertransformer/go.sum b/plugin/builtin/legacyordertransformer/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/builtin/legacyordertransformer/go.sum +++ b/plugin/builtin/legacyordertransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/namespacetransformer/go.mod b/plugin/builtin/namespacetransformer/go.mod index 881a82f4f..c931060f5 100644 --- a/plugin/builtin/namespacetransformer/go.mod +++ b/plugin/builtin/namespacetransformer/go.mod @@ -4,8 +4,10 @@ go 1.14 require ( sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace sigs.k8s.io/kustomize/api v0.5.1 => ../../../api + +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml diff --git a/plugin/builtin/namespacetransformer/go.sum b/plugin/builtin/namespacetransformer/go.sum index f9bfb4492..648e4f233 100644 --- a/plugin/builtin/namespacetransformer/go.sum +++ b/plugin/builtin/namespacetransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,6 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/patchjson6902transformer/go.mod b/plugin/builtin/patchjson6902transformer/go.mod index 304fb8850..e8a0f526e 100644 --- a/plugin/builtin/patchjson6902transformer/go.mod +++ b/plugin/builtin/patchjson6902transformer/go.mod @@ -6,8 +6,10 @@ require ( github.com/evanphx/json-patch v4.5.0+incompatible github.com/pkg/errors v0.8.1 sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace sigs.k8s.io/kustomize/api v0.5.1 => ../../../api + +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml diff --git a/plugin/builtin/patchjson6902transformer/go.sum b/plugin/builtin/patchjson6902transformer/go.sum index f9bfb4492..648e4f233 100644 --- a/plugin/builtin/patchjson6902transformer/go.sum +++ b/plugin/builtin/patchjson6902transformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,6 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/patchstrategicmergetransformer/go.mod b/plugin/builtin/patchstrategicmergetransformer/go.mod index fc0467aa2..00acc6635 100644 --- a/plugin/builtin/patchstrategicmergetransformer/go.mod +++ b/plugin/builtin/patchstrategicmergetransformer/go.mod @@ -5,11 +5,11 @@ go 1.14 require ( github.com/pkg/errors v0.8.1 sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace ( sigs.k8s.io/kustomize/api v0.5.1 => ../../../api - sigs.k8s.io/kustomize/kyaml v0.5.0 => ../../../kyaml + sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml ) diff --git a/plugin/builtin/patchtransformer/go.mod b/plugin/builtin/patchtransformer/go.mod index c35f2955e..658a5d24b 100644 --- a/plugin/builtin/patchtransformer/go.mod +++ b/plugin/builtin/patchtransformer/go.mod @@ -5,8 +5,10 @@ go 1.14 require ( github.com/evanphx/json-patch v4.5.0+incompatible sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace sigs.k8s.io/kustomize/api v0.5.1 => ../../../api + +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml diff --git a/plugin/builtin/patchtransformer/go.sum b/plugin/builtin/patchtransformer/go.sum index f9bfb4492..648e4f233 100644 --- a/plugin/builtin/patchtransformer/go.sum +++ b/plugin/builtin/patchtransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,6 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/prefixsuffixtransformer/go.mod b/plugin/builtin/prefixsuffixtransformer/go.mod index 743b43cd7..f819d3780 100644 --- a/plugin/builtin/prefixsuffixtransformer/go.mod +++ b/plugin/builtin/prefixsuffixtransformer/go.mod @@ -4,8 +4,10 @@ go 1.14 require ( sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace sigs.k8s.io/kustomize/api v0.5.1 => ../../../api + +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml diff --git a/plugin/builtin/prefixsuffixtransformer/go.sum b/plugin/builtin/prefixsuffixtransformer/go.sum index f9bfb4492..648e4f233 100644 --- a/plugin/builtin/prefixsuffixtransformer/go.sum +++ b/plugin/builtin/prefixsuffixtransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,6 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/replicacounttransformer/go.mod b/plugin/builtin/replicacounttransformer/go.mod index 2e063f3f3..35cab2da8 100644 --- a/plugin/builtin/replicacounttransformer/go.mod +++ b/plugin/builtin/replicacounttransformer/go.mod @@ -4,8 +4,10 @@ go 1.14 require ( sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace sigs.k8s.io/kustomize/api v0.5.1 => ../../../api + +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml diff --git a/plugin/builtin/replicacounttransformer/go.sum b/plugin/builtin/replicacounttransformer/go.sum index f9bfb4492..648e4f233 100644 --- a/plugin/builtin/replicacounttransformer/go.sum +++ b/plugin/builtin/replicacounttransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,6 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/secretgenerator/go.sum b/plugin/builtin/secretgenerator/go.sum index b5de1ddfe..168ea62db 100644 --- a/plugin/builtin/secretgenerator/go.sum +++ b/plugin/builtin/secretgenerator/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -519,8 +520,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/builtin/valueaddtransformer/go.mod b/plugin/builtin/valueaddtransformer/go.mod index 3d42ab535..7a4eab75f 100644 --- a/plugin/builtin/valueaddtransformer/go.mod +++ b/plugin/builtin/valueaddtransformer/go.mod @@ -4,8 +4,10 @@ go 1.14 require ( sigs.k8s.io/kustomize/api v0.5.1 - sigs.k8s.io/kustomize/kyaml v0.5.0 + sigs.k8s.io/kustomize/kyaml v0.6.1 sigs.k8s.io/yaml v1.2.0 ) replace sigs.k8s.io/kustomize/api v0.5.1 => ../../../api + +replace sigs.k8s.io/kustomize/kyaml v0.6.1 => ../../../kyaml diff --git a/plugin/builtin/valueaddtransformer/go.sum b/plugin/builtin/valueaddtransformer/go.sum index f9bfb4492..648e4f233 100644 --- a/plugin/builtin/valueaddtransformer/go.sum +++ b/plugin/builtin/valueaddtransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,6 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/bashedconfigmap/go.sum b/plugin/someteam.example.com/v1/bashedconfigmap/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/bashedconfigmap/go.sum +++ b/plugin/someteam.example.com/v1/bashedconfigmap/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/chartinflator/go.sum b/plugin/someteam.example.com/v1/chartinflator/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/chartinflator/go.sum +++ b/plugin/someteam.example.com/v1/chartinflator/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/dateprefixer/go.sum b/plugin/someteam.example.com/v1/dateprefixer/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/dateprefixer/go.sum +++ b/plugin/someteam.example.com/v1/dateprefixer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/gogetter/go.sum b/plugin/someteam.example.com/v1/gogetter/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/gogetter/go.sum +++ b/plugin/someteam.example.com/v1/gogetter/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/printpluginenv/go.sum b/plugin/someteam.example.com/v1/printpluginenv/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/printpluginenv/go.sum +++ b/plugin/someteam.example.com/v1/printpluginenv/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/replacementtransformer/go.sum b/plugin/someteam.example.com/v1/replacementtransformer/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/replacementtransformer/go.sum +++ b/plugin/someteam.example.com/v1/replacementtransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/secretsfromdatabase/go.sum b/plugin/someteam.example.com/v1/secretsfromdatabase/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/secretsfromdatabase/go.sum +++ b/plugin/someteam.example.com/v1/secretsfromdatabase/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/sedtransformer/go.sum b/plugin/someteam.example.com/v1/sedtransformer/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/sedtransformer/go.sum +++ b/plugin/someteam.example.com/v1/sedtransformer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/someservicegenerator/go.sum b/plugin/someteam.example.com/v1/someservicegenerator/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/someservicegenerator/go.sum +++ b/plugin/someteam.example.com/v1/someservicegenerator/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/stringprefixer/go.sum b/plugin/someteam.example.com/v1/stringprefixer/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/stringprefixer/go.sum +++ b/plugin/someteam.example.com/v1/stringprefixer/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/plugin/someteam.example.com/v1/validator/go.sum b/plugin/someteam.example.com/v1/validator/go.sum index f9bfb4492..3f02443a8 100644 --- a/plugin/someteam.example.com/v1/validator/go.sum +++ b/plugin/someteam.example.com/v1/validator/go.sum @@ -334,6 +334,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -521,8 +522,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= -sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= +sigs.k8s.io/kustomize/kyaml v0.6.1 h1:mwffj5vt3MPdbWV3fZnnwol8SO7sUoGdgejBlvseyak= +sigs.k8s.io/kustomize/kyaml v0.6.1/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= From 719380f523ff751bc79f103d250309c7dfe0e429 Mon Sep 17 00:00:00 2001 From: jregan Date: Sun, 23 Aug 2020 08:18:23 -0700 Subject: [PATCH 16/23] Copy api/resmap/resmap to api/resmap/reswrangler. --- api/resmap/{resmap.go => reswrangler.go} | 0 api/resmap/{resmap_test.go => reswrangler_test.go} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename api/resmap/{resmap.go => reswrangler.go} (100%) rename api/resmap/{resmap_test.go => reswrangler_test.go} (100%) diff --git a/api/resmap/resmap.go b/api/resmap/reswrangler.go similarity index 100% rename from api/resmap/resmap.go rename to api/resmap/reswrangler.go diff --git a/api/resmap/resmap_test.go b/api/resmap/reswrangler_test.go similarity index 100% rename from api/resmap/resmap_test.go rename to api/resmap/reswrangler_test.go From 97bc34eb37fcdaf0df581ac6724662f6e3c84589 Mon Sep 17 00:00:00 2001 From: jregan Date: Sun, 23 Aug 2020 08:18:23 -0700 Subject: [PATCH 17/23] Delete non-api/resmap/reswrangler stuff from api/resmap/reswrangler. --- api/resmap/reswrangler.go | 230 +------------------------------------- 1 file changed, 1 insertion(+), 229 deletions(-) diff --git a/api/resmap/reswrangler.go b/api/resmap/reswrangler.go index b86b2f699..68ba98c66 100644 --- a/api/resmap/reswrangler.go +++ b/api/resmap/reswrangler.go @@ -1,8 +1,6 @@ // Copyright 2019 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0 -// Package resmap implements a map from ResId to Resource that -// tracks all resources in a kustomization. package resmap import ( @@ -11,239 +9,13 @@ import ( "regexp" "github.com/pkg/errors" - "sigs.k8s.io/kustomize/api/ifc" "sigs.k8s.io/kustomize/api/resid" "sigs.k8s.io/kustomize/api/resource" "sigs.k8s.io/kustomize/api/types" "sigs.k8s.io/yaml" ) -// A Transformer modifies an instance of ResMap. -type Transformer interface { - // Transform modifies data in the argument, - // e.g. adding labels to resources that can be labelled. - Transform(m ResMap) error -} - -// A Generator creates an instance of ResMap. -type Generator interface { - Generate() (ResMap, error) -} - -// Something that's configurable accepts an -// instance of PluginHelpers and a raw config -// object (YAML in []byte form). -type Configurable interface { - Config(h *PluginHelpers, config []byte) error -} - -// NewPluginHelpers makes an instance of PluginHelpers. -func NewPluginHelpers(ldr ifc.Loader, v ifc.Validator, rf *Factory) *PluginHelpers { - return &PluginHelpers{ldr: ldr, v: v, rf: rf} -} - -// PluginHelpers holds things that any or all plugins might need. -// This should be available to each plugin, in addition to -// any plugin-specific configuration. -type PluginHelpers struct { - ldr ifc.Loader - v ifc.Validator - rf *Factory -} - -func (c *PluginHelpers) Loader() ifc.Loader { - return c.ldr -} - -func (c *PluginHelpers) ResmapFactory() *Factory { - return c.rf -} - -func (c *PluginHelpers) Validator() ifc.Validator { - return c.v -} - -type GeneratorPlugin interface { - Generator - Configurable -} - -type TransformerPlugin interface { - Transformer - Configurable -} - -// ResMap is an interface describing operations on the -// core kustomize data structure, a list of Resources. -// -// Every Resource has two ResIds: OrgId and CurId. -// -// In a ResMap, no two resources may have the same CurId, -// but they may have the same OrgId. The latter can happen -// when mixing two or more different overlays apply different -// transformations to a common base. When looking for a -// resource to transform, try the OrgId first, and if this -// fails or finds too many, it might make sense to then try -// the CurrId. Depends on the situation. -type ResMap interface { - // Size reports the number of resources. - Size() int - - // Resources provides a discardable slice - // of resource pointers, returned in the order - // as appended. - Resources() []*resource.Resource - - // Append adds a Resource. Error on CurId collision. - // - // A class invariant of ResMap is that all of its - // resources must differ in their value of - // CurId(), aka current Id. The Id is the tuple - // of {namespace, group, version, kind, name} - // (see ResId). - // - // This invariant reflects the invariant of a - // kubernetes cluster, where if one tries to add - // a resource to the cluster whose Id matches - // that of a resource already in the cluster, - // only two outcomes are allowed. Either the - // incoming resource is _merged_ into the existing - // one, or the incoming resource is rejected. - // One cannot end up with two resources - // in the cluster with the same Id. - Append(*resource.Resource) error - - // AppendAll appends another ResMap to self, - // failing on any CurId collision. - AppendAll(ResMap) error - - // AbsorbAll appends, replaces or merges the contents - // of another ResMap into self, - // allowing and sometimes demanding ID collisions. - // A collision would be demanded, say, when a generated - // ConfigMap has the "replace" option in its generation - // instructions, meaning it _must_ replace - // something in the known set of resources. - // If a resource id for resource X is found to already - // be in self, then the behavior field for X must - // be BehaviorMerge or BehaviorReplace. If X is not in - // self, then its behavior _cannot_ be merge or replace. - AbsorbAll(ResMap) error - - // AsYaml returns the yaml form of resources. - AsYaml() ([]byte, error) - - // GetByIndex returns a resource at the given index, - // nil if out of range. - GetByIndex(int) *resource.Resource - - // GetIndexOfCurrentId returns the index of the resource - // with the given CurId. - // Returns error if there is more than one match. - // Returns (-1, nil) if there is no match. - GetIndexOfCurrentId(id resid.ResId) (int, error) - - // GetMatchingResourcesByCurrentId returns the resources - // who's CurId is matched by the argument. - GetMatchingResourcesByCurrentId(matches IdMatcher) []*resource.Resource - - // GetMatchingResourcesByOriginalId returns the resources - // who's OriginalId is matched by the argument. - GetMatchingResourcesByOriginalId(matches IdMatcher) []*resource.Resource - - // GetByCurrentId is shorthand for calling - // GetMatchingResourcesByCurrentId with a matcher requiring - // an exact match, returning an error on multiple or no matches. - GetByCurrentId(resid.ResId) (*resource.Resource, error) - - // GetByOriginalId is shorthand for calling - // GetMatchingResourcesByOriginalId with a matcher requiring - // an exact match, returning an error on multiple or no matches. - GetByOriginalId(resid.ResId) (*resource.Resource, error) - - // GetById is a helper function which first - // attempts GetByOriginalId, then GetByCurrentId, - // returning an error if both fail to find a single - // match. - GetById(resid.ResId) (*resource.Resource, error) - - // GroupedByCurrentNamespace returns a map of namespace - // to a slice of *Resource in that namespace. - // Resources for whom IsNamespaceableKind is false are - // are not included at all (see NonNamespaceable). - // Resources with an empty namespace are placed - // in the resid.DefaultNamespace entry. - GroupedByCurrentNamespace() map[string][]*resource.Resource - - // GroupByOrginalNamespace performs as GroupByNamespace - // but use the original namespace instead of the current - // one to perform the grouping. - GroupedByOriginalNamespace() map[string][]*resource.Resource - - // NonNamespaceable returns a slice of resources that - // cannot be placed in a namespace, e.g. - // Node, ClusterRole, Namespace itself, etc. - NonNamespaceable() []*resource.Resource - - // AllIds returns all CurrentIds. - AllIds() []resid.ResId - - // Replace replaces the resource with the matching CurId. - // Error if there's no match or more than one match. - // Returns the index where the replacement happened. - Replace(*resource.Resource) (int, error) - - // Remove removes the resource whose CurId matches the argument. - // Error if not found. - Remove(resid.ResId) error - - // Clear removes all resources and Ids. - Clear() - - // SubsetThatCouldBeReferencedByResource returns a ResMap subset - // of self with resources that could be referenced by the - // resource argument. - // This is a filter; it excludes things that cannot be - // referenced by the resource, e.g. objects in other - // namespaces. Cluster wide objects are never excluded. - SubsetThatCouldBeReferencedByResource(*resource.Resource) ResMap - - // DeepCopy copies the ResMap and underlying resources. - DeepCopy() ResMap - - // ShallowCopy copies the ResMap but - // not the underlying resources. - ShallowCopy() ResMap - - // ErrorIfNotEqualSets returns an error if the - // argument doesn't have the same resources as self. - // Ordering is _not_ taken into account, - // as this function was solely used in tests written - // before internal resource order was maintained, - // and those tests are initialized with maps which - // by definition have random ordering, and will - // fail spuriously. - // TODO: modify tests to not use resmap.FromMap, - // TODO: - and replace this with a stricter equals. - ErrorIfNotEqualSets(ResMap) error - - // ErrorIfNotEqualLists returns an error if the - // argument doesn't have the resource objects - // data as self, in the same order. - // Meta information is ignored; this is similar - // to comparing the AsYaml() strings, but allows - // for more informed errors on not equals. - ErrorIfNotEqualLists(ResMap) error - - // Debug prints the ResMap. - Debug(title string) - - // Select returns a list of resources that - // are selected by a Selector - Select(types.Selector) ([]*resource.Resource, error) -} - -// resWrangler holds the content manipulated by kustomize. +// resWrangler implements ResMap. type resWrangler struct { // Resource list maintained in load (append) order. // This is important for transformers, which must From f051acb83c559a9f22bc5fec18d43e421fc2d9a4 Mon Sep 17 00:00:00 2001 From: jregan Date: Sun, 23 Aug 2020 11:58:28 -0700 Subject: [PATCH 18/23] Clean up option construction. --- .../{validators.go => kustvalidator.go} | 0 api/krusty/options.go | 3 ++- api/testutils/kusttest/harness.go | 16 ++++++---------- kustomize/internal/commands/build/build.go | 15 ++++----------- 4 files changed, 12 insertions(+), 22 deletions(-) rename api/k8sdeps/validator/{validators.go => kustvalidator.go} (100%) diff --git a/api/k8sdeps/validator/validators.go b/api/k8sdeps/validator/kustvalidator.go similarity index 100% rename from api/k8sdeps/validator/validators.go rename to api/k8sdeps/validator/kustvalidator.go diff --git a/api/krusty/options.go b/api/krusty/options.go index cf4b5c7aa..44d61fc87 100644 --- a/api/krusty/options.go +++ b/api/krusty/options.go @@ -37,7 +37,8 @@ type Options struct { // MakeDefaultOptions returns a default instance of Options. func MakeDefaultOptions() *Options { return &Options{ - DoLegacyResourceSort: true, + DoLegacyResourceSort: false, + AddManagedbyLabel: false, LoadRestrictions: types.LoadRestrictionsRootOnly, DoPrune: false, PluginConfig: konfig.DisabledPluginConfig(), diff --git a/api/testutils/kusttest/harness.go b/api/testutils/kusttest/harness.go index d79e40e82..f1d8706ac 100644 --- a/api/testutils/kusttest/harness.go +++ b/api/testutils/kusttest/harness.go @@ -16,7 +16,7 @@ import ( "sigs.k8s.io/kustomize/api/types" ) -// Harness manages a kustomize environment for tests. +// Harness manages a test environment. type Harness struct { t *testing.T fSys filesys.FileSystem @@ -72,15 +72,12 @@ func (th Harness) MakeDefaultOptions() krusty.Options { // This has no impact on Builtin plugins, as they are always enabled. func (th Harness) MakeOptionsPluginsDisabled() krusty.Options { - return krusty.Options{ - LoadRestrictions: types.LoadRestrictionsRootOnly, - PluginConfig: konfig.DisabledPluginConfig(), - } + return *krusty.MakeDefaultOptions() } // Enables use of non-builtin plugins. func (th Harness) MakeOptionsPluginsEnabled() krusty.Options { - c, err := konfig.EnabledPluginConfig(types.BploLoadFromFileSys) + pc, err := konfig.EnabledPluginConfig(types.BploLoadFromFileSys) if err != nil { if strings.Contains(err.Error(), "unable to find plugin root") { th.t.Log( @@ -89,10 +86,9 @@ func (th Harness) MakeOptionsPluginsEnabled() krusty.Options { } th.t.Fatal(err) } - return krusty.Options{ - LoadRestrictions: types.LoadRestrictionsRootOnly, - PluginConfig: c, - } + o := *krusty.MakeDefaultOptions() + o.PluginConfig = pc + return o } // Run, failing on error. diff --git a/kustomize/internal/commands/build/build.go b/kustomize/internal/commands/build/build.go index 9349e9cd0..7f9f323db 100644 --- a/kustomize/internal/commands/build/build.go +++ b/kustomize/internal/commands/build/build.go @@ -120,25 +120,18 @@ func (o *Options) Validate(args []string) (err error) { } func (o *Options) makeOptions() *krusty.Options { - opts := &krusty.Options{ - DoLegacyResourceSort: o.outOrder == legacy, - LoadRestrictions: getFlagLoadRestrictorValue(), - } + opts := krusty.MakeDefaultOptions() + opts.DoLegacyResourceSort = o.outOrder == legacy + opts.LoadRestrictions = getFlagLoadRestrictorValue() if isFlagEnablePluginsSet() { c, err := konfig.EnabledPluginConfig(types.BploUseStaticallyLinked) if err != nil { log.Fatal(err) } - c.FnpLoadingOptions = o.fnOptions - opts.PluginConfig = c - } else { - opts.PluginConfig = konfig.DisabledPluginConfig() - } - if isManagedbyLabelEnabled() { - opts.AddManagedbyLabel = true } + opts.AddManagedbyLabel = isManagedbyLabelEnabled() return opts } From e91cdb5eba9dc09134cef5b5094fabaf3b71ebb3 Mon Sep 17 00:00:00 2001 From: jregan Date: Thu, 16 Jul 2020 17:14:24 -0700 Subject: [PATCH 19/23] Checkpoint --- api/go.mod | 1 + api/internal/merge/merginator.go | 25 ++ api/internal/merge/merginator_test.go | 4 + api/internal/validate/fieldvalidator.go | 64 ++++ api/internal/validate/fieldvalidator_test.go | 4 + api/internal/wrappy/factory.go | 41 +++ api/internal/wrappy/factory_test.go | 4 + api/internal/wrappy/wnode.go | 143 ++++++++ api/internal/wrappy/wnode_test.go | 339 ++++++++++++++++++ api/k8sdeps/validator/kustvalidator.go | 3 + api/krusty/internal/provider/depprovider.go | 183 ++++++++++ api/krusty/kustomizer.go | 24 +- api/krusty/options.go | 5 + kustomize/internal/commands/build/build.go | 2 + .../commands/build/flagEnableKyaml.go | 21 ++ 15 files changed, 851 insertions(+), 12 deletions(-) create mode 100644 api/internal/merge/merginator.go create mode 100644 api/internal/merge/merginator_test.go create mode 100644 api/internal/validate/fieldvalidator.go create mode 100644 api/internal/validate/fieldvalidator_test.go create mode 100644 api/internal/wrappy/factory.go create mode 100644 api/internal/wrappy/factory_test.go create mode 100644 api/internal/wrappy/wnode.go create mode 100644 api/internal/wrappy/wnode_test.go create mode 100644 api/krusty/internal/provider/depprovider.go create mode 100644 kustomize/internal/commands/build/flagEnableKyaml.go diff --git a/api/go.mod b/api/go.mod index 45ebb6b92..26a56b767 100644 --- a/api/go.mod +++ b/api/go.mod @@ -12,6 +12,7 @@ require ( github.com/yujunz/go-getter v1.4.1-lite golang.org/x/tools v0.0.0-20191010075000-0337d82405ff gopkg.in/yaml.v2 v2.3.0 + gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 k8s.io/api v0.17.0 k8s.io/apimachinery v0.17.0 k8s.io/client-go v0.17.0 diff --git a/api/internal/merge/merginator.go b/api/internal/merge/merginator.go new file mode 100644 index 000000000..295450889 --- /dev/null +++ b/api/internal/merge/merginator.go @@ -0,0 +1,25 @@ +// Copyright 2020 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package merge + +import ( + "sigs.k8s.io/kustomize/api/resmap" + "sigs.k8s.io/kustomize/api/resource" +) + +// Merginator implements resmap.Merginator using kyaml libs. +type Merginator struct { +} + +var _ resmap.Merginator = (*Merginator)(nil) + +func NewMerginator(_ *resource.Factory) *Merginator { + return &Merginator{} +} + +// Merge implements resmap.Merginator +func (m Merginator) Merge( + resources []*resource.Resource) (resmap.ResMap, error) { + panic("TODO(#Merginator): implement Merge") +} diff --git a/api/internal/merge/merginator_test.go b/api/internal/merge/merginator_test.go new file mode 100644 index 000000000..3a15de64b --- /dev/null +++ b/api/internal/merge/merginator_test.go @@ -0,0 +1,4 @@ +// Copyright 2020 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package merge_test diff --git a/api/internal/validate/fieldvalidator.go b/api/internal/validate/fieldvalidator.go new file mode 100644 index 000000000..c9e47fa3e --- /dev/null +++ b/api/internal/validate/fieldvalidator.go @@ -0,0 +1,64 @@ +// Copyright 2020 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package validate + +import ( + "sigs.k8s.io/kustomize/api/ifc" +) + +// FieldValidator implements ifc.Validator to check +// the values of various KRM string fields, +// e.g. labels, annotations, names, namespaces. +type FieldValidator struct { +} + +var _ ifc.Validator = (*FieldValidator)(nil) + +func NewFieldValidator() *FieldValidator { + return &FieldValidator{} +} + +// TODO(#FieldValidator): implement MakeAnnotationValidator +func (f FieldValidator) MakeAnnotationValidator() func(map[string]string) error { + return func(x map[string]string) error { + return nil + } +} + +// TODO(#FieldValidator): implement MakeAnnotationNameValidator +func (f FieldValidator) MakeAnnotationNameValidator() func([]string) error { + return func(x []string) error { + return nil + } +} + +// TODO(#FieldValidator): implement MakeLabelValidator +func (f FieldValidator) MakeLabelValidator() func(map[string]string) error { + return func(x map[string]string) error { + return nil + } +} + +// TODO(#FieldValidator): implement MakeLabelNameValidator +func (f FieldValidator) MakeLabelNameValidator() func([]string) error { + return func(x []string) error { + return nil + } +} + +// TODO(#FieldValidator): implement ValidateNamespace +func (f FieldValidator) ValidateNamespace(s string) []string { + var errs []string + return errs +} + +// TODO(#FieldValidator): implement ErrIfInvalidKey +func (f FieldValidator) ErrIfInvalidKey(s string) error { + return nil +} + +// TODO(#FieldValidator): implement IsEnvVarName +func (f FieldValidator) IsEnvVarName(k string) error { + return nil +} diff --git a/api/internal/validate/fieldvalidator_test.go b/api/internal/validate/fieldvalidator_test.go new file mode 100644 index 000000000..82f18775b --- /dev/null +++ b/api/internal/validate/fieldvalidator_test.go @@ -0,0 +1,4 @@ +// Copyright 2020 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package validate_test diff --git a/api/internal/wrappy/factory.go b/api/internal/wrappy/factory.go new file mode 100644 index 000000000..b03b9e8fc --- /dev/null +++ b/api/internal/wrappy/factory.go @@ -0,0 +1,41 @@ +// Copyright 2020 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package wrappy + +import ( + "sigs.k8s.io/kustomize/api/ifc" + "sigs.k8s.io/kustomize/api/types" +) + +// WNodeFactory makes instances of WNode. +// These instances in turn adapt +// sigs.k8s.io/kustomize/kyaml/yaml.RNode +// to implement ifc.Unstructured. +// This factory is meant to implement ifc.KunstructuredFactory. +type WNodeFactory struct { +} + +var _ ifc.KunstructuredFactory = (*WNodeFactory)(nil) + +func (k *WNodeFactory) SliceFromBytes(bs []byte) ([]ifc.Kunstructured, error) { + panic("TODO(#WNodeFactory): implement SliceFromBytes") +} + +func (k *WNodeFactory) FromMap(m map[string]interface{}) ifc.Kunstructured { + panic("TODO(#WNodeFactory): implement FromMap") +} + +func (k *WNodeFactory) Hasher() ifc.KunstructuredHasher { + panic("TODO(#WNodeFactory): implement Hasher") +} + +func (k *WNodeFactory) MakeConfigMap( + kvLdr ifc.KvLoader, args *types.ConfigMapArgs) (ifc.Kunstructured, error) { + panic("TODO(#WNodeFactory): implement MakeConfigMap") +} + +func (k *WNodeFactory) MakeSecret( + kvLdr ifc.KvLoader, args *types.SecretArgs) (ifc.Kunstructured, error) { + panic("TODO(#WNodeFactory): implement MakeSecret") +} diff --git a/api/internal/wrappy/factory_test.go b/api/internal/wrappy/factory_test.go new file mode 100644 index 000000000..7db433cb6 --- /dev/null +++ b/api/internal/wrappy/factory_test.go @@ -0,0 +1,4 @@ +// Copyright 2020 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package wrappy_test diff --git a/api/internal/wrappy/wnode.go b/api/internal/wrappy/wnode.go new file mode 100644 index 000000000..be3bb8485 --- /dev/null +++ b/api/internal/wrappy/wnode.go @@ -0,0 +1,143 @@ +// Copyright 2020 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package wrappy + +import ( + "log" + + "sigs.k8s.io/kustomize/api/ifc" + "sigs.k8s.io/kustomize/api/resid" + "sigs.k8s.io/kustomize/kyaml/yaml" +) + +// WNode implements ifc.Kunstructured using yaml.RNode. +// +// It exists only to help manage a switch from +// kunstruct.UnstructAdapter to yaml.RNode as the core +// representation of KRM objects in kustomize. +// +// It's got a silly name because we don't want it around for long, +// and want its use to be obvious. +type WNode struct { + node *yaml.RNode +} + +var _ ifc.Kunstructured = (*WNode)(nil) + +func NewWNode() *WNode { + return FromRNode(yaml.NewRNode(nil)) +} + +func FromRNode(node *yaml.RNode) *WNode { + return &WNode{node: node} +} + +func (wn *WNode) demandMetaData(label string) yaml.ResourceMeta { + meta, err := wn.node.GetMeta() + if err != nil { + // Log and die since interface doesn't allow error. + log.Fatalf("for %s', expected valid resource: %v", label, err) + } + return meta +} + +// Copy implements ifc.Kunstructured. +func (wn *WNode) Copy() ifc.Kunstructured { + return &WNode{node: wn.node.Copy()} +} + +// GetAnnotations implements ifc.Kunstructured. +func (wn *WNode) GetAnnotations() map[string]string { + return wn.demandMetaData("GetAnnotations").Annotations +} + +// GetFieldValue implements ifc.Kunstructured. +func (wn *WNode) GetFieldValue(path string) (interface{}, error) { + // The argument is a json path, e.g. "metadata.name" + // fields := strings.Split(path, ".") + // return wn.node.Pipe(yaml.Lookup(fields...)) + panic("TODO(#WNode): GetFieldValue; implement or drop from API") +} + +// GetGvk implements ifc.Kunstructured. +func (wn *WNode) GetGvk() resid.Gvk { + meta := wn.demandMetaData("GetGvk") + g, v := resid.ParseGroupVersion(meta.APIVersion) + return resid.Gvk{Group: g, Version: v, Kind: meta.Kind} +} + +// GetKind implements ifc.Kunstructured. +func (wn *WNode) GetKind() string { + return wn.demandMetaData("GetKind").Kind +} + +// GetLabels implements ifc.Kunstructured. +func (wn *WNode) GetLabels() map[string]string { + return wn.demandMetaData("GetLabels").Labels +} + +// GetName implements ifc.Kunstructured. +func (wn *WNode) GetName() string { + return wn.demandMetaData("GetName").Name +} + +// GetSlice implements ifc.Kunstructured. +func (wn *WNode) GetSlice(string) ([]interface{}, error) { + panic("TODO(#WNode) GetSlice; implement or drop from API") +} + +// GetSlice implements ifc.Kunstructured. +func (wn *WNode) GetString(string) (string, error) { + panic("TODO(#WNode) GetString; implement or drop from API") +} + +// Map implements ifc.Kunstructured. +func (wn *WNode) Map() map[string]interface{} { + panic("TODO(#WNode) Map; implement or drop from API") +} + +// MarshalJSON implements ifc.Kunstructured. +func (wn *WNode) MarshalJSON() ([]byte, error) { + return wn.node.MarshalJSON() +} + +// MatchesAnnotationSelector implements ifc.Kunstructured. +func (wn *WNode) MatchesAnnotationSelector(string) (bool, error) { + panic("TODO(#WNode) MatchesAnnotationSelector; implement or drop from API") +} + +// MatchesLabelSelector implements ifc.Kunstructured. +func (wn *WNode) MatchesLabelSelector(string) (bool, error) { + panic("TODO(#WNode) MatchesLabelSelector; implement or drop from API") +} + +// SetAnnotations implements ifc.Kunstructured. +func (wn *WNode) SetAnnotations(map[string]string) { + panic("TODO(#WNode) SetAnnotations; implement or drop from API") +} + +// SetGvk implements ifc.Kunstructured. +func (wn *WNode) SetGvk(resid.Gvk) { + panic("TODO(#WNode) SetGvk; implement or drop from API") +} + +// SetLabels implements ifc.Kunstructured. +func (wn *WNode) SetLabels(map[string]string) { + panic("TODO(#WNode) SetLabels; implement or drop from API") +} + +// SetName implements ifc.Kunstructured. +func (wn *WNode) SetName(string) { + panic("TODO(#WNode) SetName; implement or drop from API") +} + +// SetNamespace implements ifc.Kunstructured. +func (wn *WNode) SetNamespace(string) { + panic("TODO(#WNode) SetNamespace; implement or drop from API") +} + +// UnmarshalJSON implements ifc.Kunstructured. +func (wn *WNode) UnmarshalJSON(data []byte) error { + return wn.node.UnmarshalJSON(data) +} diff --git a/api/internal/wrappy/wnode_test.go b/api/internal/wrappy/wnode_test.go new file mode 100644 index 000000000..072373a23 --- /dev/null +++ b/api/internal/wrappy/wnode_test.go @@ -0,0 +1,339 @@ +// Copyright 2019 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package wrappy_test + +import ( + "strings" + "testing" + + "gopkg.in/yaml.v3" + . "sigs.k8s.io/kustomize/api/internal/wrappy" + kyaml "sigs.k8s.io/kustomize/kyaml/yaml" +) + +const ( + deploymentLittleJson = `{"apiVersion":"apps/v1","kind":"Deployment",` + + `"metadata":{"name":"homer","namespace":"simpsons"}}` + + deploymentBiggerJson = ` +{ + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "homer", + "namespace": "simpsons", + "labels": { + "fruit": "apple", + "veggie": "carrot" + }, + "annotations": { + "area": "51", + "greeting": "Take me to your leader." + } + } +} +` + bigMapYaml = `Kind: Service +complextree: + - field1: + - boolfield: true + floatsubfield: 1.01 + intsubfield: 1010 + stringsubfield: idx1010 + - boolfield: false + floatsubfield: 1.011 + intsubfield: 1011 + stringsubfield: idx1011 + field2: + - boolfield: true + floatsubfield: 1.02 + intsubfield: 1020 + stringsubfield: idx1020 + - boolfield: false + floatsubfield: 1.021 + intsubfield: 1021 + stringsubfield: idx1021 + - field1: + - boolfield: true + floatsubfield: 1.11 + intsubfield: 1110 + stringsubfield: idx1110 + - boolfield: false + floatsubfield: 1.111 + intsubfield: 1111 + stringsubfield: idx1111 + field2: + - boolfield: true + floatsubfield: 1.112 + intsubfield: 1120 + stringsubfield: idx1120 + - boolfield: false + floatsubfield: 1.1121 + intsubfield: 1121 + stringsubfield: idx1121 +metadata: + labels: + app: application-name + name: service-name +spec: + ports: + port: 80 +that: + - idx0 + - idx1 + - idx2 + - idx3 +these: + - field1: + - idx010 + - idx011 + field2: + - idx020 + - idx021 + - field1: + - idx110 + - idx111 + field2: + - idx120 + - idx121 + - field1: + - idx210 + - idx211 + field2: + - idx220 + - idx221 +this: + is: + aBool: true + aFloat: 1.001 + aNilValue: null + aNumber: 1000 + anEmptyMap: {} + anEmptySlice: [] +those: + - field1: idx0foo + field2: idx0bar + - field1: idx1foo + field2: idx1bar + - field1: idx2foo + field2: idx2bar +` +) + +func makeBigMap() map[string]interface{} { + return map[string]interface{}{ + "Kind": "Service", + "metadata": map[string]interface{}{ + "labels": map[string]interface{}{ + "app": "application-name", + }, + "name": "service-name", + }, + "spec": map[string]interface{}{ + "ports": map[string]interface{}{ + "port": int64(80), + }, + }, + "this": map[string]interface{}{ + "is": map[string]interface{}{ + "aNumber": int64(1000), + "aFloat": float64(1.001), + "aNilValue": nil, + "aBool": true, + "anEmptyMap": map[string]interface{}{}, + "anEmptySlice": []interface{}{}, + /* + TODO: test for unrecognizable (e.g. a function) + "unrecognizable": testing.InternalExample{ + Name: "fooBar", + }, + */ + }, + }, + "that": []interface{}{ + "idx0", + "idx1", + "idx2", + "idx3", + }, + "those": []interface{}{ + map[string]interface{}{ + "field1": "idx0foo", + "field2": "idx0bar", + }, + map[string]interface{}{ + "field1": "idx1foo", + "field2": "idx1bar", + }, + map[string]interface{}{ + "field1": "idx2foo", + "field2": "idx2bar", + }, + }, + "these": []interface{}{ + map[string]interface{}{ + "field1": []interface{}{"idx010", "idx011"}, + "field2": []interface{}{"idx020", "idx021"}, + }, + map[string]interface{}{ + "field1": []interface{}{"idx110", "idx111"}, + "field2": []interface{}{"idx120", "idx121"}, + }, + map[string]interface{}{ + "field1": []interface{}{"idx210", "idx211"}, + "field2": []interface{}{"idx220", "idx221"}, + }, + }, + "complextree": []interface{}{ + map[string]interface{}{ + "field1": []interface{}{ + map[string]interface{}{ + "stringsubfield": "idx1010", + "intsubfield": int64(1010), + "floatsubfield": float64(1.010), + "boolfield": true, + }, + map[string]interface{}{ + "stringsubfield": "idx1011", + "intsubfield": int64(1011), + "floatsubfield": float64(1.011), + "boolfield": false, + }, + }, + "field2": []interface{}{ + map[string]interface{}{ + "stringsubfield": "idx1020", + "intsubfield": int64(1020), + "floatsubfield": float64(1.020), + "boolfield": true, + }, + map[string]interface{}{ + "stringsubfield": "idx1021", + "intsubfield": int64(1021), + "floatsubfield": float64(1.021), + "boolfield": false, + }, + }, + }, + map[string]interface{}{ + "field1": []interface{}{ + map[string]interface{}{ + "stringsubfield": "idx1110", + "intsubfield": int64(1110), + "floatsubfield": float64(1.110), + "boolfield": true, + }, + map[string]interface{}{ + "stringsubfield": "idx1111", + "intsubfield": int64(1111), + "floatsubfield": float64(1.111), + "boolfield": false, + }, + }, + "field2": []interface{}{ + map[string]interface{}{ + "stringsubfield": "idx1120", + "intsubfield": int64(1120), + "floatsubfield": float64(1.1120), + "boolfield": true, + }, + map[string]interface{}{ + "stringsubfield": "idx1121", + "intsubfield": int64(1121), + "floatsubfield": float64(1.1121), + "boolfield": false, + }, + }, + }, + }, + } +} + +func TestBasicYamlOperationFromMap(t *testing.T) { + bytes, err := yaml.Marshal(makeBigMap()) + if err != nil { + t.Fatalf("unexpected yaml.Marshal err: %v", err) + } + if string(bytes) != bigMapYaml { + t.Fatalf("unexpected string equality") + } + rNode, err := kyaml.Parse(string(bytes)) + if err != nil { + t.Fatalf("unexpected yaml.Marshal err: %v", err) + } + rNodeString := rNode.MustString() + // The result from MustString has more indentation + // than bigMapYaml. + rNodeStrings := strings.Split(rNodeString, "\n") + bigMapStrings := strings.Split(bigMapYaml, "\n") + if len(rNodeStrings) != len(bigMapStrings) { + t.Fatalf("line count mismatch") + } + for i := range rNodeStrings { + s1 := strings.TrimSpace(rNodeStrings[i]) + s2 := strings.TrimSpace(bigMapStrings[i]) + if s1 != s2 { + t.Fatalf("expected '%s'=='%s'", s1, s2) + } + } +} + +func TestRoundTripJSON(t *testing.T) { + wn := NewWNode() + err := wn.UnmarshalJSON([]byte(deploymentLittleJson)) + if err != nil { + t.Fatalf("unexpected UnmarshalJSON err: %v", err) + } + data, err := wn.MarshalJSON() + if err != nil { + t.Fatalf("unexpected MarshalJSON err: %v", err) + } + actual := string(data) + if actual != deploymentLittleJson { + t.Fatalf("expected %s, got %s", deploymentLittleJson, actual) + } +} + +func TestGettingFields(t *testing.T) { + wn := NewWNode() + err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)) + if err != nil { + t.Fatalf("unexpected unmarshaljson err: %v", err) + } + gvk := wn.GetGvk() + expected := "apps" + actual := gvk.Group + if expected != actual { + t.Fatalf("expected '%s', got '%s'", expected, actual) + } + expected = "v1" + actual = gvk.Version + if expected != actual { + t.Fatalf("expected '%s', got '%s'", expected, actual) + } + expected = "Deployment" + actual = gvk.Kind + if expected != actual { + t.Fatalf("expected '%s', got '%s'", expected, actual) + } + actual = wn.GetKind() + if expected != actual { + t.Fatalf("expected '%s', got '%s'", expected, actual) + } + expected = "homer" + actual = wn.GetName() + if expected != actual { + t.Fatalf("expected '%s', got '%s'", expected, actual) + } + actualMap := wn.GetLabels() + v, ok := actualMap["fruit"] + if !ok || v != "apple" { + t.Fatalf("unexpected labels '%v'", actualMap) + } + actualMap = wn.GetAnnotations() + v, ok = actualMap["greeting"] + if !ok || v != "Take me to your leader." { + t.Fatalf("unexpected annotations '%v'", actualMap) + } +} diff --git a/api/k8sdeps/validator/kustvalidator.go b/api/k8sdeps/validator/kustvalidator.go index 7ac71ecea..65147320d 100644 --- a/api/k8sdeps/validator/kustvalidator.go +++ b/api/k8sdeps/validator/kustvalidator.go @@ -14,11 +14,14 @@ import ( v1validation "k8s.io/apimachinery/pkg/apis/meta/v1/validation" "k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation/field" + "sigs.k8s.io/kustomize/api/ifc" ) // KustValidator validates Labels and annotations by apimachinery type KustValidator struct{} +var _ ifc.Validator = (*KustValidator)(nil) + // NewKustValidator returns a KustValidator object func NewKustValidator() *KustValidator { return &KustValidator{} diff --git a/api/krusty/internal/provider/depprovider.go b/api/krusty/internal/provider/depprovider.go new file mode 100644 index 000000000..242cfdc21 --- /dev/null +++ b/api/krusty/internal/provider/depprovider.go @@ -0,0 +1,183 @@ +// Copyright 2020 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package provider + +import ( + "sigs.k8s.io/kustomize/api/ifc" + "sigs.k8s.io/kustomize/api/internal/k8sdeps/merge" + kmerge "sigs.k8s.io/kustomize/api/internal/merge" + "sigs.k8s.io/kustomize/api/internal/validate" + "sigs.k8s.io/kustomize/api/internal/wrappy" + "sigs.k8s.io/kustomize/api/k8sdeps/kunstruct" + "sigs.k8s.io/kustomize/api/k8sdeps/validator" + "sigs.k8s.io/kustomize/api/resmap" + "sigs.k8s.io/kustomize/api/resource" +) + +// DepProvider is a dependency provider. +// +// The instances it returns are either +// - old implementations backed by k8sdeps code, +// - new implementations backed by kyaml code. +// +// History: +// +// kubectl depends on k8s.io code, and at the time of writing, so +// does kustomize. Code that imports k8s.io/api* cannot be imported +// back into k8s.io/*, yet kustomize appears inside k8s.io/kubectl. +// +// To allow kustomize to appear inside kubectl, yet still be developed +// outside kubectl, the kustomize code was divided into the following +// packages +// +// api/ +// k8sdeps/ (and internal/ks8deps/) +// ifc/ +// krusty/ +// everythingElse/ +// +// with the following rules: +// +// - Only k8sdeps/ may import k8s.io/api*. +// +// - Only krusty/ (and its internals) may import k8sdeps/. +// I.e., ifc/ and everythingElse/ must not +// import k8sdeps/ or k8s.io/api*. +// +// - Code in krusty/ may use code in k8sdeps/ to create +// objects then inject said objects into +// everythingElse/ behind dependency neutral interfaces. +// +// The idea was to periodically copy, not import, the large k8sdeps/ +// tree (plus a snippet from krusty/kustomizer.go) into the kubectl +// codebase via a large PR, and have kubectl depend on the rest via +// normal importing. +// +// Over 2019, however, kubectl underwent large changes including +// a switch to Go modules, and a concerted attempt to extract kubectl +// from the k8s repo. This made large kustomize integration PRs too +// intrusive to review. +// +// In 2020, kubectl is based on Go modules, and almost entirely +// extracted from the k8s.io repositories, and further the kyaml +// library has a appeared as a viable replacement to k8s.io/api* +// KRM manipulation code. +// +// The new plan is to eliminate k8sdeps/ entirely, along with its +// k8s.io/api* dependence, allowing kustomize code to be imported +// into kubectl via normal Go module imports. Then the kustomize API +// code can then move into the github.com/kubernetes-sigs/cli-utils +// repo. The kustomize CLI in github.com/kubernetes-sigs/kustomize +// and the kubectl CLI can then both depend on the kustomize API. +// +// So, all code that depends on k8sdeps must go behind interfaces, +// and kustomize must be factored to choose the implementation. +// +// That problem has been reduced to three interfaces, each having +// two implementations. (1) is k8sdeps-based, (2) is kyaml-based. +// +// - ifc.Kunstructured +// +// 1) api/k8sdeps/kunstruct.UnstructAdapter +// +// This adapts structs in +// k8s.io/apimachinery/pkg/apis/meta/v1/unstructured +// to ifc.Kunstructured. +// +// 2) api/wrappy.WNode +// +// This adapts sigs.k8s.io/kustomize/kyaml/yaml.RNode +// to ifc.Unstructured. +// +// At time of writing, implementation started. +// Further reducing the size of ifc.Kunstructed +// would really reduce the work +// (e.g. drop Vars, drop ReplacementTranformer). +// +// - resmap.Merginator +// +// 1) api/internal/k8sdeps/merge.Merginator +// +// Uses k8s.io/apimachinery/pkg/util/strategicpatch, +// apimachinery/pkg/util/mergepatch, etc. to merge +// resource.Resource instances. +// +// 2) api/internal/merge.Merginator +// +// At time of writing, this is unimplemented. +// +// - ifc.Validator +// +// 1) api/k8sdeps/validator.KustValidator +// +// Uses k8s.io/apimachinery/pkg/api/validation and +// friends to validate strings. +// +// 2) api/internal/validate.FieldValidator +// +// At time of writing, this is a do-nothing +// validator as it's not critical to kustomize function. +// +// Proposed plan: +// [ ] Ship kustomize with the ability to switch from 1 to 2 via +// an --enable_kyaml flag. +// [ ] Make --enable_kyaml true by default. +// [ ] When 2 is not noticeably more buggy than 1, delete 1. +// I.e. delete k8sdeps/, transitively deleting all k8s.io/api* deps. +// This DepProvider should be left in place to retain these +// comments, but it will have only one choice. +// [ ] The way is now clear to reintegrate into kubectl. +// This should be done ASAP; the last step is cleanup. +// [ ] With only one impl of Kunstructure remaining, that interface +// and WNode can be deleted, along with this DepProvider. +// The other two interfaces could be dropped too. +// +// When the above is done, kustomize will use yaml.RNode and/or +// KRM Config Functions directly and exclusively. +// If you're reading this, plan not done. +// +type DepProvider struct { + resourceFactory *resource.Factory + merginator resmap.Merginator + fieldValidator ifc.Validator +} + +func makeK8sdepBasedInstances() *DepProvider { + kf := kunstruct.NewKunstructuredFactoryImpl() + rf := resource.NewFactory(kf) + return &DepProvider{ + resourceFactory: rf, + merginator: merge.NewMerginator(rf), + fieldValidator: validator.NewKustValidator(), + } +} + +func makeKyamlBasedInstances() *DepProvider { + kf := &wrappy.WNodeFactory{} + rf := resource.NewFactory(kf) + return &DepProvider{ + resourceFactory: rf, + merginator: kmerge.NewMerginator(rf), + fieldValidator: validate.NewFieldValidator(), + } +} + +func NewDepProvider(useKyaml bool) *DepProvider { + if useKyaml { + return makeKyamlBasedInstances() + } + return makeK8sdepBasedInstances() +} + +func (dp *DepProvider) GetResourceFactory() *resource.Factory { + return dp.resourceFactory +} + +func (dp *DepProvider) GetMerginator() resmap.Merginator { + return dp.merginator +} + +func (dp *DepProvider) GetFieldValidator() ifc.Validator { + return dp.fieldValidator +} diff --git a/api/krusty/kustomizer.go b/api/krusty/kustomizer.go index 07fbc9145..9dad1beb9 100644 --- a/api/krusty/kustomizer.go +++ b/api/krusty/kustomizer.go @@ -8,16 +8,13 @@ import ( "sigs.k8s.io/kustomize/api/builtins" "sigs.k8s.io/kustomize/api/filesys" - "sigs.k8s.io/kustomize/api/internal/k8sdeps/merge" pLdr "sigs.k8s.io/kustomize/api/internal/plugins/loader" "sigs.k8s.io/kustomize/api/internal/target" - "sigs.k8s.io/kustomize/api/k8sdeps/kunstruct" - "sigs.k8s.io/kustomize/api/k8sdeps/validator" "sigs.k8s.io/kustomize/api/konfig" + "sigs.k8s.io/kustomize/api/krusty/internal/provider" fLdr "sigs.k8s.io/kustomize/api/loader" "sigs.k8s.io/kustomize/api/provenance" "sigs.k8s.io/kustomize/api/resmap" - "sigs.k8s.io/kustomize/api/resource" "sigs.k8s.io/kustomize/api/types" ) @@ -28,13 +25,18 @@ import ( // number of overlays and bases), then make a Kustomizer // injected with the given fileystem, then call Run. type Kustomizer struct { - fSys filesys.FileSystem - options *Options + fSys filesys.FileSystem + options *Options + depProvider *provider.DepProvider } // MakeKustomizer returns an instance of Kustomizer. func MakeKustomizer(fSys filesys.FileSystem, o *Options) *Kustomizer { - return &Kustomizer{fSys: fSys, options: o} + return &Kustomizer{ + fSys: fSys, + options: o, + depProvider: provider.NewDepProvider(o.UseKyaml), + } } // Run performs a kustomization. @@ -49,11 +51,9 @@ func MakeKustomizer(fSys filesys.FileSystem, o *Options) *Kustomizer { // on any number of internal paths (e.g. the filesystem may contain // multiple overlays, and Run can be called on each of them). func (b *Kustomizer) Run(path string) (resmap.ResMap, error) { - resourceFactory := resource.NewFactory( - kunstruct.NewKunstructuredFactoryImpl()) resmapFactory := resmap.NewFactory( - resourceFactory, - merge.NewMerginator(resourceFactory)) + b.depProvider.GetResourceFactory(), + b.depProvider.GetMerginator()) lr := fLdr.RestrictionNone if b.options.LoadRestrictions == types.LoadRestrictionsRootOnly { lr = fLdr.RestrictionRootOnly @@ -65,7 +65,7 @@ func (b *Kustomizer) Run(path string) (resmap.ResMap, error) { defer ldr.Cleanup() kt := target.NewKustTarget( ldr, - validator.NewKustValidator(), + b.depProvider.GetFieldValidator(), resmapFactory, pLdr.NewLoader(b.options.PluginConfig, resmapFactory), ) diff --git a/api/krusty/options.go b/api/krusty/options.go index 44d61fc87..041ca729d 100644 --- a/api/krusty/options.go +++ b/api/krusty/options.go @@ -32,6 +32,10 @@ type Options struct { // Options related to kustomize plugins. PluginConfig *types.PluginConfig + + // When true, use kyaml/ packages to manipulate KRM yaml. + // When false, use k8sdeps/ instead (uses k8s.io/api* packages). + UseKyaml bool } // MakeDefaultOptions returns a default instance of Options. @@ -42,5 +46,6 @@ func MakeDefaultOptions() *Options { LoadRestrictions: types.LoadRestrictionsRootOnly, DoPrune: false, PluginConfig: konfig.DisabledPluginConfig(), + UseKyaml: false, } } diff --git a/kustomize/internal/commands/build/build.go b/kustomize/internal/commands/build/build.go index 7f9f323db..55da661cb 100644 --- a/kustomize/internal/commands/build/build.go +++ b/kustomize/internal/commands/build/build.go @@ -95,6 +95,7 @@ func NewCmdBuild(out io.Writer) *cobra.Command { addFlagEnablePlugins(cmd.Flags()) addFlagReorderOutput(cmd.Flags()) addFlagEnableManagedbyLabel(cmd.Flags()) + addFlagEnableKyaml(cmd.Flags()) return cmd } @@ -132,6 +133,7 @@ func (o *Options) makeOptions() *krusty.Options { opts.PluginConfig = c } opts.AddManagedbyLabel = isManagedbyLabelEnabled() + opts.UseKyaml = flagEnableKyamlValue return opts } diff --git a/kustomize/internal/commands/build/flagEnableKyaml.go b/kustomize/internal/commands/build/flagEnableKyaml.go new file mode 100644 index 000000000..c73f81dc2 --- /dev/null +++ b/kustomize/internal/commands/build/flagEnableKyaml.go @@ -0,0 +1,21 @@ +// Copyright 2019 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package build + +import ( + "github.com/spf13/pflag" +) + +var ( + flagEnableKyamlValue = false +) + +func addFlagEnableKyaml(set *pflag.FlagSet) { + set.BoolVar( + &flagEnableKyamlValue, + "enable_kyaml", // flag name + false, // default value + "enable dependence on kyaml instead of k8sdeps.", // help + ) +} From fa15242719d359195421637d7bd7844a0c4607cd Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Mon, 24 Aug 2020 11:40:57 -0700 Subject: [PATCH 20/23] refactor network name in kyaml container --- kyaml/fn/runtime/container/container.go | 23 +++++++++++++----- kyaml/fn/runtime/container/container_test.go | 24 +++++++++---------- kyaml/fn/runtime/runtimeutil/functiontypes.go | 24 +++++++++++++++++-- kyaml/runfn/runfn.go | 21 +++++++--------- kyaml/runfn/runfn_test.go | 6 +++-- 5 files changed, 63 insertions(+), 35 deletions(-) diff --git a/kyaml/fn/runtime/container/container.go b/kyaml/fn/runtime/container/container.go index 9f34f1512..3975e003b 100644 --- a/kyaml/fn/runtime/container/container.go +++ b/kyaml/fn/runtime/container/container.go @@ -161,15 +161,10 @@ func (c *Filter) getCommand() (string, []string) { // run the container using docker. this is simpler than using the docker // libraries, and ensures things like auth work the same as if the container // was run from the cli. - - network := "none" - if c.Network.Name != "" { - network = c.Network.Name - } args := []string{"run", "--rm", // delete the container afterward "-i", "-a", "STDIN", "-a", "STDOUT", "-a", "STDERR", // attach stdin, stdout, stderr - "--network", network, + "--network", c.ContainerSpec.Network.Name.String(), // added security options "--user", c.User.String(), @@ -198,3 +193,19 @@ func (c *Filter) getCommand() (string, []string) { a := append(args, c.Image) return "docker", a } + +// NewContainer returns a new container instance +func NewContainer(spec runtimeutil.ContainerSpec) Filter { + f := Filter{ContainerSpec: spec} + // default user is nobody + if f.ContainerSpec.User.IsEmpty() { + f.ContainerSpec.User = runtimeutil.UserNobody + } + + // default network name is none + if f.ContainerSpec.Network.Name.IsEmpty() { + f.ContainerSpec.Network.Name = runtimeutil.NetworkNameNone + } + + return f +} diff --git a/kyaml/fn/runtime/container/container_test.go b/kyaml/fn/runtime/container/container_test.go index bd6f0e6b3..c0833f5b2 100644 --- a/kyaml/fn/runtime/container/container_test.go +++ b/kyaml/fn/runtime/container/container_test.go @@ -38,12 +38,12 @@ metadata: "--user", "nobody", "--security-opt=no-new-privileges", }, - instance: Filter{ - ContainerSpec: runtimeutil.ContainerSpec{ + instance: NewContainer( + runtimeutil.ContainerSpec{ Image: "example.com:version", User: "nobody", }, - }, + ), }, { @@ -61,15 +61,15 @@ metadata: "--user", "nobody", "--security-opt=no-new-privileges", }, - instance: Filter{ - ContainerSpec: runtimeutil.ContainerSpec{ + instance: NewContainer( + runtimeutil.ContainerSpec{ Image: "example.com:version", Network: runtimeutil.ContainerNetwork{ Name: "test-1", }, User: "nobody", }, - }, + ), }, { @@ -91,8 +91,8 @@ metadata: "--mount", fmt.Sprintf("type=%s,source=%s,target=%s,readonly", "volume", "myvol", "/local/"), "--mount", fmt.Sprintf("type=%s,source=%s,target=%s,readonly", "tmpfs", "", "/local/"), }, - instance: Filter{ - ContainerSpec: runtimeutil.ContainerSpec{ + instance: NewContainer( + runtimeutil.ContainerSpec{ Image: "example.com:version", StorageMounts: []runtimeutil.StorageMount{ {MountType: "bind", Src: "/mount/path", DstPath: "/local/"}, @@ -102,7 +102,7 @@ metadata: }, User: "nobody", }, - }, + ), }, { name: "root user", @@ -119,12 +119,12 @@ metadata: "--user", "root", "--security-opt=no-new-privileges", }, - instance: Filter{ - ContainerSpec: runtimeutil.ContainerSpec{ + instance: NewContainer( + runtimeutil.ContainerSpec{ Image: "example.com:version", User: "root", }, - }, + ), }, } diff --git a/kyaml/fn/runtime/runtimeutil/functiontypes.go b/kyaml/fn/runtime/runtimeutil/functiontypes.go index 7eb1c7056..3eac14399 100644 --- a/kyaml/fn/runtime/runtimeutil/functiontypes.go +++ b/kyaml/fn/runtime/runtimeutil/functiontypes.go @@ -33,6 +33,26 @@ const ( UserNobody ContainerUser = "nobody" ) +// ContainerNetworkName is a type for network name used in container +type ContainerNetworkName string + +func (n *ContainerNetworkName) String() string { + return string(*n) +} + +func (n *ContainerNetworkName) IsEmpty() bool { + return string(*n) == "" +} + +func (n *ContainerNetworkName) Set(s string) { + *n = ContainerNetworkName(s) +} + +const ( + NetworkNameNone ContainerNetworkName = "none" + NetworkNameEmpty ContainerNetworkName = "" +) + // FunctionSpec defines a spec for running a function type FunctionSpec struct { DeferFailure bool `json:"deferFailure,omitempty" yaml:"deferFailure,omitempty"` @@ -75,7 +95,7 @@ type ContainerNetwork struct { Required bool `json:"required,omitempty" yaml:"required,omitempty"` // Name is the name of the network to use from a container - Name string `json:"name,omitempty" yaml:"name,omitempty"` + Name ContainerNetworkName `json:"name,omitempty" yaml:"name,omitempty"` } // StarlarkSpec defines how to run a function as a starlark program @@ -128,7 +148,7 @@ func GetFunctionSpec(n *yaml.RNode) *FunctionSpec { } if fn := getFunctionSpecFromAnnotation(n, meta); fn != nil { - fn.Container.Network.Name = "" + fn.Container.Network.Name = NetworkNameEmpty fn.StorageMounts = []StorageMount{} return fn } diff --git a/kyaml/runfn/runfn.go b/kyaml/runfn/runfn.go index c757967e2..59f44a170 100644 --- a/kyaml/runfn/runfn.go +++ b/kyaml/runfn/runfn.go @@ -280,16 +280,12 @@ func (r RunFns) getFunctionFilters(global bool, fns ...*yaml.RNode) ( // TODO(eddiezane): Provide error info about which function needs the network return fltrs, errors.Errorf("network required but not enabled with --network") } - spec.Container.Network.Name = r.NetworkName + spec.Container.Network.Name.Set(r.NetworkName) } // command line username has higher priority if r.User != "" { spec.Container.User = r.User } - // default user is nobody - if spec.Container.User.IsEmpty() { - spec.Container.User = runtimeutil.UserNobody - } c, err := r.functionFilterProvider(*spec, api) if err != nil { @@ -393,14 +389,13 @@ func (r *RunFns) ffp(spec runtimeutil.FunctionSpec, api *yaml.RNode) (kio.Filter } if !r.DisableContainers && spec.Container.Image != "" { // TODO: Add a test for this behavior - cf := &container.Filter{ - ContainerSpec: runtimeutil.ContainerSpec{ - Image: spec.Container.Image, - Network: spec.Container.Network, - StorageMounts: r.StorageMounts, - User: spec.Container.User, - }, - } + c := container.NewContainer(runtimeutil.ContainerSpec{ + Image: spec.Container.Image, + Network: spec.Container.Network, + StorageMounts: r.StorageMounts, + User: spec.Container.User, + }) + cf := &c cf.Exec.FunctionConfig = api cf.Exec.GlobalScope = r.GlobalScope cf.Exec.ResultsFile = resultsFile diff --git a/kyaml/runfn/runfn_test.go b/kyaml/runfn/runfn_test.go index 8599609fc..55cb2d429 100644 --- a/kyaml/runfn/runfn_test.go +++ b/kyaml/runfn/runfn_test.go @@ -60,7 +60,8 @@ kind: return } filter, _ := instance.functionFilterProvider(spec, api) - cf := &container.Filter{ContainerSpec: runtimeutil.ContainerSpec{Image: "example.com:version"}} + c := container.NewContainer(runtimeutil.ContainerSpec{Image: "example.com:version"}) + cf := &c cf.Exec.FunctionConfig = api assert.Equal(t, cf, filter) } @@ -90,7 +91,8 @@ kind: return } filter, _ := instance.functionFilterProvider(spec, api) - cf := &container.Filter{ContainerSpec: runtimeutil.ContainerSpec{Image: "example.com:version"}} + c := container.NewContainer(runtimeutil.ContainerSpec{Image: "example.com:version"}) + cf := &c cf.Exec.FunctionConfig = api cf.Exec.GlobalScope = true assert.Equal(t, cf, filter) From 0c8e033c966eb360fde9a77c2ce0dfb5d8f56bed Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Mon, 24 Aug 2020 21:21:30 +0000 Subject: [PATCH 21/23] Add logging for module release notes. --- releasing/cloudbuild.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/releasing/cloudbuild.sh b/releasing/cloudbuild.sh index ceab40a3b..ed115a2bc 100755 --- a/releasing/cloudbuild.sh +++ b/releasing/cloudbuild.sh @@ -41,11 +41,13 @@ lastCommitHash=$( # Generate the changelog for this release # using commit hashes and commit messages. -changeLog=$(mktemp) +changeLogFile=$(mktemp) git log $lastCommitHash.. \ --pretty=oneline \ --abbrev-commit --no-decorate --no-color \ - -- $module > $changeLog + -- $module > $changeLogFile +echo "Release notes:" +cat $changeLogFile # Take everything after the last slash. # This should be something like "v1.2.3". @@ -126,6 +128,6 @@ cat $configFile /bin/goreleaser release \ --config=$configFile \ + --release-notes=$changeLogFile \ --rm-dist \ - --skip-validate $remainingArgs \ - --release-notes $changeLog + --skip-validate $remainingArgs From 43980f8586869f8839e79ac99bb1b8927ad199ac Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Mon, 24 Aug 2020 21:39:51 +0000 Subject: [PATCH 22/23] Remove changelog directive in yaml. --- releasing/cloudbuild.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/releasing/cloudbuild.sh b/releasing/cloudbuild.sh index ed115a2bc..b39436803 100755 --- a/releasing/cloudbuild.sh +++ b/releasing/cloudbuild.sh @@ -100,15 +100,6 @@ builds: goarch: - amd64 -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' - - Merge pull request - - Merge branch - checksum: name_template: 'checksums.txt' From 893c99da1c4175a496f87ac233aa27d933c823d8 Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Mon, 24 Aug 2020 16:27:55 -0700 Subject: [PATCH 23/23] code review --- kyaml/fn/runtime/container/container.go | 6 +++--- kyaml/fn/runtime/runtimeutil/functiontypes.go | 12 ------------ kyaml/runfn/runfn.go | 2 +- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/kyaml/fn/runtime/container/container.go b/kyaml/fn/runtime/container/container.go index 3975e003b..8e9bf52f8 100644 --- a/kyaml/fn/runtime/container/container.go +++ b/kyaml/fn/runtime/container/container.go @@ -164,7 +164,7 @@ func (c *Filter) getCommand() (string, []string) { args := []string{"run", "--rm", // delete the container afterward "-i", "-a", "STDIN", "-a", "STDOUT", "-a", "STDERR", // attach stdin, stdout, stderr - "--network", c.ContainerSpec.Network.Name.String(), + "--network", string(c.ContainerSpec.Network.Name), // added security options "--user", c.User.String(), @@ -194,7 +194,7 @@ func (c *Filter) getCommand() (string, []string) { return "docker", a } -// NewContainer returns a new container instance +// NewContainer returns a new container filter func NewContainer(spec runtimeutil.ContainerSpec) Filter { f := Filter{ContainerSpec: spec} // default user is nobody @@ -203,7 +203,7 @@ func NewContainer(spec runtimeutil.ContainerSpec) Filter { } // default network name is none - if f.ContainerSpec.Network.Name.IsEmpty() { + if f.ContainerSpec.Network.Name == "" { f.ContainerSpec.Network.Name = runtimeutil.NetworkNameNone } diff --git a/kyaml/fn/runtime/runtimeutil/functiontypes.go b/kyaml/fn/runtime/runtimeutil/functiontypes.go index 3eac14399..869d27d20 100644 --- a/kyaml/fn/runtime/runtimeutil/functiontypes.go +++ b/kyaml/fn/runtime/runtimeutil/functiontypes.go @@ -36,18 +36,6 @@ const ( // ContainerNetworkName is a type for network name used in container type ContainerNetworkName string -func (n *ContainerNetworkName) String() string { - return string(*n) -} - -func (n *ContainerNetworkName) IsEmpty() bool { - return string(*n) == "" -} - -func (n *ContainerNetworkName) Set(s string) { - *n = ContainerNetworkName(s) -} - const ( NetworkNameNone ContainerNetworkName = "none" NetworkNameEmpty ContainerNetworkName = "" diff --git a/kyaml/runfn/runfn.go b/kyaml/runfn/runfn.go index 59f44a170..4b743df2b 100644 --- a/kyaml/runfn/runfn.go +++ b/kyaml/runfn/runfn.go @@ -280,7 +280,7 @@ func (r RunFns) getFunctionFilters(global bool, fns ...*yaml.RNode) ( // TODO(eddiezane): Provide error info about which function needs the network return fltrs, errors.Errorf("network required but not enabled with --network") } - spec.Container.Network.Name.Set(r.NetworkName) + spec.Container.Network.Name = runtimeutil.ContainerNetworkName(r.NetworkName) } // command line username has higher priority if r.User != "" {