Skip to content

Commit

Permalink
Merge pull request konstructio#1786 from kubefirst/fix-harden_flag_ch…
Browse files Browse the repository at this point in the history
…ecking

fix: add logging and hardening
  • Loading branch information
claywd authored Aug 30, 2023
2 parents 417305a + 8555ee8 commit 94066e6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/civo/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,23 @@ func createCivo(cmd *cobra.Command, args []string) error {
gitopsTemplateBranchFlag = "main"
}
default:
switch gitopsTemplateURLFlag {
switch strings.ToLower(gitopsTemplateBranchFlag) {
case "https://github.com/kubefirst/gitops-template.git": //default value
if gitopsTemplateBranchFlag == "" {
log.Info().Msgf("--gitops-template-repo-url supplied and branch not supplied so setting branch name to main")
gitopsTemplateBranchFlag = configs.K1Version
}
case "https://github.com/kubefirst/gitops-template": // edge case for valid but incomplete url
if gitopsTemplateBranchFlag == "" {
log.Info().Msgf("--gitops-template-repo-url supplied and branch not supplied so setting branch name to main")
gitopsTemplateBranchFlag = configs.K1Version
}
default: // not equal to our defaults
if gitopsTemplateBranchFlag == "" { //didn't supply the branch flag but they did supply the repo flag
if len(strings.TrimSpace(gitopsTemplateBranchFlag)) == 0 { //didn't supply the branch flag but they did supply the repo flag
log.Info().Msgf("--gitops-template-repo-url supplied and branch not supplied but if branch is not supplied then --gitops-template-url must be set to https://github.com/kubefirst/gitops-template or https://github.com/kubefirst/gitops-template.git ")
return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden")
}
log.Info().Msgf("--gitops-template-repo-url supplied and branch supplied so continuing on")
}
}

Expand Down

0 comments on commit 94066e6

Please sign in to comment.