Skip to content

Commit

Permalink
OCM-1308 | fix: filter empty subnet id
Browse files Browse the repository at this point in the history
Signed-off-by: Maggie Chen <[email protected]>
  • Loading branch information
chenz4027 committed Apr 19, 2024
1 parent 86498a9 commit 1344878
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmd/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2058,9 +2058,9 @@ func run(cmd *cobra.Command, _ []string) {
}

// Subnet IDs
subnetIDs := args.subnetIDs
subnetIDs := delete_empty(args.subnetIDs)
subnetsProvided := len(subnetIDs) > 0
r.Reporter.Debugf("Received the following subnetIDs: %v", args.subnetIDs)
r.Reporter.Debugf("Received the following subnetIDs: %v", subnetIDs)
// If the user has set the availability zones (allowed for non-BYOVPC clusters), don't prompt the BYOVPC message
if !useExistingVPC && !subnetsProvided && !isAvailabilityZonesSet && interactive.Enabled() {
existingVPCHelp := "To install into an existing VPC you need to ensure that your VPC is configured " +
Expand Down Expand Up @@ -2092,7 +2092,7 @@ func run(cmd *cobra.Command, _ []string) {
var subnets []ec2types.Subnet
mapSubnetIDToSubnet := make(map[string]aws.Subnet)
if useExistingVPC || subnetsProvided {
initialSubnets, err := getInitialValidSubnets(awsClient, args.subnetIDs, r.Reporter)
initialSubnets, err := getInitialValidSubnets(awsClient, subnetIDs, r.Reporter)
if err != nil {
r.Reporter.Errorf("Failed to get the list of subnets: %s", err)
os.Exit(1)
Expand Down Expand Up @@ -4134,3 +4134,13 @@ func getMachinePoolRootDisk(r *rosa.Runtime, cmd *cobra.Command, version string,
func clusterHasLongNameWithoutDomainPrefix(clusterName, domainPrefix string) bool {
return domainPrefix == "" && len(clusterName) > ocm.MaxClusterDomainPrefixLength
}

func delete_empty(s []string) []string {
var r []string
for _, str := range s {
if str != "" {
r = append(r, str)
}
}
return r
}

0 comments on commit 1344878

Please sign in to comment.