Skip to content

Commit

Permalink
Applied deprecation message, set ID appropriately if missing (404)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed Nov 17, 2020
1 parent 0438cd0 commit bd7672e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions octopusdeploy/resource_account.go
Expand Up @@ -10,12 +10,13 @@ import (

func resourceAccount() *schema.Resource {
return &schema.Resource{
CreateContext: resourceAccountCreate,
DeleteContext: resourceAccountDeleteCommon,
Importer: getImporter(),
ReadContext: resourceAccountRead,
Schema: getAccountResourceSchema(),
UpdateContext: resourceAccountUpdate,
CreateContext: resourceAccountCreate,
DeleteContext: resourceAccountDeleteCommon,
DeprecationMessage: "use account-specific resource instead (i.e. octopusdeploy_aws_account, octopusdeploy_azure_service_principal, octopusdeploy_azure_subscription_account, octopusdeploy_ssh_key_account, octopusdeploy_token_account, octopusdeploy_username_password_account)",
Importer: getImporter(),
ReadContext: resourceAccountRead,
Schema: getAccountResourceSchema(),
UpdateContext: resourceAccountUpdate,
}
}

Expand All @@ -41,12 +42,13 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interfac
client := m.(*octopusdeploy.Client)
account, err := client.Accounts.GetByID(d.Id())
if err != nil {
apiError := err.(*octopusdeploy.APIError)
if apiError.StatusCode == 404 {
d.SetId("")
return nil
}
return diag.FromErr(err)
}
if account == nil {
d.SetId("")
return nil
}

accountResource := account.(*octopusdeploy.AccountResource)

Expand Down

0 comments on commit bd7672e

Please sign in to comment.