kustomize.yaml becomes kustomization.yaml

This commit is contained in:
Jeffrey Regan
2018-04-17 11:16:49 -07:00
parent da0682cdeb
commit 4d2b8d4e1d
22 changed files with 59 additions and 43 deletions

View File

@@ -44,9 +44,8 @@ func newCmdBuild(out, errOut io.Writer, fs fs.FileSystem) *cobra.Command {
cmd := &cobra.Command{
Use: "build [path]",
Short: "Print current configuration per contents of " + constants.KustomizationFileName,
Example: `
# Use the kustomize.yaml file under somedir/ to generate a set of api resources.
build somedir/`,
Example: "Use the file somedir/" + constants.KustomizationFileName +
" to generate a set of api resources:\nbuild somedir/",
Run: func(cmd *cobra.Command, args []string) {
err := o.Validate(args)
if err != nil {
@@ -66,7 +65,7 @@ func newCmdBuild(out, errOut io.Writer, fs fs.FileSystem) *cobra.Command {
// Validate validates build command.
func (o *buildOptions) Validate(args []string) error {
if len(args) > 1 {
return errors.New("specify one path to kustomization file")
return errors.New("specify one path to " + constants.KustomizationFileName)
}
if len(args) == 0 {
o.kustomizationPath = "./"

View File

@@ -28,6 +28,7 @@ import (
"github.com/ghodss/yaml"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubectl/pkg/kustomize/constants"
"k8s.io/kubectl/pkg/kustomize/util/fs"
)
@@ -50,7 +51,8 @@ func TestBuildValidate(t *testing.T) {
{"noargs", []string{}, "./", ""},
{"file", []string{"beans"}, "beans", ""},
{"path", []string{"a/b/c"}, "a/b/c", ""},
{"path", []string{"too", "many"}, "", "specify one path to kustomization file"},
{"path", []string{"too", "many"},
"", "specify one path to " + constants.KustomizationFileName},
}
for _, mycase := range cases {
opts := buildOptions{}

View File

@@ -24,6 +24,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/kubectl/pkg/kustomize/app"
"k8s.io/kubectl/pkg/kustomize/constants"
"k8s.io/kubectl/pkg/kustomize/util"
"k8s.io/kubectl/pkg/kustomize/util/fs"
"k8s.io/kubectl/pkg/loader"
@@ -56,7 +57,12 @@ func newCmdDiff(out, errOut io.Writer, fs fs.FileSystem) *cobra.Command {
},
}
cmd.Flags().StringVarP(&o.kustomizationPath, "filename", "f", "", "Pass in a kustomize.yaml file or a directory that contains the file.")
cmd.Flags().StringVarP(
&o.kustomizationPath,
"filename",
"f",
"",
"Specify a directory containing "+constants.KustomizationFileName)
cmd.MarkFlagRequired("filename")
return cmd
}

View File

@@ -32,9 +32,9 @@ namePrefix: some-prefix
# Labels to add to all objects and selectors.
# These labels would also be used to form the selector for apply --prune
# Named differently than “labels” to avoid confusion with metadata for this object
labelsToAdd:
commonLabels:
app: helloworld
annotationsToAdd:
commonAnnotations:
note: This is an example annotation
resources: []
#- service.yaml

View File

@@ -1,9 +1,9 @@
namePrefix: team-foo-
labelsToAdd:
commonLabels:
app: mynginx
org: example.com
team: foo
annotationsToAdd:
commonAnnotations:
note: This is a test annotation
resources:
- deployment.yaml

View File

@@ -1,5 +1,5 @@
namePrefix: staging-
labelsToAdd:
commonLabels:
env: staging
patches:
- deployment-patch2.yaml

View File

@@ -1,9 +1,9 @@
namePrefix: team-foo-
labelsToAdd:
commonLabels:
app: mynginx
org: example.com
team: foo
annotationsToAdd:
commonAnnotations:
note: This is a test annotation
resources:
- deployment.yaml

View File

@@ -1,5 +1,5 @@
namePrefix: staging-
labelsToAdd:
commonLabels:
env: staging
patches:
- deployment-patch1.yaml

View File

@@ -1,9 +1,9 @@
namePrefix: team-foo-
labelsToAdd:
commonLabels:
app: mynginx
org: example.com
team: foo
annotationsToAdd:
commonAnnotations:
note: This is a test annotation
resources:
- deployment.yaml

View File

@@ -1,5 +1,5 @@
namePrefix: staging-
labelsToAdd:
commonLabels:
env: staging
team: override-foo
patches:

View File

@@ -1,9 +1,9 @@
namePrefix: team-foo-
labelsToAdd:
commonLabels:
app: mynginx
org: example.com
team: foo
annotationsToAdd:
commonAnnotations:
note: This is a test annotation
resources:
- deployment.yaml

View File

@@ -21,6 +21,7 @@ import (
"strings"
"testing"
"k8s.io/kubectl/pkg/kustomize/constants"
"k8s.io/kubectl/pkg/kustomize/types"
"k8s.io/kubectl/pkg/kustomize/util/fs"
)
@@ -31,8 +32,8 @@ func TestWriteAndRead(t *testing.T) {
}
fsys := fs.MakeFakeFS()
fsys.Create("kustomize.yaml")
mf, err := newKustomizationFile("kustomize.yaml", fsys)
fsys.Create(constants.KustomizationFileName)
mf, err := newKustomizationFile(constants.KustomizationFileName, fsys)
if err != nil {
t.Fatalf("Unexpected Error: %v", err)
}
@@ -63,7 +64,7 @@ func TestNewNotExist(t *testing.T) {
fakeFS := fs.MakeFakeFS()
fakeFS.Mkdir(".", 0644)
fakeFS.Create(badSuffix)
_, err := newKustomizationFile("kustomize.yaml", fakeFS)
_, err := newKustomizationFile(constants.KustomizationFileName, fakeFS)
if err == nil {
t.Fatalf("expect an error")
}
@@ -71,7 +72,7 @@ func TestNewNotExist(t *testing.T) {
if !strings.Contains(err.Error(), contained) {
t.Fatalf("expect an error contains %q, but got %v", contained, err)
}
_, err = newKustomizationFile("kustomize.yaml", fakeFS)
_, err = newKustomizationFile(constants.KustomizationFileName, fakeFS)
if err == nil {
t.Fatalf("expect an error")
}