Skip to content

Commit

Permalink
Refactored into schema file; updated function name (more accurate)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed Nov 15, 2020
1 parent f78d0b4 commit 6be341d
Showing 1 changed file with 3 additions and 69 deletions.
72 changes: 3 additions & 69 deletions octopusdeploy/resource_account.go
Expand Up @@ -6,75 +6,9 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func resourceAccount() *schema.Resource {
resourceAccountSchema := getAccountResourceSchema()
resourceAccountSchema["access_key"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
}
resourceAccountSchema["active_directory_endpoint_base_uri"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
}
resourceAccountSchema["azure_environment"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
}
resourceAccountSchema["client_id"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
ValidateDiagFunc: validateDiagFunc(validation.IsUUID),
}
resourceAccountSchema["client_secret"] = &schema.Schema{
Optional: true,
Sensitive: true,
Type: schema.TypeString,
}
resourceAccountSchema["key"] = &schema.Schema{
Optional: true,
Sensitive: true,
Type: schema.TypeString,
}
resourceAccountSchema["password"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
}
resourceAccountSchema["passphrase"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
}
resourceAccountSchema["secret_key"] = &schema.Schema{
Optional: true,
Sensitive: true,
Type: schema.TypeString,
}
resourceAccountSchema["token"] = &schema.Schema{
Optional: true,
Sensitive: true,
Type: schema.TypeString,
}
resourceAccountSchema["resource_management_endpoint_base_uri"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
}
resourceAccountSchema["subscription_id"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
ValidateDiagFunc: validateDiagFunc(validation.IsUUID),
}
resourceAccountSchema["tenant_id"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
ValidateDiagFunc: validateDiagFunc(validation.IsUUID),
}
resourceAccountSchema["username"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
}

return &schema.Resource{
CreateContext: resourceAccountCreate,
DeleteContext: resourceAccountDeleteCommon,
Expand All @@ -99,7 +33,7 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interf
return diag.FromErr(err)
}

flattenAccountResource(ctx, d, accountResource)
setAccountResource(ctx, d, accountResource)
return nil
}

Expand All @@ -116,7 +50,7 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interfac

accountResource := account.(*octopusdeploy.AccountResource)

flattenAccountResource(ctx, d, accountResource)
setAccountResource(ctx, d, accountResource)
return nil
}

Expand All @@ -134,6 +68,6 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
return diag.FromErr(err)
}

flattenAccountResource(ctx, d, accountResource)
setAccountResource(ctx, d, accountResource)
return nil
}

0 comments on commit 6be341d

Please sign in to comment.