mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
cmd/config linter updates
This commit is contained in:
@@ -142,7 +142,6 @@ func (r *AnnotateRunner) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
@@ -601,12 +601,12 @@ added annotations in the package
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expected, "\\", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expected, "\\", "/")
|
||||
if !assert.Contains(t, actualNormalized, expectedNormalized) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -654,12 +654,12 @@ spec:
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expected, "\\", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expected, "\\", "/")
|
||||
if !assert.Equal(t, expectedNormalized, actualNormalized) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -753,12 +753,12 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
expectedOut := strings.Replace(test.out, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expectedOut, "\\", "/", -1)
|
||||
expectedOut := strings.ReplaceAll(test.out, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expectedOut, "\\", "/")
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(out.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(out.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
if !assert.Contains(t, actualNormalized, expectedNormalized) {
|
||||
t.FailNow()
|
||||
@@ -863,12 +863,12 @@ setter with name "namespace" already exists, if you want to modify it, please de
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expected, "\\", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expected, "\\", "/")
|
||||
if !assert.Contains(t, actualNormalized, expectedNormalized) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -393,12 +393,12 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
expectedOut := strings.Replace(test.out, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expectedOut, "\\", "/", -1)
|
||||
expectedOut := strings.ReplaceAll(test.out, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expectedOut, "\\", "/")
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(out.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(out.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
if !assert.Contains(t, actualNormalized, expectedNormalized) {
|
||||
t.FailNow()
|
||||
@@ -500,12 +500,12 @@ created substitution "image-tag"`,
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expected, "\\", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expected, "\\", "/")
|
||||
if !assert.Contains(t, strings.TrimSpace(actualNormalized), strings.TrimSpace(expectedNormalized)) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -340,12 +340,12 @@ kind: Deployment
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNorm := strings.Replace(
|
||||
strings.Replace(out.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNorm := strings.ReplaceAll(
|
||||
strings.ReplaceAll(out.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expectedOut := strings.Replace(test.out, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expectedOut, "\\", "/", -1)
|
||||
expectedOut := strings.ReplaceAll(test.out, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expectedOut, "\\", "/")
|
||||
|
||||
if !assert.Contains(t, strings.TrimSpace(actualNorm), expectedNormalized) {
|
||||
t.FailNow()
|
||||
@@ -427,7 +427,7 @@ deleted setter "namespace"
|
||||
t.FailNow()
|
||||
}
|
||||
copyutil.CopyDir(sourceDir, baseDir)
|
||||
//defer os.RemoveAll(baseDir)
|
||||
// defer os.RemoveAll(baseDir)
|
||||
runner := commands.NewDeleteSetterRunner("")
|
||||
actual := &bytes.Buffer{}
|
||||
runner.Command.SetOut(actual)
|
||||
@@ -438,12 +438,12 @@ deleted setter "namespace"
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expected, "\\", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expected, "\\", "/")
|
||||
if !assert.Equal(t, expectedNormalized, actualNormalized) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -467,11 +467,11 @@ spec:
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNorm := strings.Replace(
|
||||
strings.Replace(out.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
expectedOut := strings.Replace(test.out, "${baseDir}", baseDir, -1)
|
||||
expectedNorm := strings.Replace(expectedOut, "\\", "/", -1)
|
||||
actualNorm := strings.ReplaceAll(
|
||||
strings.ReplaceAll(out.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
expectedOut := strings.ReplaceAll(test.out, "${baseDir}", baseDir)
|
||||
expectedNorm := strings.ReplaceAll(expectedOut, "\\", "/")
|
||||
|
||||
if !assert.Contains(t, strings.TrimSpace(actualNorm), expectedNorm) {
|
||||
t.FailNow()
|
||||
@@ -544,7 +544,7 @@ deleted substitution "image-tag"
|
||||
t.FailNow()
|
||||
}
|
||||
copyutil.CopyDir(sourceDir, baseDir)
|
||||
//defer os.RemoveAll(baseDir)
|
||||
// defer os.RemoveAll(baseDir)
|
||||
runner := commands.NewDeleteSubstitutionRunner("")
|
||||
actual := &bytes.Buffer{}
|
||||
runner.Command.SetOut(actual)
|
||||
@@ -555,12 +555,12 @@ deleted substitution "image-tag"
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expected, "\\", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expected, "\\", "/")
|
||||
if !assert.Equal(t, expectedNormalized, actualNormalized) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ test/testdata/dataset-with-setters/mysql/
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(actual.String(), "\\", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(actual.String(), "\\", "/")
|
||||
|
||||
if !assert.Contains(t, strings.TrimSpace(actualNormalized), strings.TrimSpace(test.expected)) {
|
||||
t.FailNow()
|
||||
|
||||
@@ -1129,14 +1129,14 @@ set 1 field(s) of setter "namespace" to value "otherspace"
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(
|
||||
strings.Replace(expected, "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(expected, "\\", "/"),
|
||||
"//", "/")
|
||||
if !assert.Contains(t, strings.TrimSpace(actualNormalized), strings.TrimSpace(expectedNormalized)) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ func (r *XArgsRunner) runE(c *cobra.Command, _ []string) error {
|
||||
return fmt.Errorf("must specify -- before command")
|
||||
}
|
||||
r.Args = r.Args[cmdIndex:]
|
||||
run := exec.Command(r.Args[0])
|
||||
run := exec.Command(r.Args[0]) // nolint: gosec
|
||||
|
||||
if len(r.Args) > 1 {
|
||||
r.Args = r.Args[cmdIndex+1:]
|
||||
|
||||
@@ -137,12 +137,12 @@ Deployment: 1
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expected, "\\", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expected, "\\", "/")
|
||||
if !assert.Equal(t, expectedNormalized, actualNormalized) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func TestRunE2e(t *testing.T) {
|
||||
name: "exec_function_no_args",
|
||||
args: func(d string) []string {
|
||||
return []string{
|
||||
"--enable-exec", "--exec-path", filepath.Join(d, "e2econtainerconfig"),
|
||||
"--enable-exec", "--exec-path", filepath.Join(d, e2eConfigDir),
|
||||
}
|
||||
},
|
||||
files: func(d string) map[string]string {
|
||||
@@ -720,7 +720,7 @@ metadata:
|
||||
}
|
||||
|
||||
args := append([]string{"fn", "run", "."}, tt.args(binDir)...)
|
||||
cmd := exec.Command(filepath.Join(binDir, kyamlBin), args...)
|
||||
cmd := exec.Command(filepath.Join(binDir, kyamlBin), args...) // nolint: gosec
|
||||
cmd.Dir = dir
|
||||
var stdErr, stdOut bytes.Buffer
|
||||
cmd.Stdout = &stdOut
|
||||
@@ -751,6 +751,8 @@ metadata:
|
||||
var buildOnce sync.Once
|
||||
var binDir string
|
||||
|
||||
const e2eConfigDir = "e2econtainerconfig"
|
||||
|
||||
func build() string {
|
||||
// only build the binaries once
|
||||
buildOnce.Do(func() {
|
||||
@@ -760,7 +762,7 @@ func build() string {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
build := exec.Command("go", "build", "-o",
|
||||
build := exec.Command("go", "build", "-o", // nolint: gosec
|
||||
filepath.Join(binDir, e2econtainerconfigBin))
|
||||
build.Dir = "e2econtainerconfig"
|
||||
build.Stdout = os.Stdout
|
||||
@@ -772,7 +774,7 @@ func build() string {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
build = exec.Command("go", "build", "-o", filepath.Join(binDir, kyamlBin))
|
||||
build = exec.Command("go", "build", "-o", filepath.Join(binDir, kyamlBin)) // nolint: gosec
|
||||
build.Dir = filepath.Join("..", "..", "..", "kubectl-krm")
|
||||
build.Stdout = os.Stdout
|
||||
build.Stderr = os.Stderr
|
||||
@@ -786,7 +788,7 @@ func build() string {
|
||||
}
|
||||
build = exec.Command(
|
||||
"docker", "build", ".", "-t", "gcr.io/kustomize-functions/e2econtainerconfig")
|
||||
build.Dir = "e2econtainerconfig"
|
||||
build.Dir = e2eConfigDir
|
||||
build.Stdout = os.Stdout
|
||||
build.Stderr = os.Stderr
|
||||
err = build.Run()
|
||||
@@ -803,9 +805,9 @@ var (
|
||||
kyamlBin string
|
||||
)
|
||||
|
||||
func init() {
|
||||
func init() { //nolint: gochecknoinits
|
||||
kyamlBin = "kubectl-krm"
|
||||
e2econtainerconfigBin = "e2econtainerconfig"
|
||||
e2econtainerconfigBin = e2eConfigDir
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
kyamlBin = "kubectl-krm.exe"
|
||||
|
||||
@@ -17,9 +17,13 @@ import (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
d := build()
|
||||
defer os.RemoveAll(d)
|
||||
os.Exit(m.Run())
|
||||
var code int
|
||||
func() {
|
||||
d := build()
|
||||
defer os.RemoveAll(d)
|
||||
code = m.Run()
|
||||
}()
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
type test struct {
|
||||
|
||||
@@ -69,7 +69,6 @@ func (r *FmtRunner) preRunE(c *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
func (r *FmtRunner) runE(c *cobra.Command, args []string) error {
|
||||
|
||||
// format stdin if there are no args
|
||||
if len(args) == 0 {
|
||||
rw := &kio.ByteReadWriter{
|
||||
|
||||
@@ -232,12 +232,12 @@ formatted resource files in the package
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expected, "\\", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expected, "\\", "/")
|
||||
if !assert.Contains(t, strings.TrimSpace(actualNormalized), strings.TrimSpace(expectedNormalized)) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -73,19 +73,20 @@ func (r *GrepRunner) preRunE(c *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
var last []string
|
||||
if strings.Contains(parts[len(parts)-1], ">=") {
|
||||
switch {
|
||||
case strings.Contains(parts[len(parts)-1], ">="):
|
||||
last = strings.Split(parts[len(parts)-1], ">=")
|
||||
r.MatchType = filters.GreaterThanEq
|
||||
} else if strings.Contains(parts[len(parts)-1], "<=") {
|
||||
case strings.Contains(parts[len(parts)-1], "<="):
|
||||
last = strings.Split(parts[len(parts)-1], "<=")
|
||||
r.MatchType = filters.LessThanEq
|
||||
} else if strings.Contains(parts[len(parts)-1], ">") {
|
||||
case strings.Contains(parts[len(parts)-1], ">"):
|
||||
last = strings.Split(parts[len(parts)-1], ">")
|
||||
r.MatchType = filters.GreaterThan
|
||||
} else if strings.Contains(parts[len(parts)-1], "<") {
|
||||
case strings.Contains(parts[len(parts)-1], "<"):
|
||||
last = strings.Split(parts[len(parts)-1], "<")
|
||||
r.MatchType = filters.LessThan
|
||||
} else {
|
||||
default:
|
||||
last = strings.Split(parts[len(parts)-1], "=")
|
||||
r.MatchType = filters.Regexp
|
||||
}
|
||||
@@ -99,7 +100,7 @@ func (r *GrepRunner) preRunE(c *cobra.Command, args []string) error {
|
||||
r.Value = last[1]
|
||||
}
|
||||
|
||||
r.Path = append(parts[:len(parts)-1], last[0])
|
||||
r.Path = append(parts[:len(parts)-1], last[0]) // nolint:gocritic
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -136,7 +137,6 @@ func (r *GrepRunner) runE(c *cobra.Command, args []string) error {
|
||||
fmt.Fprintf(c.OutOrStdout(), "%s", res)
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (r *GrepRunner) ExecuteCmd(w io.Writer, pkgPath string) error {
|
||||
|
||||
@@ -416,12 +416,12 @@ spec:
|
||||
}
|
||||
|
||||
// normalize path format for windows
|
||||
actualNormalized := strings.Replace(
|
||||
strings.Replace(actual.String(), "\\", "/", -1),
|
||||
"//", "/", -1)
|
||||
actualNormalized := strings.ReplaceAll(
|
||||
strings.ReplaceAll(actual.String(), "\\", "/"),
|
||||
"//", "/")
|
||||
|
||||
expected := strings.Replace(test.expected, "${baseDir}", baseDir, -1)
|
||||
expectedNormalized := strings.Replace(expected, "\\", "/", -1)
|
||||
expected := strings.ReplaceAll(test.expected, "${baseDir}", baseDir)
|
||||
expectedNormalized := strings.ReplaceAll(expected, "\\", "/")
|
||||
if !assert.Equal(t, expectedNormalized, actualNormalized) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -61,13 +61,13 @@ spec:
|
||||
return
|
||||
}
|
||||
|
||||
expected_dir, err := ioutil.TempDir("", "test-data-expected")
|
||||
defer os.RemoveAll(expected_dir)
|
||||
expectedDir, err := ioutil.TempDir("", "test-data-expected")
|
||||
defer os.RemoveAll(expectedDir)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(expected_dir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
err = ioutil.WriteFile(filepath.Join(expectedDir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app
|
||||
@@ -111,13 +111,13 @@ spec:
|
||||
return
|
||||
}
|
||||
|
||||
updated_dir, err := ioutil.TempDir("", "test-data-updated")
|
||||
defer os.RemoveAll(updated_dir)
|
||||
updatedDir, err := ioutil.TempDir("", "test-data-updated")
|
||||
defer os.RemoveAll(updatedDir)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(updated_dir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
err = ioutil.WriteFile(filepath.Join(updatedDir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app
|
||||
@@ -158,13 +158,13 @@ spec:
|
||||
return
|
||||
}
|
||||
|
||||
dest_dir, err := ioutil.TempDir("", "test-data-dest")
|
||||
defer os.RemoveAll(dest_dir)
|
||||
destDir, err := ioutil.TempDir("", "test-data-dest")
|
||||
defer os.RemoveAll(destDir)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(dest_dir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
err = ioutil.WriteFile(filepath.Join(destDir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app
|
||||
@@ -212,15 +212,15 @@ spec:
|
||||
"--ancestor",
|
||||
datadir,
|
||||
"--from",
|
||||
updated_dir,
|
||||
updatedDir,
|
||||
"--to",
|
||||
dest_dir,
|
||||
destDir,
|
||||
})
|
||||
if !assert.NoError(t, r.Command.Execute()) {
|
||||
return
|
||||
}
|
||||
|
||||
diffs, err := copyutil.Diff(dest_dir, expected_dir)
|
||||
diffs, err := copyutil.Diff(destDir, expectedDir)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ func GetRunFnRunner(name string) *RunFnRunner {
|
||||
"run this image as a function instead of discovering them.")
|
||||
// NOTE: exec plugins execute arbitrary code -- never change the default value of this flag!!!
|
||||
r.Command.Flags().BoolVar(
|
||||
&r.EnableExec, "enable-exec", false /*do not change!*/, "enable support for exec functions -- note: exec functions run arbitrary code -- do not use for untrusted configs!!! (Alpha)")
|
||||
&r.EnableExec, "enable-exec", false, /*do not change!*/
|
||||
"enable support for exec functions -- note: exec functions run arbitrary code -- do not use for untrusted configs!!! (Alpha)")
|
||||
r.Command.Flags().StringVar(
|
||||
&r.ExecPath, "exec-path", "", "run an executable as a function. (Alpha)")
|
||||
r.Command.Flags().BoolVar(
|
||||
|
||||
@@ -412,7 +412,6 @@ apiVersion: v1
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,8 +202,22 @@ func TestSourceCommandJSON(t *testing.T) {
|
||||
if !assert.Equal(t, `apiVersion: config.kubernetes.io/v1
|
||||
kind: ResourceList
|
||||
items:
|
||||
- {"kind": "Deployment", "metadata": {"labels": {"app": "nginx2"}, "name": "foo", "annotations": {"app": "nginx2", config.kubernetes.io/index: '0', config.kubernetes.io/path: 'f1.json', internal.config.kubernetes.io/index: '0', internal.config.kubernetes.io/path: 'f1.json'}}, "spec": {"replicas": 1}}
|
||||
- {"apiVersion": "v1", "kind": "Abstraction", "metadata": {"name": "foo", "annotations": {"config.kubernetes.io/function": "container:\n image: gcr.io/example/reconciler:v1\n", "config.kubernetes.io/local-config": "true", config.kubernetes.io/index: '0', config.kubernetes.io/path: 'f2.json', internal.config.kubernetes.io/index: '0', internal.config.kubernetes.io/path: 'f2.json'}}, "spec": {"replicas": 3}}
|
||||
- {"kind": "Deployment", `+
|
||||
`"metadata": {`+
|
||||
`"labels": {"app": "nginx2"}, `+
|
||||
`"name": "foo", `+
|
||||
`"annotations": {`+
|
||||
`"app": "nginx2", `+
|
||||
`config.kubernetes.io/index: '0', config.kubernetes.io/path: 'f1.json', internal.config.kubernetes.io/index: '0', internal.config.kubernetes.io/path: 'f1.json'}}, `+
|
||||
`"spec": {"replicas": 1}}
|
||||
- {"apiVersion": "v1", "kind": "Abstraction", `+
|
||||
`"metadata": {`+
|
||||
`"name": "foo", `+
|
||||
`"annotations": {`+
|
||||
`"config.kubernetes.io/function": "container:\n image: gcr.io/example/reconciler:v1\n", `+
|
||||
`"config.kubernetes.io/local-config": "true", `+
|
||||
`config.kubernetes.io/index: '0', config.kubernetes.io/path: 'f2.json', internal.config.kubernetes.io/index: '0', internal.config.kubernetes.io/path: 'f2.json'}}, `+
|
||||
`"spec": {"replicas": 3}}
|
||||
`, b.String()) {
|
||||
return
|
||||
}
|
||||
@@ -312,7 +326,14 @@ func TestSourceCommandJSON_Stdin(t *testing.T) {
|
||||
if !assert.Equal(t, `apiVersion: config.kubernetes.io/v1
|
||||
kind: ResourceList
|
||||
items:
|
||||
- {"kind": "Deployment", "metadata": {"labels": {"app": "nginx2"}, "name": "foo", "annotations": {"app": "nginx2", config.kubernetes.io/index: '0', internal.config.kubernetes.io/index: '0'}}, "spec": {"replicas": 1}}
|
||||
- {"kind": "Deployment", `+
|
||||
`"metadata": {`+
|
||||
`"labels": {"app": "nginx2"}, `+
|
||||
`"name": "foo", `+
|
||||
`"annotations": {`+
|
||||
`"app": "nginx2", `+
|
||||
`config.kubernetes.io/index: '0', internal.config.kubernetes.io/index: '0'}}, `+
|
||||
`"spec": {"replicas": 1}}
|
||||
`, out.String()) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user