Skip to content

Commit

Permalink
Renamed function using set verb (more accurate)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed Nov 15, 2020
1 parent ebd05fa commit 08c609c
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion octopusdeploy/data_source_environments.go
Expand Up @@ -35,6 +35,6 @@ func dataSourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, m in

environment := environments[0]

flattenEnvironment(ctx, d, environment)
setEnvironment(ctx, d, environment)
return nil
}
6 changes: 3 additions & 3 deletions octopusdeploy/resource_aws_account.go
Expand Up @@ -30,7 +30,7 @@ func resourceAmazonWebServicesAccountCreate(ctx context.Context, d *schema.Resou

createdAmazonWebServicesAccount := createdAccount.(*octopusdeploy.AmazonWebServicesAccount)

flattenAmazonWebServicesAccount(ctx, d, createdAmazonWebServicesAccount)
setAmazonWebServicesAccount(ctx, d, createdAmazonWebServicesAccount)
return nil
}

Expand All @@ -52,7 +52,7 @@ func resourceAmazonWebServicesAccountRead(ctx context.Context, d *schema.Resourc

amazonWebServicesAccount := accountResource.(*octopusdeploy.AmazonWebServicesAccount)

flattenAmazonWebServicesAccount(ctx, d, amazonWebServicesAccount)
setAmazonWebServicesAccount(ctx, d, amazonWebServicesAccount)
return nil
}

Expand All @@ -67,6 +67,6 @@ func resourceAmazonWebServicesAccountUpdate(ctx context.Context, d *schema.Resou

updatedAmazonWebServicesAccount := updatedAccount.(*octopusdeploy.AmazonWebServicesAccount)

flattenAmazonWebServicesAccount(ctx, d, updatedAmazonWebServicesAccount)
setAmazonWebServicesAccount(ctx, d, updatedAmazonWebServicesAccount)
return nil
}
6 changes: 3 additions & 3 deletions octopusdeploy/resource_azure_service_principal_account.go
Expand Up @@ -30,7 +30,7 @@ func resourceAzureServicePrincipalAccountCreate(ctx context.Context, d *schema.R

createdAzureSubscriptionAccount := accountResource.(*octopusdeploy.AzureServicePrincipalAccount)

flattenAzureServicePrincipalAccount(ctx, d, createdAzureSubscriptionAccount)
setAzureServicePrincipalAccount(ctx, d, createdAzureSubscriptionAccount)
return nil
}

Expand All @@ -52,7 +52,7 @@ func resourceAzureServicePrincipalAccountRead(ctx context.Context, d *schema.Res

azureSubscriptionAccount := accountResource.(*octopusdeploy.AzureServicePrincipalAccount)

flattenAzureServicePrincipalAccount(ctx, d, azureSubscriptionAccount)
setAzureServicePrincipalAccount(ctx, d, azureSubscriptionAccount)
return nil
}

Expand All @@ -72,6 +72,6 @@ func resourceAzureServicePrincipalAccountUpdate(ctx context.Context, d *schema.R

updatedAzureSubscriptionAccount := accountResource.(*octopusdeploy.AzureServicePrincipalAccount)

flattenAzureServicePrincipalAccount(ctx, d, updatedAzureSubscriptionAccount)
setAzureServicePrincipalAccount(ctx, d, updatedAzureSubscriptionAccount)
return nil
}
6 changes: 3 additions & 3 deletions octopusdeploy/resource_azure_subscription_account.go
Expand Up @@ -30,7 +30,7 @@ func resourceAzureSubscriptionAccountCreate(ctx context.Context, d *schema.Resou

createdAzureSubscriptionAccount := accountResource.(*octopusdeploy.AzureSubscriptionAccount)

flattenAzureSubscriptionAccount(ctx, d, createdAzureSubscriptionAccount)
setAzureSubscriptionAccount(ctx, d, createdAzureSubscriptionAccount)
return nil
}

