Skip to content

Commit

Permalink
Merge pull request #13665 from terraform-providers/ap_unparam_linting…
Browse files Browse the repository at this point in the history
…_expandredshiftparameters

tech-debt/structure: remove always nil error param from expandRedshiftParameters func
  • Loading branch information
anGie44 authored Jun 12, 2020
2 parents 747c204 + 3837c3f commit 684e66e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
15 changes: 4 additions & 11 deletions aws/resource_aws_redshift_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ func resourceAwsRedshiftParameterGroupCreate(d *schema.ResourceData, meta interf
d.SetId(*createOpts.ParameterGroupName)

if v := d.Get("parameter").(*schema.Set); v.Len() > 0 {
parameters, err := expandRedshiftParameters(v.List())

if err != nil {
return fmt.Errorf("error expanding parameter: %s", err)
}
parameters := expandRedshiftParameters(v.List())

modifyOpts := redshift.ModifyClusterParameterGroupInput{
ParameterGroupName: aws.String(d.Id()),
Expand Down Expand Up @@ -134,7 +130,7 @@ func resourceAwsRedshiftParameterGroupRead(d *schema.ResourceData, meta interfac
}

if len(describeResp.ParameterGroups) != 1 ||
*describeResp.ParameterGroups[0].ParameterGroupName != d.Id() {
aws.StringValue(describeResp.ParameterGroups[0].ParameterGroupName) != d.Id() {
d.SetId("")
return fmt.Errorf("Unable to find Parameter Group: %#v", describeResp.ParameterGroups)
}
Expand Down Expand Up @@ -186,10 +182,7 @@ func resourceAwsRedshiftParameterGroupUpdate(d *schema.ResourceData, meta interf
ns := n.(*schema.Set)

// Expand the "parameter" set to aws-sdk-go compat []redshift.Parameter
parameters, err := expandRedshiftParameters(ns.Difference(os).List())
if err != nil {
return err
}
parameters := expandRedshiftParameters(ns.Difference(os).List())

if len(parameters) > 0 {
modifyOpts := redshift.ModifyClusterParameterGroupInput{
Expand All @@ -198,7 +191,7 @@ func resourceAwsRedshiftParameterGroupUpdate(d *schema.ResourceData, meta interf
}

log.Printf("[DEBUG] Modify Redshift Parameter Group: %s", modifyOpts)
_, err = conn.ModifyClusterParameterGroup(&modifyOpts)
_, err := conn.ModifyClusterParameterGroup(&modifyOpts)
if err != nil {
return fmt.Errorf("Error modifying Redshift Parameter Group: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions aws/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func expandParameters(configured []interface{}) []*rds.Parameter {
return parameters
}

func expandRedshiftParameters(configured []interface{}) ([]*redshift.Parameter, error) {
func expandRedshiftParameters(configured []interface{}) []*redshift.Parameter {
var parameters []*redshift.Parameter

// Loop over our configured parameters and create
Expand All @@ -365,7 +365,7 @@ func expandRedshiftParameters(configured []interface{}) ([]*redshift.Parameter,
parameters = append(parameters, p)
}

return parameters, nil
return parameters
}

// Takes the result of flatmap.Expand for an array of parameters and
Expand Down
5 changes: 1 addition & 4 deletions aws/structure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,7 @@ func TestExpandRedshiftParameters(t *testing.T) {
"value": "utf8",
},
}
parameters, err := expandRedshiftParameters(expanded)
if err != nil {
t.Fatalf("bad: %#v", err)
}
parameters := expandRedshiftParameters(expanded)

expected := &redshift.Parameter{
ParameterName: aws.String("character_set_client"),
Expand Down

0 comments on commit 684e66e

Please sign in to comment.