diff --git a/pkg/commands/environment.go b/pkg/commands/environment.go index dd8ccd1b..999ecae1 100644 --- a/pkg/commands/environment.go +++ b/pkg/commands/environment.go @@ -217,12 +217,14 @@ var environmentApplyCmd = &cobra.Command{ Options: &optFlags, GithubClient: github.NewGithubClient(ghConfig, optFlags.GithubToken), } - // if -all-namespaces is provided, apply all namespaces - if optFlags.AllNamespaces { - err := applier.ApplyAll() + + // if -namespace or a prNumber is provided, apply on given namespace + if optFlags.Namespace != "" || optFlags.PRNumber > 0 { + err := applier.Apply() if err != nil { contextLogger.Fatal(err) } + return } // if -batch-apply-index and -batch-apply-size is provided, apply on given batch of namespaces if optFlags.BatchApplyIndex >= 0 && optFlags.BatchApplySize > 0 { @@ -230,14 +232,17 @@ var environmentApplyCmd = &cobra.Command{ if err != nil { contextLogger.Fatal(err) } + return } - // if -namespace or a prNumber is provided, apply on given namespace - if optFlags.Namespace != "" || optFlags.PRNumber > 0 { - err := applier.Apply() + // if -all-namespaces is provided, apply all namespaces + if optFlags.AllNamespaces { + err := applier.ApplyAll() if err != nil { contextLogger.Fatal(err) } + return } + }, } diff --git a/pkg/util/filesystem.go b/pkg/util/filesystem.go index bda52a14..5d0df707 100644 --- a/pkg/util/filesystem.go +++ b/pkg/util/filesystem.go @@ -19,7 +19,7 @@ func GetFolderChunks(repoPath string, batchIndex int, batchSize int) ([]string, nsFolders = append(nsFolders, folders[1:]...) if batchIndex < 0 || batchSize <= 0 || batchIndex > len(nsFolders) { - return nil, errors.New("invalid batch-apply-index") + return nil, errors.New("invalid index or size") } // The number of namespaces cant be equally split and hence the last batch // will have either the batchsize or the remaining of the namespaces