Skip to content

Commit

Permalink
azurepathfixcontroller: return error if account name is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
flavianmissi committed Feb 15, 2024
1 parent 33d4dad commit aceec22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pkg/operator/azurepathfixcontroller.go
Expand Up @@ -168,6 +168,14 @@ func (c *AzurePathFixController) sync() error {
if err != nil {
return err
}
azureStorage := imageRegistryConfig.Status.Storage.Azure
if azureStorage == nil || (azureStorage != nil && len(azureStorage.AccountName) == 0) {
return fmt.Errorf("storage account not yet provisioned")
}
if azureStorage == nil || (azureStorage != nil && len(azureStorage.Container) == 0) {
return fmt.Errorf("storage container not yet provisioned")
}

gen := resource.NewGeneratorAzurePathFixJob(
c.jobLister,
c.batchClient,
Expand Down
11 changes: 8 additions & 3 deletions pkg/resource/azurepathfixjob.go
Expand Up @@ -81,9 +81,14 @@ func (gapfj *generatorAzurePathFixJob) expected() (runtime.Object, error) {
return nil, fmt.Errorf("unable to get cluster proxy configuration: %v", err)
}

azureStorage := gapfj.cr.Status.Storage.Azure
if azureStorage == nil {
return fmt.Errorf("storage not yet provisioned")
}

envs := []corev1.EnvVar{
{Name: "AZURE_STORAGE_ACCOUNT_NAME", Value: gapfj.cr.Spec.Storage.Azure.AccountName}, // use cr.Status ?
{Name: "AZURE_CONTAINER_NAME", Value: gapfj.cr.Spec.Storage.Azure.Container},
{Name: "AZURE_STORAGE_ACCOUNT_NAME", Value: azureStorage.AccountName},
{Name: "AZURE_CONTAINER_NAME", Value: azureStorage.Container},
{Name: "AZURE_CLIENT_ID", Value: azureCfg.ClientID},
{Name: "AZURE_TENANT_ID", Value: azureCfg.TenantID},
{Name: "AZURE_CLIENT_SECRET", Value: azureCfg.ClientSecret},
Expand All @@ -98,7 +103,7 @@ func (gapfj *generatorAzurePathFixJob) expected() (runtime.Object, error) {
}},
}

if len(gapfj.cr.Spec.Storage.Azure.CloudName) > 0 {
if len(azureStorage.CloudName) > 0 {
envs = append(envs, corev1.EnvVar{Name: "AZURE_ENVIRONMENT", Value: gapfj.cr.Spec.Storage.Azure.CloudName})
}

Expand Down

0 comments on commit aceec22

Please sign in to comment.