Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tech-debt/structure: remove always nil error param from expandRedshiftParameters func #13665

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, error) {
return parameters, nil
}

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 @@ -592,10 +592,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