Expand All @@ -52,7 +52,7 @@ func resourceAzureSubscriptionAccountRead(ctx context.Context, d *schema.Resourc

azureSubscriptionAccount := accountResource.(*octopusdeploy.AzureSubscriptionAccount)

flattenAzureSubscriptionAccount(ctx, d, azureSubscriptionAccount)
setAzureSubscriptionAccount(ctx, d, azureSubscriptionAccount)
return nil
}

Expand All @@ -72,6 +72,6 @@ func resourceAzureSubscriptionAccountUpdate(ctx context.Context, d *schema.Resou

updatedAzureSubscriptionAccount := accountResource.(*octopusdeploy.AzureSubscriptionAccount)

flattenAzureSubscriptionAccount(ctx, d, updatedAzureSubscriptionAccount)
setAzureSubscriptionAccount(ctx, d, updatedAzureSubscriptionAccount)
return nil
}
6 changes: 3 additions & 3 deletions octopusdeploy/resource_certificate.go
Expand Up @@ -28,7 +28,7 @@ func resourceCertificateCreate(ctx context.Context, d *schema.ResourceData, m in
return diag.FromErr(err)
}

flattenCertificate(ctx, d, createdCertificate)
setCertificate(ctx, d, createdCertificate)
return nil
}

Expand All @@ -50,7 +50,7 @@ func resourceCertificateRead(ctx context.Context, d *schema.ResourceData, m inte
diag.FromErr(err)
}

flattenCertificate(ctx, d, certificate)
setCertificate(ctx, d, certificate)
return nil
}

Expand All @@ -63,6 +63,6 @@ func resourceCertificateUpdate(ctx context.Context, d *schema.ResourceData, m in
return diag.FromErr(err)
}

flattenCertificate(ctx, d, updatedCertificate)
setCertificate(ctx, d, updatedCertificate)
return nil
}
6 changes: 3 additions & 3 deletions octopusdeploy/resource_deployment_target.go
Expand Up @@ -29,7 +29,7 @@ func resourceDeploymentTargetCreate(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(err)
}

flattenDeploymentTarget(ctx, d, createdDeploymentTarget)
setDeploymentTarget(ctx, d, createdDeploymentTarget)
return nil
}

Expand All @@ -51,7 +51,7 @@ func resourceDeploymentTargetRead(ctx context.Context, d *schema.ResourceData, m
return diag.FromErr(err)
}

flattenDeploymentTarget(ctx, d, deploymentTarget)
setDeploymentTarget(ctx, d, deploymentTarget)
return nil
}

Expand All @@ -64,6 +64,6 @@ func resourceDeploymentTargetUpdate(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(err)
}

flattenDeploymentTarget(ctx, d, updatedDeploymentTarget)
setDeploymentTarget(ctx, d, updatedDeploymentTarget)
return nil
}
6 changes: 3 additions & 3 deletions octopusdeploy/resource_environment.go
Expand Up @@ -28,7 +28,7 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, m in
return diag.FromErr(err)
}

flattenEnvironment(ctx, d, createdEnvironment)
setEnvironment(ctx, d, createdEnvironment)
return nil
}

Expand All @@ -39,7 +39,7 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, m inte
return diag.FromErr(err)
}

flattenEnvironment(ctx, d, environment)
setEnvironment(ctx, d, environment)
return nil
}

Expand All @@ -52,7 +52,7 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, m in
return diag.FromErr(err)
}

flattenEnvironment(ctx, d, updatedEnvironment)
setEnvironment(ctx, d, updatedEnvironment)
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions octopusdeploy/resource_project.go
Expand Up @@ -28,7 +28,7 @@ func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, m interf
return diag.FromErr(err)
}

flattenProject(ctx, d, createdProject)
setProject(ctx, d, createdProject)
return nil
}

Expand All @@ -50,7 +50,7 @@ func resourceProjectRead(ctx context.Context, d *schema.ResourceData, m interfac
return diag.FromErr(err)
}

flattenProject(ctx, d, project)
setProject(ctx, d, project)
return nil
}

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

