Skip to content

Commit

Permalink
Merge pull request #31394 from hashicorp/td-createTags-inspector
Browse files Browse the repository at this point in the history
Tech debt: Reduce tags boilerplate code - Use `createTags`; Inspector
  • Loading branch information
ewbankkit committed May 12, 2023
2 parents 52ae8ed + fc84370 commit b39fdfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/service/inspector/assessment_template.go
Expand Up @@ -108,7 +108,7 @@ func resourceAssessmentTemplateCreate(ctx context.Context, d *schema.ResourceDat

d.SetId(aws.StringValue(output.AssessmentTemplateArn))

if err := updateTags(ctx, conn, d.Id(), nil, KeyValueTags(ctx, GetTagsIn(ctx))); err != nil {
if err := createTags(ctx, conn, d.Id(), GetTagsIn(ctx)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting Inspector Classic Assessment Template (%s) tags: %s", d.Id(), err)
}

Expand Down
8 changes: 8 additions & 0 deletions internal/service/inspector/tags.go
Expand Up @@ -49,6 +49,14 @@ func updateTags(ctx context.Context, conn inspectoriface.InspectorAPI, identifie
return nil
}

func createTags(ctx context.Context, conn inspectoriface.InspectorAPI, identifier string, tags []*inspector.Tag) error {
if len(tags) == 0 {
return nil
}

return updateTags(ctx, conn, identifier, nil, KeyValueTags(ctx, tags))
}

// UpdateTags updates Inspector Classic service tags.
// It is called from outside this package.
func (p *servicePackage) UpdateTags(ctx context.Context, meta any, identifier string, oldTags, newTags any) error {
Expand Down

0 comments on commit b39fdfb

Please sign in to comment.