Skip to content

Commit

Permalink
services: Clean up style
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Jul 22, 2022
1 parent 6e42982 commit 7a2014a
Show file tree
Hide file tree
Showing 181 changed files with 946 additions and 930 deletions.
4 changes: 2 additions & 2 deletions internal/service/accessanalyzer/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ func testAccCheckAnalyzerExists(resourceName string, analyzer *accessanalyzer.An
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
if !ok {
return fmt.Errorf("Resource not found: %s", resourceName)
return fmt.Errorf("resource not found: %s", resourceName)
}

if rs.Primary.ID == "" {
return fmt.Errorf("Resource (%s) ID not set", resourceName)
return fmt.Errorf("resource (%s) ID not set", resourceName)
}

conn := acctest.Provider.Meta().(*conns.AWSClient).AccessAnalyzerConn
Expand Down
4 changes: 2 additions & 2 deletions internal/service/accessanalyzer/archive_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func testAccCheckArchiveRuleDestroy(s *terraform.State) error {
return err
}

return fmt.Errorf("Expected AccessAnalyzer ArchiveRule to be destroyed, %s found", rs.Primary.ID)
return fmt.Errorf("expected AccessAnalyzer ArchiveRule to be destroyed, %s found", rs.Primary.ID)
}

return nil
Expand All @@ -192,7 +192,7 @@ func testAccCheckArchiveRuleExists(name string, archiveRule *accessanalyzer.Arch
resp, err := tfaccessanalyzer.FindArchiveRule(context.Background(), conn, analyzerName, ruleName)

if err != nil {
return fmt.Errorf("Error describing AccessAnalyzer ArchiveRule: %s", err.Error())
return fmt.Errorf("describing AccessAnalyzer ArchiveRule: %s", err.Error())
}

*archiveRule = *resp
Expand Down
4 changes: 2 additions & 2 deletions internal/service/acm/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ func ResourceCertificate() *schema.Resource {
// ACM automatically adds the domain_name value to the list of SANs. Mimic ACM's behavior
// so that the user doesn't need to explicitly set it themselves.
if diff.HasChange("domain_name") || diff.HasChange("subject_alternative_names") {
domain_name := diff.Get("domain_name").(string)
domainName := diff.Get("domain_name").(string)

if sanSet, ok := diff.Get("subject_alternative_names").(*schema.Set); ok {
sanSet.Add(domain_name)
sanSet.Add(domainName)
if err := diff.SetNew("subject_alternative_names", sanSet); err != nil {
return fmt.Errorf("error setting new subject_alternative_names diff: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/service/acm/certificate_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func dataSourceCertificateRead(d *schema.ResourceData, meta interface{}) error {
return true
})
if err != nil {
return fmt.Errorf("Error listing certificates: %w", err)
return fmt.Errorf("listing certificates: %w", err)
}

if len(arns) == 0 {
Expand Down Expand Up @@ -128,7 +128,7 @@ func dataSourceCertificateRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Describing ACM Certificate: %s", input)
output, err := conn.DescribeCertificate(input)
if err != nil {
return fmt.Errorf("Error describing ACM certificate: %w", err)
return fmt.Errorf("describing ACM certificate: %w", err)
}
certificate := output.Certificate

Expand Down
4 changes: 2 additions & 2 deletions internal/service/acm/certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,11 @@ func testAccCheckCertificateExists(n string, v *acm.CertificateDetail) resource.
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
return fmt.Errorf("not found: %s", n)
}

if rs.Primary.ID == "" {
return fmt.Errorf("No ACM Certificate ID is set")
return fmt.Errorf("no ACM Certificate ID is set")
}

conn := acctest.Provider.Meta().(*conns.AWSClient).ACMConn
Expand Down
4 changes: 2 additions & 2 deletions internal/service/acm/certificate_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ func testAccCheckCertificateValidationExists(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
return fmt.Errorf("not found: %s", n)
}

if rs.Primary.ID == "" {
return fmt.Errorf("No ACM Certificate Validation ID is set")
return fmt.Errorf("no ACM Certificate Validation ID is set")
}

conn := acctest.Provider.Meta().(*conns.AWSClient).ACMConn
Expand Down
16 changes: 8 additions & 8 deletions internal/service/acmpca/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func ResourceCertificate() *schema.Resource {
Importer: &schema.ResourceImporter{
State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
re := regexp.MustCompile(`arn:.+:certificate-authority/[^/]+`)
authorityArn := re.FindString(d.Id())
if authorityArn == "" {
authorityARN := re.FindString(d.Id())
if authorityARN == "" {
return nil, fmt.Errorf("Unexpected format for ID (%q), expected ACM PCA Certificate ARN", d.Id())
}

d.Set("certificate_authority_arn", authorityArn)
d.Set("certificate_authority_arn", authorityARN)

return []*schema.ResourceData{d}, nil
},
Expand Down Expand Up @@ -108,16 +108,16 @@ func ResourceCertificate() *schema.Resource {
func resourceCertificateCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).ACMPCAConn

certificateAuthorityArn := d.Get("certificate_authority_arn").(string)
certificateAuthorityARN := d.Get("certificate_authority_arn").(string)
input := &acmpca.IssueCertificateInput{
CertificateAuthorityArn: aws.String(certificateAuthorityArn),
CertificateAuthorityArn: aws.String(certificateAuthorityARN),
Csr: []byte(d.Get("certificate_signing_request").(string)),
IdempotencyToken: aws.String(resource.UniqueId()),
SigningAlgorithm: aws.String(d.Get("signing_algorithm").(string)),
}
validity, err := expandValidity(d.Get("validity").([]interface{}))
if err != nil {
return fmt.Errorf("error issuing ACM PCA Certificate with Certificate Authority (%s): %w", certificateAuthorityArn, err)
return fmt.Errorf("error issuing ACM PCA Certificate with Certificate Authority (%s): %w", certificateAuthorityARN, err)
}
input.Validity = validity

Expand All @@ -142,7 +142,7 @@ func resourceCertificateCreate(d *schema.ResourceData, meta interface{}) error {
}

if err != nil {
return fmt.Errorf("error issuing ACM PCA Certificate with Certificate Authority (%s): %w", certificateAuthorityArn, err)
return fmt.Errorf("error issuing ACM PCA Certificate with Certificate Authority (%s): %w", certificateAuthorityARN, err)
}

d.SetId(aws.StringValue(output.CertificateArn))
Expand All @@ -154,7 +154,7 @@ func resourceCertificateCreate(d *schema.ResourceData, meta interface{}) error {

err = conn.WaitUntilCertificateIssued(getCertificateInput)
if err != nil {
return fmt.Errorf("error waiting for ACM PCA Certificate Authority (%s) to issue Certificate (%s), error: %w", certificateAuthorityArn, d.Id(), err)
return fmt.Errorf("error waiting for ACM PCA Certificate Authority (%s) to issue Certificate (%s), error: %w", certificateAuthorityARN, d.Id(), err)
}

return resourceCertificateRead(d, meta)
Expand Down
8 changes: 4 additions & 4 deletions internal/service/acmpca/certificate_authority_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ func ResourceCertificateAuthorityCertificate() *schema.Resource {
func resourceCertificateAuthorityCertificateCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).ACMPCAConn

certificateAuthorityArn := d.Get("certificate_authority_arn").(string)
certificateAuthorityARN := d.Get("certificate_authority_arn").(string)

input := &acmpca.ImportCertificateAuthorityCertificateInput{
Certificate: []byte(d.Get("certificate").(string)),
CertificateAuthorityArn: aws.String(certificateAuthorityArn),
CertificateAuthorityArn: aws.String(certificateAuthorityARN),
}
if v, ok := d.Get("certificate_chain").(string); ok && v != "" {
input.CertificateChain = []byte(v)
}

_, err := conn.ImportCertificateAuthorityCertificate(input)
if err != nil {
return fmt.Errorf("error associating ACM PCA Certificate with Certificate Authority (%s): %w", certificateAuthorityArn, err)
return fmt.Errorf("error associating ACM PCA Certificate with Certificate Authority (%s): %w", certificateAuthorityARN, err)
}

d.SetId(certificateAuthorityArn)
d.SetId(certificateAuthorityARN)

return resourceCertificateAuthorityCertificateRead(d, meta)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func testAccCheckCertificateAuthorityCertificateExists(resourceName string, cert
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
if !ok {
return fmt.Errorf("Not found: %s", resourceName)
return fmt.Errorf("not found: %s", resourceName)
}

conn := acctest.Provider.Meta().(*conns.AWSClient).ACMPCAConn
Expand Down
14 changes: 7 additions & 7 deletions internal/service/acmpca/certificate_authority_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ func DataSourceCertificateAuthority() *schema.Resource {
func dataSourceCertificateAuthorityRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).ACMPCAConn
ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig
certificateAuthorityArn := d.Get("arn").(string)
certificateAuthorityARN := d.Get("arn").(string)

describeCertificateAuthorityInput := &acmpca.DescribeCertificateAuthorityInput{
CertificateAuthorityArn: aws.String(certificateAuthorityArn),
CertificateAuthorityArn: aws.String(certificateAuthorityARN),
}

log.Printf("[DEBUG] Reading ACM PCA Certificate Authority: %s", describeCertificateAuthorityInput)
Expand Down Expand Up @@ -151,7 +151,7 @@ func dataSourceCertificateAuthorityRead(d *schema.ResourceData, meta interface{}
d.Set("type", certificateAuthority.Type)

getCertificateAuthorityCertificateInput := &acmpca.GetCertificateAuthorityCertificateInput{
CertificateAuthorityArn: aws.String(certificateAuthorityArn),
CertificateAuthorityArn: aws.String(certificateAuthorityARN),
}

log.Printf("[DEBUG] Reading ACM PCA Certificate Authority Certificate: %s", getCertificateAuthorityCertificateInput)
Expand All @@ -173,7 +173,7 @@ func dataSourceCertificateAuthorityRead(d *schema.ResourceData, meta interface{}
}

getCertificateAuthorityCsrInput := &acmpca.GetCertificateAuthorityCsrInput{
CertificateAuthorityArn: aws.String(certificateAuthorityArn),
CertificateAuthorityArn: aws.String(certificateAuthorityARN),
}

log.Printf("[DEBUG] Reading ACM PCA Certificate Authority Certificate Signing Request: %s", getCertificateAuthorityCsrInput)
Expand All @@ -188,17 +188,17 @@ func dataSourceCertificateAuthorityRead(d *schema.ResourceData, meta interface{}
d.Set("certificate_signing_request", getCertificateAuthorityCsrOutput.Csr)
}

tags, err := ListTags(conn, certificateAuthorityArn)
tags, err := ListTags(conn, certificateAuthorityARN)

if err != nil {
return fmt.Errorf("error listing tags for ACM PCA Certificate Authority (%s): %w", certificateAuthorityArn, err)
return fmt.Errorf("error listing tags for ACM PCA Certificate Authority (%s): %w", certificateAuthorityARN, err)
}

if err := d.Set("tags", tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %w", err)
}

d.SetId(certificateAuthorityArn)
d.SetId(certificateAuthorityARN)

return nil
}
2 changes: 1 addition & 1 deletion internal/service/acmpca/certificate_authority_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func resourceCertificateAuthorityMigrateState(v int, is *terraform.InstanceState
log.Println("[INFO] Found ACM PCA Certificate Authority state v0; migrating to v1")
return migrateCertificateAuthorityStateV0toV1(is)
default:
return is, fmt.Errorf("Unexpected schema version: %d", v)
return is, fmt.Errorf("unexpected schema version: %d", v)
}
}

Expand Down
8 changes: 4 additions & 4 deletions internal/service/acmpca/certificate_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ func DataSourceCertificate() *schema.Resource {

func dataSourceCertificateRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).ACMPCAConn
certificateArn := d.Get("arn").(string)
certificateARN := d.Get("arn").(string)

getCertificateInput := &acmpca.GetCertificateInput{
CertificateArn: aws.String(certificateArn),
CertificateArn: aws.String(certificateARN),
CertificateAuthorityArn: aws.String(d.Get("certificate_authority_arn").(string)),
}

log.Printf("[DEBUG] Reading ACM PCA Certificate: %s", getCertificateInput)

certificateOutput, err := conn.GetCertificate(getCertificateInput)
if err != nil {
return fmt.Errorf("error reading ACM PCA Certificate (%s): %w", certificateArn, err)
return fmt.Errorf("error reading ACM PCA Certificate (%s): %w", certificateARN, err)
}

d.SetId(certificateArn)
d.SetId(certificateARN)
d.Set("certificate", certificateOutput.Certificate)
d.Set("certificate_chain", certificateOutput.CertificateChain)

Expand Down
2 changes: 1 addition & 1 deletion internal/service/acmpca/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func sweepCertificateAuthorities(region string) error {
log.Printf("[WARN] Skipping ACM PCA Certificate Authorities sweep for %s: %s", region, err)
return nil
}
return fmt.Errorf("Error retrieving ACM PCA Certificate Authorities: %w", err)
return fmt.Errorf("retrieving ACM PCA Certificate Authorities: %w", err)
}
if len(certificateAuthorities) == 0 {
log.Print("[DEBUG] No ACM PCA Certificate Authorities to sweep")
Expand Down
2 changes: 1 addition & 1 deletion internal/service/apigateway/api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func resourceAPIKeyCreate(d *schema.ResourceData, meta interface{}) error {
Tags: Tags(tags.IgnoreAWS()),
})
if err != nil {
return fmt.Errorf("Error creating API Gateway API Key: %s", err)
return fmt.Errorf("creating API Gateway API Key: %s", err)
}

d.SetId(aws.StringValue(apiKey.Id))
Expand Down
10 changes: 5 additions & 5 deletions internal/service/apigatewayv2/api_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func resourceAPIMappingCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Creating API Gateway v2 API mapping: %s", req)
resp, err := conn.CreateApiMapping(req)
if err != nil {
return fmt.Errorf("error creating API Gateway v2 API mapping: %s", err)
return fmt.Errorf("creating API Gateway v2 API mapping: %s", err)
}

d.SetId(aws.StringValue(resp.ApiMappingId))
Expand All @@ -81,7 +81,7 @@ func resourceAPIMappingRead(d *schema.ResourceData, meta interface{}) error {
return nil
}
if err != nil {
return fmt.Errorf("error reading API Gateway v2 API mapping: %s", err)
return fmt.Errorf("reading API Gateway v2 API mapping: %s", err)
}

d.Set("api_id", resp.ApiId)
Expand Down Expand Up @@ -109,7 +109,7 @@ func resourceAPIMappingUpdate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Updating API Gateway v2 API mapping: %s", req)
_, err := conn.UpdateApiMapping(req)
if err != nil {
return fmt.Errorf("error updating API Gateway v2 API mapping: %s", err)
return fmt.Errorf("updating API Gateway v2 API mapping: %s", err)
}

return resourceAPIMappingRead(d, meta)
Expand All @@ -127,7 +127,7 @@ func resourceAPIMappingDelete(d *schema.ResourceData, meta interface{}) error {
return nil
}
if err != nil {
return fmt.Errorf("error deleting API Gateway v2 API mapping: %s", err)
return fmt.Errorf("deleting API Gateway v2 API mapping: %s", err)
}

return nil
Expand All @@ -136,7 +136,7 @@ func resourceAPIMappingDelete(d *schema.ResourceData, meta interface{}) error {
func resourceAPIMappingImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
parts := strings.Split(d.Id(), "/")
if len(parts) != 2 {
return []*schema.ResourceData{}, fmt.Errorf("Wrong format of resource: %s. Please follow 'api-mapping-id/domain-name'", d.Id())
return []*schema.ResourceData{}, fmt.Errorf("wrong format of import ID (%s), use: 'api-mapping-id/domain-name'", d.Id())
}

d.SetId(parts[0])
Expand Down
16 changes: 8 additions & 8 deletions internal/service/apigatewayv2/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func resourceAuthorizerCreate(d *schema.ResourceData, meta interface{}) error {
apiOutput, err := FindAPIByID(conn, apiId)

if err != nil {
return fmt.Errorf("error reading API Gateway v2 API (%s): %s", apiId, err)
return fmt.Errorf("reading API Gateway v2 API (%s): %s", apiId, err)
}

protocolType := aws.StringValue(apiOutput.ProtocolType)
Expand Down Expand Up @@ -140,7 +140,7 @@ func resourceAuthorizerCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Creating API Gateway v2 authorizer: %s", req)
resp, err := conn.CreateAuthorizer(req)
if err != nil {
return fmt.Errorf("error creating API Gateway v2 authorizer: %s", err)
return fmt.Errorf("creating API Gateway v2 authorizer: %s", err)
}

d.SetId(aws.StringValue(resp.AuthorizerId))
Expand All @@ -161,7 +161,7 @@ func resourceAuthorizerRead(d *schema.ResourceData, meta interface{}) error {
return nil
}
if err != nil {
return fmt.Errorf("error reading API Gateway v2 authorizer: %s", err)
return fmt.Errorf("reading API Gateway v2 authorizer: %s", err)
}

d.Set("authorizer_credentials_arn", resp.AuthorizerCredentialsArn)
Expand All @@ -171,10 +171,10 @@ func resourceAuthorizerRead(d *schema.ResourceData, meta interface{}) error {
d.Set("authorizer_uri", resp.AuthorizerUri)
d.Set("enable_simple_responses", resp.EnableSimpleResponses)
if err := d.Set("identity_sources", flex.FlattenStringSet(resp.IdentitySource)); err != nil {
return fmt.Errorf("error setting identity_sources: %s", err)
return fmt.Errorf("setting identity_sources: %s", err)
}
if err := d.Set("jwt_configuration", flattenJWTConfiguration(resp.JwtConfiguration)); err != nil {
return fmt.Errorf("error setting jwt_configuration: %s", err)
return fmt.Errorf("setting jwt_configuration: %s", err)
}
d.Set("name", resp.Name)

Expand Down Expand Up @@ -219,7 +219,7 @@ func resourceAuthorizerUpdate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Updating API Gateway v2 authorizer: %s", req)
_, err := conn.UpdateAuthorizer(req)
if err != nil {
return fmt.Errorf("error updating API Gateway v2 authorizer: %s", err)
return fmt.Errorf("updating API Gateway v2 authorizer: %s", err)
}

return resourceAuthorizerRead(d, meta)
Expand All @@ -237,7 +237,7 @@ func resourceAuthorizerDelete(d *schema.ResourceData, meta interface{}) error {
return nil
}
if err != nil {
return fmt.Errorf("error deleting API Gateway v2 authorizer: %s", err)
return fmt.Errorf("deleting API Gateway v2 authorizer: %s", err)
}

return nil
Expand All @@ -246,7 +246,7 @@ func resourceAuthorizerDelete(d *schema.ResourceData, meta interface{}) error {
func resourceAuthorizerImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
parts := strings.Split(d.Id(), "/")
if len(parts) != 2 {
return []*schema.ResourceData{}, fmt.Errorf("Wrong format of resource: %s. Please follow 'api-id/authorizer-id'", d.Id())
return []*schema.ResourceData{}, fmt.Errorf("wrong format of import ID (%s), use: 'api-id/authorizer-id'", d.Id())
}

d.SetId(parts[1])
Expand Down
Loading

0 comments on commit 7a2014a

Please sign in to comment.