diff --git a/cmd/config/internal/commands/annotate.go b/cmd/config/internal/commands/annotate.go index 93db621db8e..8e5ec2384ab 100644 --- a/cmd/config/internal/commands/annotate.go +++ b/cmd/config/internal/commands/annotate.go @@ -27,6 +27,9 @@ func NewAnnotateRunner(parent string) *AnnotateRunner { Long: commands.AnnotateLong, Example: commands.AnnotateExamples, RunE: r.runE, + Deprecated: + "use the `commonAnnotations` field in your kustomization file\n" + + "or a KRM function such as https://catalog.kpt.dev/set-annotations/v0.1/ instead.", } runner.FixDocs(parent, c) r.Command = c diff --git a/cmd/config/internal/commands/annotate_test.go b/cmd/config/internal/commands/annotate_test.go index ef855ae7070..f897e95f57f 100644 --- a/cmd/config/internal/commands/annotate_test.go +++ b/cmd/config/internal/commands/annotate_test.go @@ -559,7 +559,7 @@ added annotations in the package expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1) expectedNormalized := strings.Replace(expected, "\\", "/", -1) - if !assert.Equal(t, expectedNormalized, actualNormalized) { + if !assert.Contains(t, actualNormalized, expectedNormalized) { t.FailNow() } }) diff --git a/cmd/config/internal/commands/cmdcreatesetter.go b/cmd/config/internal/commands/cmdcreatesetter.go index eca08277501..59318d95b86 100644 --- a/cmd/config/internal/commands/cmdcreatesetter.go +++ b/cmd/config/internal/commands/cmdcreatesetter.go @@ -32,6 +32,8 @@ func NewCreateSetterRunner(parent string) *CreateSetterRunner { Example: commands.CreateSetterExamples, PreRunE: r.preRunE, RunE: r.runE, + Deprecated: "setter commands will no longer be available in kustomize v5.\n" + + "See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953.", } set.Flags().StringVar(&r.FieldValue, "value", "", "optional flag, alternative to specifying the value as an argument. e.g. used to specify values that start with '-'") diff --git a/cmd/config/internal/commands/cmdcreatesetter_test.go b/cmd/config/internal/commands/cmdcreatesetter_test.go index fbad6652927..6a0ffcd601a 100644 --- a/cmd/config/internal/commands/cmdcreatesetter_test.go +++ b/cmd/config/internal/commands/cmdcreatesetter_test.go @@ -869,7 +869,7 @@ setter with name "namespace" already exists, if you want to modify it, please de expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1) expectedNormalized := strings.Replace(expected, "\\", "/", -1) - if !assert.Equal(t, expectedNormalized, actualNormalized) { + if !assert.Contains(t, actualNormalized, expectedNormalized) { t.FailNow() } }) diff --git a/cmd/config/internal/commands/cmdcreatesubstitution.go b/cmd/config/internal/commands/cmdcreatesubstitution.go index 3532136a68d..bd03ea9c01a 100644 --- a/cmd/config/internal/commands/cmdcreatesubstitution.go +++ b/cmd/config/internal/commands/cmdcreatesubstitution.go @@ -23,6 +23,8 @@ func NewCreateSubstitutionRunner(parent string) *CreateSubstitutionRunner { Args: cobra.ExactArgs(2), PreRun: r.preRun, RunE: r.runE, + Deprecated: "imperative substitutions will no longer be available in kustomize v5.\n" + + "See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953.", } cs.Flags().StringVar(&r.CreateSubstitution.FieldName, "field", "", "name of the field to set -- e.g. --field image") diff --git a/cmd/config/internal/commands/cmdcreatesubstitution_test.go b/cmd/config/internal/commands/cmdcreatesubstitution_test.go index a868fd38be8..6754d7319ba 100644 --- a/cmd/config/internal/commands/cmdcreatesubstitution_test.go +++ b/cmd/config/internal/commands/cmdcreatesubstitution_test.go @@ -506,7 +506,7 @@ created substitution "image-tag"`, expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1) expectedNormalized := strings.Replace(expected, "\\", "/", -1) - if !assert.Equal(t, strings.TrimSpace(expectedNormalized), strings.TrimSpace(actualNormalized)) { + if !assert.Contains(t, strings.TrimSpace(actualNormalized), strings.TrimSpace(expectedNormalized), ) { t.FailNow() } }) diff --git a/cmd/config/internal/commands/cmdinit.go b/cmd/config/internal/commands/cmdinit.go index f8b4346588b..a1d79bc320b 100644 --- a/cmd/config/internal/commands/cmdinit.go +++ b/cmd/config/internal/commands/cmdinit.go @@ -26,6 +26,8 @@ func GetInitRunner(name string) *InitRunner { Long: commands.InitLong, Example: commands.InitExamples, RunE: r.runE, + Deprecated: "setter commands and substitutions will no longer be available in kustomize v5.\n" + + "See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953.", } runner.FixDocs(name, c) r.Command = c diff --git a/cmd/config/internal/commands/cmdlistsetters.go b/cmd/config/internal/commands/cmdlistsetters.go index 9f2bb0fe8fb..623374c2a1b 100644 --- a/cmd/config/internal/commands/cmdlistsetters.go +++ b/cmd/config/internal/commands/cmdlistsetters.go @@ -31,6 +31,8 @@ func NewListSettersRunner(parent string) *ListSettersRunner { Example: commands.ListSettersExamples, PreRunE: r.preRunE, RunE: r.runE, + Deprecated: "setter commands will no longer be available in kustomize v5.\n" + + "See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953.", } c.Flags().BoolVar(&r.Markdown, "markdown", false, "output as github markdown") diff --git a/cmd/config/internal/commands/cmdlistsetters_test.go b/cmd/config/internal/commands/cmdlistsetters_test.go index 040ede6cd6e..6248399d0aa 100644 --- a/cmd/config/internal/commands/cmdlistsetters_test.go +++ b/cmd/config/internal/commands/cmdlistsetters_test.go @@ -525,7 +525,7 @@ test/testdata/dataset-with-setters/mysql/ // normalize path format for windows actualNormalized := strings.Replace(actual.String(), "\\", "/", -1) - if !assert.Equal(t, strings.TrimSpace(test.expected), strings.TrimSpace(actualNormalized)) { + if !assert.Contains(t, strings.TrimSpace(actualNormalized), strings.TrimSpace(test.expected)) { t.FailNow() } }) diff --git a/cmd/config/internal/commands/cmdset.go b/cmd/config/internal/commands/cmdset.go index 90c834d4db9..1d033f02ff2 100644 --- a/cmd/config/internal/commands/cmdset.go +++ b/cmd/config/internal/commands/cmdset.go @@ -27,6 +27,8 @@ func NewSetRunner(parent string) *SetRunner { Example: commands.SetExamples, PreRunE: r.preRunE, RunE: r.runE, + Deprecated: "setter commands will no longer be available in kustomize v5.\n" + + "See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953.", } runner.FixDocs(parent, c) r.Command = c diff --git a/cmd/config/internal/commands/cmdset_test.go b/cmd/config/internal/commands/cmdset_test.go index 90ef0509393..9548f76d6e6 100644 --- a/cmd/config/internal/commands/cmdset_test.go +++ b/cmd/config/internal/commands/cmdset_test.go @@ -1137,7 +1137,7 @@ set 1 field(s) of setter "namespace" to value "otherspace" expectedNormalized := strings.Replace( strings.Replace(expected, "\\", "/", -1), "//", "/", -1) - if !assert.Equal(t, strings.TrimSpace(expectedNormalized), strings.TrimSpace(actualNormalized)) { + if !assert.Contains(t, strings.TrimSpace(actualNormalized), strings.TrimSpace(expectedNormalized)) { t.FailNow() } }) diff --git a/cmd/config/internal/commands/fmt.go b/cmd/config/internal/commands/fmt.go index c820332b7e5..2ab3d4eb209 100644 --- a/cmd/config/internal/commands/fmt.go +++ b/cmd/config/internal/commands/fmt.go @@ -25,6 +25,8 @@ func GetFmtRunner(name string) *FmtRunner { Example: commands.FmtExamples, RunE: r.runE, PreRunE: r.preRunE, + Deprecated: "imperative formatting will no longer be available in kustomize v5.\n" + + "Declare a formatting transformer in your kustomization instead.", } runner.FixDocs(name, c) c.Flags().StringVar(&r.FilenamePattern, "pattern", filters.DefaultFilenamePattern, diff --git a/cmd/config/internal/commands/fmt_test.go b/cmd/config/internal/commands/fmt_test.go index 9aba4fcf90b..6baa8fcf7c0 100644 --- a/cmd/config/internal/commands/fmt_test.go +++ b/cmd/config/internal/commands/fmt_test.go @@ -78,7 +78,7 @@ func TestFmtCommand_stdin(t *testing.T) { assert.NoError(t, err) // verify the output - assert.Equal(t, string(testyaml.FormattedYaml1), out.String()) + assert.Contains(t, out.String(), string(testyaml.FormattedYaml1)) } // TestCmd_filesAndstdin verifies that if both files and stdin input are provided, only @@ -238,7 +238,7 @@ formatted resource files in the package expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1) expectedNormalized := strings.Replace(expected, "\\", "/", -1) - if !assert.Equal(t, strings.TrimSpace(expectedNormalized), strings.TrimSpace(actualNormalized)) { + if !assert.Contains(t, strings.TrimSpace(actualNormalized), strings.TrimSpace(expectedNormalized), ) { t.FailNow() } }) diff --git a/cmd/config/internal/commands/init_test.go b/cmd/config/internal/commands/init_test.go index e49649712b4..f4a7dea50c3 100644 --- a/cmd/config/internal/commands/init_test.go +++ b/cmd/config/internal/commands/init_test.go @@ -43,7 +43,9 @@ kind: Krmfile t.FailNow() } - if !assert.Equal(t, "", b.String()) { + if !assert.Equal(t, `Command "init" is deprecated, setter commands and substitutions will no longer be available in kustomize v5. +See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953. +`, b.String()) { t.FailNow() } } @@ -78,7 +80,9 @@ kind: Krmfile t.FailNow() } - if !assert.Equal(t, "", b.String()) { + if !assert.Equal(t, `Command "init" is deprecated, setter commands and substitutions will no longer be available in kustomize v5. +See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953. +`, b.String()) { t.FailNow() } } diff --git a/cmd/config/internal/commands/merge.go b/cmd/config/internal/commands/merge.go index dd65b50e992..37cc07ca302 100644 --- a/cmd/config/internal/commands/merge.go +++ b/cmd/config/internal/commands/merge.go @@ -19,6 +19,8 @@ func GetMergeRunner(name string) *MergeRunner { Long: commands.MergeLong, Example: commands.MergeExamples, RunE: r.runE, + Deprecated: "this will no longer be available in kustomize v5.\n" + + "See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953.", } runner.FixDocs(name, c) r.Command = c diff --git a/cmd/config/internal/commands/merge3.go b/cmd/config/internal/commands/merge3.go index 5c48efc4e85..a01bd981222 100644 --- a/cmd/config/internal/commands/merge3.go +++ b/cmd/config/internal/commands/merge3.go @@ -18,6 +18,8 @@ func GetMerge3Runner(name string) *Merge3Runner { Long: commands.Merge3Long, Example: commands.Merge3Examples, RunE: r.runE, + Deprecated: "this will no longer be available in kustomize v5.\n" + + "See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953.", } runner.FixDocs(name, c) c.Flags().StringVar(&r.ancestor, "ancestor", "",