Skip to content

Commit

Permalink
Merge #131218
Browse files Browse the repository at this point in the history
131218: roachprod: validate cloud providers r=herkolategan a=herkolategan

Previously, when calling the `create` command, it was possible to pass the same cloud twice by specifying `-c` or `--clouds` for the same provider more than once. There was no early validation that caught this and the resulting error after attempting to create the cluster would be confusing.

This change adds validation that warns the user early on a duplicate provider has been passed.

Epic: None
Release note: None

Co-authored-by: Herko Lategan <[email protected]>
  • Loading branch information
craig[bot] and herkolategan committed Sep 27, 2024
2 parents 133ef3b + ef01426 commit fcf3009
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/cmd/roachprod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,18 @@ func validateAndConfigure(cmd *cobra.Command, args []string) {
_ = cmd.Flags().Set("arch", string(arch))
}
}

// Validate cloud providers, if set.
providersSet := make(map[string]struct{})
for _, p := range createVMOpts.VMProviders {
if _, ok := vm.Providers[p]; !ok {
printErrAndExit(fmt.Errorf("unknown cloud provider %q", p))
}
if _, ok := providersSet[p]; ok {
printErrAndExit(fmt.Errorf("duplicate cloud provider specified %q", p))
}
providersSet[p] = struct{}{}
}
}

var updateCmd = &cobra.Command{
Expand Down

0 comments on commit fcf3009

Please sign in to comment.