Skip to content

Commit

Permalink
Change order and return after each option
Browse files Browse the repository at this point in the history
  • Loading branch information
poornima-krishnasamy committed Dec 11, 2023
1 parent e8efd07 commit 6b4ef45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions pkg/commands/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,27 +217,32 @@ 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 {
err := applier.ApplyBatch()
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
}

},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b4ef45

Please sign in to comment.