Skip to content

Commit

Permalink
azure: resource group testing complete
Browse files Browse the repository at this point in the history
Signed-off-by: HashedDan <georgedanielmangum@gmail.com>
  • Loading branch information
hasheddan committed Apr 23, 2019
1 parent f678b2e commit bbec93c
Show file tree
Hide file tree
Showing 3 changed files with 437 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pkg/clients/azure/resourcegroup/fake/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ func (m *MockClient) CheckExistence(ctx context.Context, resourceGroupName strin
}

// DeleteGroup calls the underlying MockDeleteGroup method.
func (m *MockClient) DeleteGroup(ctx context.Context, resourceGroupName string) (result resources.GroupsDeleteFuture, err error) {
func (m *MockClient) Delete(ctx context.Context, resourceGroupName string) (result resources.GroupsDeleteFuture, err error) {
return m.MockDelete(ctx, resourceGroupName)
}
8 changes: 5 additions & 3 deletions pkg/controller/azure/provider/resourcegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const (
reasonDeletingResource = "failed to delete Azure Resource Group resource"
reasonSyncingResource = "failed to sync Azure Resource Group resource"

azureDeletedMessage = "resource has been deleted on Azure"

reconcileTimeout = 1 * time.Minute
)

Expand Down Expand Up @@ -119,8 +121,9 @@ func (a *azureResourceGroup) Sync(ctx context.Context, r *v1alpha1.ResourceGroup
case 204:
r.Status.SetReady()
case 404:
r.Status.SetDeleting()
return false
// Custom message passed to SetFailed due to Azure API returning 404 instead of error
r.Status.SetFailed(reasonSyncingResource, azureDeletedMessage)
return true
default:
return true
}
Expand All @@ -131,7 +134,6 @@ func (a *azureResourceGroup) Sync(ctx context.Context, r *v1alpha1.ResourceGroup
func (a *azureResourceGroup) Delete(ctx context.Context, r *v1alpha1.ResourceGroup) bool {
if r.Spec.ReclaimPolicy == corev1alpha1.ReclaimDelete {
if _, err := a.client.Delete(ctx, r.Spec.Name); err != nil {

r.Status.SetFailed(reasonDeletingResource, err.Error())
return true
}
Expand Down
Loading

0 comments on commit bbec93c

Please sign in to comment.