deprecate some cfg commands

This commit is contained in:
Natasha Sarkar
2021-07-08 11:09:16 -07:00
parent f4e6816338
commit 16dcc98cff
16 changed files with 31 additions and 9 deletions

View File

@@ -27,6 +27,8 @@ func NewAnnotateRunner(parent string) *AnnotateRunner {
Long: commands.AnnotateLong, Long: commands.AnnotateLong,
Example: commands.AnnotateExamples, Example: commands.AnnotateExamples,
RunE: r.runE, RunE: r.runE,
Deprecated:
"use the `commonAnnotations` field in your kustomization file.",
} }
runner.FixDocs(parent, c) runner.FixDocs(parent, c)
r.Command = c r.Command = c

View File

@@ -559,7 +559,7 @@ added annotations in the package
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1) expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
expectedNormalized := strings.Replace(expected, "\\", "/", -1) expectedNormalized := strings.Replace(expected, "\\", "/", -1)
if !assert.Equal(t, expectedNormalized, actualNormalized) { if !assert.Contains(t, actualNormalized, expectedNormalized) {
t.FailNow() t.FailNow()
} }
}) })

View File

@@ -32,6 +32,8 @@ func NewCreateSetterRunner(parent string) *CreateSetterRunner {
Example: commands.CreateSetterExamples, Example: commands.CreateSetterExamples,
PreRunE: r.preRunE, PreRunE: r.preRunE,
RunE: r.runE, 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", "", 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 '-'") "optional flag, alternative to specifying the value as an argument. e.g. used to specify values that start with '-'")

View File

@@ -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) expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
expectedNormalized := strings.Replace(expected, "\\", "/", -1) expectedNormalized := strings.Replace(expected, "\\", "/", -1)
if !assert.Equal(t, expectedNormalized, actualNormalized) { if !assert.Contains(t, actualNormalized, expectedNormalized) {
t.FailNow() t.FailNow()
} }
}) })

View File

@@ -23,6 +23,8 @@ func NewCreateSubstitutionRunner(parent string) *CreateSubstitutionRunner {
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
PreRun: r.preRun, PreRun: r.preRun,
RunE: r.runE, 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", "", cs.Flags().StringVar(&r.CreateSubstitution.FieldName, "field", "",
"name of the field to set -- e.g. --field image") "name of the field to set -- e.g. --field image")

View File

@@ -506,7 +506,7 @@ created substitution "image-tag"`,
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1) expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
expectedNormalized := strings.Replace(expected, "\\", "/", -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() t.FailNow()
} }
}) })

View File

@@ -26,6 +26,8 @@ func GetInitRunner(name string) *InitRunner {
Long: commands.InitLong, Long: commands.InitLong,
Example: commands.InitExamples, Example: commands.InitExamples,
RunE: r.runE, 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) runner.FixDocs(name, c)
r.Command = c r.Command = c

View File

@@ -31,6 +31,8 @@ func NewListSettersRunner(parent string) *ListSettersRunner {
Example: commands.ListSettersExamples, Example: commands.ListSettersExamples,
PreRunE: r.preRunE, PreRunE: r.preRunE,
RunE: r.runE, 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, c.Flags().BoolVar(&r.Markdown, "markdown", false,
"output as github markdown") "output as github markdown")

View File

@@ -525,7 +525,7 @@ test/testdata/dataset-with-setters/mysql/
// normalize path format for windows // normalize path format for windows
actualNormalized := strings.Replace(actual.String(), "\\", "/", -1) 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() t.FailNow()
} }
}) })

View File

@@ -27,6 +27,8 @@ func NewSetRunner(parent string) *SetRunner {
Example: commands.SetExamples, Example: commands.SetExamples,
PreRunE: r.preRunE, PreRunE: r.preRunE,
RunE: r.runE, 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) runner.FixDocs(parent, c)
r.Command = c r.Command = c

View File

@@ -1137,7 +1137,7 @@ set 1 field(s) of setter "namespace" to value "otherspace"
expectedNormalized := strings.Replace( expectedNormalized := strings.Replace(
strings.Replace(expected, "\\", "/", -1), strings.Replace(expected, "\\", "/", -1),
"//", "/", -1) "//", "/", -1)
if !assert.Equal(t, strings.TrimSpace(expectedNormalized), strings.TrimSpace(actualNormalized)) { if !assert.Contains(t, strings.TrimSpace(actualNormalized), strings.TrimSpace(expectedNormalized)) {
t.FailNow() t.FailNow()
} }
}) })

View File

@@ -25,6 +25,8 @@ func GetFmtRunner(name string) *FmtRunner {
Example: commands.FmtExamples, Example: commands.FmtExamples,
RunE: r.runE, RunE: r.runE,
PreRunE: r.preRunE, 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) runner.FixDocs(name, c)
c.Flags().StringVar(&r.FilenamePattern, "pattern", filters.DefaultFilenamePattern, c.Flags().StringVar(&r.FilenamePattern, "pattern", filters.DefaultFilenamePattern,

View File

@@ -78,7 +78,7 @@ func TestFmtCommand_stdin(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
// verify the output // 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 // 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) expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
expectedNormalized := strings.Replace(expected, "\\", "/", -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() t.FailNow()
} }
}) })

View File

@@ -43,7 +43,9 @@ kind: Krmfile
t.FailNow() 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() t.FailNow()
} }
} }
@@ -78,7 +80,9 @@ kind: Krmfile
t.FailNow() 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() t.FailNow()
} }
} }

View File

@@ -19,6 +19,8 @@ func GetMergeRunner(name string) *MergeRunner {
Long: commands.MergeLong, Long: commands.MergeLong,
Example: commands.MergeExamples, Example: commands.MergeExamples,
RunE: r.runE, 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) runner.FixDocs(name, c)
r.Command = c r.Command = c

View File

@@ -18,6 +18,8 @@ func GetMerge3Runner(name string) *Merge3Runner {
Long: commands.Merge3Long, Long: commands.Merge3Long,
Example: commands.Merge3Examples, Example: commands.Merge3Examples,
RunE: r.runE, 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) runner.FixDocs(name, c)
c.Flags().StringVar(&r.ancestor, "ancestor", "", c.Flags().StringVar(&r.ancestor, "ancestor", "",