Skip to content

Commit

Permalink
Improve error when SQL server doesn't have RG specified
Browse files Browse the repository at this point in the history
  - This fixes #1106.
  • Loading branch information
matthchr committed Jun 23, 2020
1 parent d0ac904 commit b327923
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/appinsights_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type AppInsightsSpec struct {
Kind string `json:"kind"`
Location string `json:"location"`
ApplicationType string `json:"applicationType"` // Possible values include 'web' or 'other'
ResourceGroup string `json:"resourceGroup,omitempty"`
ResourceGroup string `json:"resourceGroup"`
KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/azuresqlserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type AzureSqlServerSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Location string `json:"location"`
ResourceGroup string `json:"resourcegroup,omitempty"`
ResourceGroup string `json:"resourcegroup"`
KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/azuresqlserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type AzureSqlServerSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Location string `json:"location"`
ResourceGroup string `json:"resourceGroup,omitempty"`
ResourceGroup string `json:"resourceGroup"`
KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object,
if instance.Status.Provisioning ||
(!specHashWasEmpty && instance.Status.SpecHash == hash) {

// TODO: This is a bit of a hack because really this check should be in the SDK.
// TODO: See: https://github.com/Azure/azure-sdk-for-go/issues/10712
if instance.Spec.ResourceGroup == "" {
instance.Status.Message = "A nonempty resource group must be specified."
return false, nil
}

serv, err := s.GetServer(ctx, instance.Spec.ResourceGroup, instance.Name)
if err != nil {
azerr := errhelp.NewAzureErrorAzureError(err)
Expand Down

0 comments on commit b327923

Please sign in to comment.