From 127c2f1e7410b68510a850c44e7f6e3c63bb42f4 Mon Sep 17 00:00:00 2001 From: Jingfang Liu Date: Tue, 26 Feb 2019 13:53:56 -0800 Subject: [PATCH] address comments --- .../cli-runtime/pkg/genericclioptions/resource/builder.go | 2 +- .../pkg/genericclioptions/resource/builder_test.go | 7 ++++++- test/cmd/apply.sh | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder.go b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder.go index ad5247e9b4f..08528fa2981 100644 --- a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder.go +++ b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder.go @@ -140,7 +140,7 @@ func (o *FilenameOptions) validate() []error { errs = append(errs, fmt.Errorf("only one of -f or -k can be specified")) } if len(o.Kustomize) > 0 && o.Recursive { - errs = append(errs, fmt.Errorf("-R is not allowed to work with -k")) + errs = append(errs, fmt.Errorf("the -k flag can't be used with -f or -R")) } return errs } diff --git a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder_test.go b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder_test.go index 8c0fb836163..d2e0d6ffec0 100644 --- a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder_test.go +++ b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder_test.go @@ -392,7 +392,7 @@ func TestFilenameOptionsValidate(t *testing.T) { kustomize: "dir", recursive: true, errExp: true, - msgExp: "-R is not allowed to work with -k", + msgExp: "the -k flag can't be used with -f or -R", }, { filenames: []string{"file"}, @@ -673,6 +673,11 @@ func TestKustomizeDirectoryBuilder(t *testing.T) { expectErr: false, expectedNames: []string{"test-the-map", "test-the-deployment", "test-the-service"}, }, + { + directory: filepath.Join(dir, "kustomization.yaml"), + expectErr: true, + errMsg: "must be a directory to be a root", + }, { directory: "../../../artifacts/kustomization/should-not-load.yaml", expectErr: true, diff --git a/test/cmd/apply.sh b/test/cmd/apply.sh index 6f230a645c0..2f9bac52db9 100755 --- a/test/cmd/apply.sh +++ b/test/cmd/apply.sh @@ -229,7 +229,7 @@ __EOF__ kube::test::get_object_assert 'deployment test-the-deployment' "{{${id_field}}}" 'test-the-deployment' kube::test::get_object_assert 'service test-the-service' "{{${id_field}}}" 'test-the-service' # cleanup - kubectl delete configmap/test-the-map deployment/test-the-deployment service/test-the-service + kubectl delete -k hack/testdata/kustomize ## kubectl apply --kustomize somedir kubectl apply --kustomize hack/testdata/kustomize @@ -237,7 +237,7 @@ __EOF__ kube::test::get_object_assert 'deployment test-the-deployment' "{{${id_field}}}" 'test-the-deployment' kube::test::get_object_assert 'service test-the-service' "{{${id_field}}}" 'test-the-service' # cleanup - kubectl delete -k hack/testdata/kustomize + kubectl delete --kustomize hack/testdata/kustomize set +o nounset set +o errexit