Skip to content

Commit

Permalink
Merge pull request #582 from abutcher/OCPBUGS-16807
Browse files Browse the repository at this point in the history
OCPBUGS-16807: ccoctl azure exit with error when OIDC and installation resource group names are the same
  • Loading branch information
openshift-merge-robot committed Jul 27, 2023
2 parents 0e376e4 + fca7408 commit 078b087
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/cmd/provisioning/azure/create_all.go
Expand Up @@ -43,6 +43,15 @@ func createAllCmd(cmd *cobra.Command, args []string) {
log.Printf("No --oidc-resource-group-name provided, defaulting OIDC resource group name to %s", CreateAllOpts.OIDCResourceGroupName)
}

if CreateAllOpts.InstallationResourceGroupName == "" {
CreateAllOpts.InstallationResourceGroupName = CreateAllOpts.Name
log.Printf("No --installation-resource-group-name provided, defaulting installation resource group name to %s", CreateAllOpts.InstallationResourceGroupName)
}

if CreateAllOpts.OIDCResourceGroupName == CreateAllOpts.InstallationResourceGroupName {
log.Fatalf("OIDC and installation resource group names cannot be the same")
}

if CreateAllOpts.StorageAccountName == "" {
CreateAllOpts.StorageAccountName = CreateAllOpts.Name
log.Printf("No --storage-account-name provided, defaulting storage account name to %s", CreateAllOpts.StorageAccountName)
Expand All @@ -56,11 +65,6 @@ func createAllCmd(cmd *cobra.Command, args []string) {
log.Printf("No --blob-container-name provided, defaulting blob container name to %s", CreateAllOpts.BlobContainerName)
}

if CreateAllOpts.InstallationResourceGroupName == "" {
CreateAllOpts.InstallationResourceGroupName = CreateAllOpts.Name
log.Printf("No --installation-resource-group-name provided, defaulting installation resource group name to %s", CreateAllOpts.InstallationResourceGroupName)
}

issuerURL, err := createOIDCIssuer(azureClientWrapper,
CreateAllOpts.Name,
CreateAllOpts.Region,
Expand Down Expand Up @@ -177,7 +181,7 @@ func NewCreateAllCmd() *cobra.Command {
"The OpenShift installer requires that the resource group provided for installation resources be initially empty so this resource group must "+
"contain no resources if the resource group was previously created. "+
"A resource group will be created (with name derived from the --name parameter) if an installation-resource-group-name parameter was not provided. "+
"Note that this resource group must be provided as the installation resource group when installing the OpenShift cluster",
"Note that this resource group must be provided as the installation resource group when installing the OpenShift cluster.",
)
createAllCmd.PersistentFlags().StringVar(
&CreateAllOpts.StorageAccountName,
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/provisioning/azure/create_managed_identities.go
Expand Up @@ -654,6 +654,10 @@ func createManagedIdentitiesCmd(cmd *cobra.Command, args []string) {
log.Printf("No --installation-resource-group-name provided, defaulting installation resource group name to %s", CreateManagedIdentitiesOpts.InstallationResourceGroupName)
}

if CreateManagedIdentitiesOpts.OIDCResourceGroupName == CreateManagedIdentitiesOpts.InstallationResourceGroupName {
log.Fatalf("OIDC and installation resource group names cannot be the same")
}

err = createManagedIdentities(
azureClientWrapper,
CreateManagedIdentitiesOpts.CredRequestDir,
Expand Down

0 comments on commit 078b087

Please sign in to comment.