Merge pull request #993 from monopole/fixNits

Fix some comment nits.
This commit is contained in:
Jeff Regan
2019-04-19 09:29:18 -07:00
committed by GitHub
5 changed files with 25 additions and 17 deletions

View File

@@ -58,7 +58,7 @@ func NewPruneTransformer(p *types.Prune, namespace string, append bool) transfor
// The prune ConfigMap is used to support the pruning command in the client side tool, // The prune ConfigMap is used to support the pruning command in the client side tool,
// which is proposed in https://github.com/kubernetes/enhancements/pull/810 // which is proposed in https://github.com/kubernetes/enhancements/pull/810
func (o *pruneTransformer) Transform(m resmap.ResMap) error { func (o *pruneTransformer) Transform(m resmap.ResMap) error {
keys := []string{} var keys []string
for _, r := range m { for _, r := range m {
s := r.PruneString() s := r.PruneString()
keys = append(keys, s) keys = append(keys, s)

View File

@@ -96,10 +96,11 @@ func NewCmdBuild(
// Validate validates build command. // Validate validates build command.
func (o *Options) Validate(args []string) error { func (o *Options) Validate(args []string) error {
if len(args) > 1 { if len(args) > 1 {
return errors.New("specify one path to " + pgmconfig.KustomizationFileNames[0]) return errors.New(
"specify one path to " + pgmconfig.KustomizationFileNames[0])
} }
if len(args) == 0 { if len(args) == 0 {
o.kustomizationPath = "./" o.kustomizationPath = loader.CWD
} else { } else {
o.kustomizationPath = args[0] o.kustomizationPath = args[0]
} }

View File

@@ -35,7 +35,7 @@ func TestBuildValidate(t *testing.T) {
path string path string
erMsg string erMsg string
}{ }{
{"noargs", []string{}, "./", ""}, {"noargs", []string{}, ".", ""},
{"file", []string{"beans"}, "beans", ""}, {"file", []string{"beans"}, "beans", ""},
{"path", []string{"a/b/c"}, "a/b/c", ""}, {"path", []string{"a/b/c"}, "a/b/c", ""},
{"path", []string{"too", "many"}, {"path", []string{"too", "many"},
@@ -54,7 +54,7 @@ func TestBuildValidate(t *testing.T) {
continue continue
} }
if e != nil { if e != nil {
t.Errorf("%s: unknown error %v", mycase.name, e) t.Errorf("%s: unknown error: %v", mycase.name, e)
continue continue
} }
if opts.kustomizationPath != mycase.path { if opts.kustomizationPath != mycase.path {

View File

@@ -30,7 +30,7 @@ import (
// fileLoader is a kustomization's interface to files. // fileLoader is a kustomization's interface to files.
// //
// The directory in which a kustomization file sits // The directory in which a kustomization file sits
// is referred to below as the kustomization's root. // is referred to below as the kustomization's _root_.
// //
// An instance of fileLoader has an immutable root, // An instance of fileLoader has an immutable root,
// and offers a `New` method returning a new loader // and offers a `New` method returning a new loader
@@ -42,12 +42,12 @@ import (
// //
// `Load` is used to visit these paths. // `Load` is used to visit these paths.
// //
// These paths refer to resources, patches,
// data for ConfigMaps and Secrets, etc.
//
// They must terminate in or below the root. // They must terminate in or below the root.
// //
// They hold things like resources, patches, // * bases (other kustomizations)
// data for ConfigMaps, etc.
//
// * bases; other kustomizations
// //
// `New` is used to load bases. // `New` is used to load bases.
// //
@@ -82,24 +82,31 @@ type fileLoader struct {
// Loader that spawned this loader. // Loader that spawned this loader.
// Used to avoid cycles. // Used to avoid cycles.
referrer *fileLoader referrer *fileLoader
// An absolute, cleaned path to a directory. // An absolute, cleaned path to a directory.
// The Load function reads from this directory, // The Load function will read non-absolute
// or directories below it. // paths relative to this directory.
root fs.ConfirmedDir root fs.ConfirmedDir
// If this is non-nil, the files were // If this is non-nil, the files were
// obtained from the given repository. // obtained from the given repository.
repoSpec *git.RepoSpec repoSpec *git.RepoSpec
// File system utilities. // File system utilities.
fSys fs.FileSystem fSys fs.FileSystem
// Used to clone repositories. // Used to clone repositories.
cloner git.Cloner cloner git.Cloner
// Used to clean up, as needed. // Used to clean up, as needed.
cleaner func() error cleaner func() error
} }
const CWD = "."
// NewFileLoaderAtCwd returns a loader that loads from ".". // NewFileLoaderAtCwd returns a loader that loads from ".".
func NewFileLoaderAtCwd(fSys fs.FileSystem) *fileLoader { func NewFileLoaderAtCwd(fSys fs.FileSystem) *fileLoader {
return newLoaderOrDie(fSys, ".") return newLoaderOrDie(fSys, CWD)
} }
// NewFileLoaderAtRoot returns a loader that loads from "/". // NewFileLoaderAtRoot returns a loader that loads from "/".
@@ -279,9 +286,9 @@ func (l *fileLoader) errIfRepoCycle(newRepoSpec *git.RepoSpec) error {
return l.referrer.errIfRepoCycle(newRepoSpec) return l.referrer.errIfRepoCycle(newRepoSpec)
} }
// Load returns content of file at the given relative path, // Load returns the content of file at the given path,
// else an error. The path must refer to a file in or // else an error. Relative paths are taken relative
// below the current root. // relative to the root.
func (l *fileLoader) Load(path string) ([]byte, error) { func (l *fileLoader) Load(path string) ([]byte, error) {
if filepath.IsAbs(path) { if filepath.IsAbs(path) {
return nil, l.loadOutOfBounds(path) return nil, l.loadOutOfBounds(path)

View File

@@ -159,7 +159,7 @@ func (p *ExecPlugin) Transform(rm resmap.ResMap) error {
return err return err
} }
if len(tmpMap) != 1 { if len(tmpMap) != 1 {
return fmt.Errorf("Unable to put two resources into one") return fmt.Errorf("unable to put two resources into one")
} }
for _, v := range tmpMap { for _, v := range tmpMap {
rm[id].Kunstructured = v.Kunstructured rm[id].Kunstructured = v.Kunstructured