flattenProject(ctx, d, updatedProject)
setProject(ctx, d, updatedProject)
return nil
}
6 changes: 3 additions & 3 deletions octopusdeploy/resource_space.go
Expand Up @@ -28,7 +28,7 @@ func resourceSpaceCreate(ctx context.Context, d *schema.ResourceData, m interfac
return diag.FromErr(err)
}

flattenSpace(ctx, d, createdSpace)
setSpace(ctx, d, createdSpace)
return nil
}

Expand Down Expand Up @@ -58,7 +58,7 @@ func resourceSpaceRead(ctx context.Context, d *schema.ResourceData, m interface{
return diag.FromErr(err)
}

flattenSpace(ctx, d, space)
setSpace(ctx, d, space)
return nil
}

Expand All @@ -71,6 +71,6 @@ func resourceSpaceUpdate(ctx context.Context, d *schema.ResourceData, m interfac
return diag.FromErr(err)
}

flattenSpace(ctx, d, updatedSpace)
setSpace(ctx, d, updatedSpace)
return nil
}
8 changes: 4 additions & 4 deletions octopusdeploy/resource_sshkey_account.go
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func resourceSSHKey() *schema.Resource {
func resourceSSHKeyAccount() *schema.Resource {
return &schema.Resource{
CreateContext: resourceSSHKeyAccountCreate,
DeleteContext: resourceAccountDeleteCommon,
Expand All @@ -30,7 +30,7 @@ func resourceSSHKeyAccountCreate(ctx context.Context, d *schema.ResourceData, m

createdSSHKeyAccount := createdAccount.(*octopusdeploy.SSHKeyAccount)

flattenSSHKeyAccount(ctx, d, createdSSHKeyAccount)
setSSHKeyAccount(ctx, d, createdSSHKeyAccount)
return nil
}

Expand All @@ -52,7 +52,7 @@ func resourceSSHKeyAccountRead(ctx context.Context, d *schema.ResourceData, m in

sshKeyAccount := accountResource.(*octopusdeploy.SSHKeyAccount)

flattenSSHKeyAccount(ctx, d, sshKeyAccount)
setSSHKeyAccount(ctx, d, sshKeyAccount)
return nil
}

Expand All @@ -72,6 +72,6 @@ func resourceSSHKeyAccountUpdate(ctx context.Context, d *schema.ResourceData, m

updatedSSHKeyAccount := accountResource.(*octopusdeploy.SSHKeyAccount)

flattenSSHKeyAccount(ctx, d, updatedSSHKeyAccount)
setSSHKeyAccount(ctx, d, updatedSSHKeyAccount)
return nil
}
6 changes: 3 additions & 3 deletions octopusdeploy/resource_token_account.go
Expand Up @@ -31,7 +31,7 @@ func resourceTokenAccountCreate(ctx context.Context, d *schema.ResourceData, m i
createdTokenAccount := createdAccount.(*octopusdeploy.TokenAccount)
createdTokenAccount.Token = account.Token

flattenTokenAccount(ctx, d, createdTokenAccount)
setTokenAccount(ctx, d, createdTokenAccount)
return nil
}

Expand All @@ -53,7 +53,7 @@ func resourceTokenAccountRead(ctx context.Context, d *schema.ResourceData, m int

tokenAccount := accountResource.(*octopusdeploy.TokenAccount)

flattenTokenAccount(ctx, d, tokenAccount)
setTokenAccount(ctx, d, tokenAccount)
return nil
}

Expand All @@ -74,6 +74,6 @@ func resourceTokenAccountUpdate(ctx context.Context, d *schema.ResourceData, m i
updatedTokenAccount := accountResource.(*octopusdeploy.TokenAccount)
updatedTokenAccount.Token = account.Token

flattenTokenAccount(ctx, d, updatedTokenAccount)
setTokenAccount(ctx, d, updatedTokenAccount)
return nil
}
4 changes: 2 additions & 2 deletions octopusdeploy/schema_amazon_web_services_account.go
Expand Up @@ -31,8 +31,8 @@ func expandAmazonWebServicesAccount(d *schema.ResourceData) *octopusdeploy.Amazo
return account
}

func flattenAmazonWebServicesAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.AmazonWebServicesAccount) {
flattenAccount(ctx, d, account)
func setAmazonWebServicesAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.AmazonWebServicesAccount) {
setAccount(ctx, d, account)

d.Set("account_type", "AmazonWebServicesAccount")
d.Set("access_key", account.AccessKey)
Expand Down
4 changes: 2 additions & 2 deletions octopusdeploy/schema_azure_service_principal_account.go
Expand Up @@ -60,8 +60,8 @@ func expandAzureServicePrincipalAccount(d *schema.ResourceData) *octopusdeploy.A
return account
}

func flattenAzureServicePrincipalAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.AzureServicePrincipalAccount) {
flattenAccount(ctx, d, account)
func setAzureServicePrincipalAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.AzureServicePrincipalAccount) {
setAccount(ctx, d, account)

d.Set("account_type", "AzureServicePrincipal")
d.Set("application_id", account.ApplicationID.String())
Expand Down
4 changes: 2 additions & 2 deletions octopusdeploy/schema_azure_subscription_account.go
Expand Up @@ -72,8 +72,8 @@ func expandAzureSubscriptionAccount(d *schema.ResourceData) *octopusdeploy.Azure
return account
}

func flattenAzureSubscriptionAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.AzureSubscriptionAccount) {
flattenAccount(ctx, d, account)
func setAzureSubscriptionAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.AzureSubscriptionAccount) {
setAccount(ctx, d, account)

d.Set("account_type", "AzureSubscription")
d.Set("azure_environment", account.AzureEnvironment)
Expand Down
4 changes: 2 additions & 2 deletions octopusdeploy/schema_ssh_key_account.go
Expand Up @@ -30,8 +30,8 @@ func expandSSHKeyAccount(d *schema.ResourceData) *octopusdeploy.SSHKeyAccount {
return account
}

func flattenSSHKeyAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.SSHKeyAccount) {
flattenAccount(ctx, d, account)
func setSSHKeyAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.SSHKeyAccount) {
setAccount(ctx, d, account)

d.Set("account_type", "SshKeyPair")
d.Set("private_key_file", account.PrivateKeyFile)
Expand Down
4 changes: 2 additions & 2 deletions octopusdeploy/schema_token_account.go
Expand Up @@ -41,8 +41,8 @@ func expandTokenAccount(d *schema.ResourceData) *octopusdeploy.TokenAccount {
return account
}

func flattenTokenAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.TokenAccount) {
flattenAccount(ctx, d, account)
func setTokenAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.TokenAccount) {
setAccount(ctx, d, account)

d.Set("account_type", "Token")
d.Set("token", account.Token.NewValue)
Expand Down
7 changes: 4 additions & 3 deletions octopusdeploy/schema_username_password_account.go
Expand Up @@ -47,8 +47,8 @@ func expandUsernamePasswordAccount(d *schema.ResourceData) *octopusdeploy.Userna
return account
}

func flattenUsernamePasswordAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.UsernamePasswordAccount) {
flattenAccount(ctx, d, account)
func setUsernamePasswordAccount(ctx context.Context, d *schema.ResourceData, account *octopusdeploy.UsernamePasswordAccount) {
setAccount(ctx, d, account)

d.Set("account_type", "UsernamePassword")
d.Set("username", account.Username)
Expand All @@ -60,11 +60,12 @@ func flattenUsernamePasswordAccount(ctx context.Context, d *schema.ResourceData,
func getUsernamePasswordAccountSchema() map[string]*schema.Schema {
schemaMap := getAccountSchema()
schemaMap["account_type"] = &schema.Schema{
Optional: true,
Default: "UsernamePassword",
Optional: true,
Type: schema.TypeString,
}
schemaMap["password"] = &schema.Schema{
Sensitive: true,
Optional: true,
Type: schema.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
Expand Down

0 comments on commit 08c609c

Please sign in to comment.