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

Fix for tagsProperty in CFN schema creation #2444

Merged
merged 1 commit into from
Nov 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private ResourceSchema convertResource(ConversionEnvironment environment, Resour
Tagging.Builder tagBuilder = Tagging.builder()
.taggable(true)
.tagOnCreate(tagsIndex.isResourceTagOnCreate(resourceShape.getId()))
.tagProperty(getTagsProperty(resourceShape))
.tagProperty("/properties/" + getTagMemberName(resourceShape))
.cloudFormationSystemTags(!trait.getDisableSystemTags())
// Unless tag-on-create is supported, Smithy tagging means
.tagUpdatable(true);
Expand Down Expand Up @@ -396,7 +396,7 @@ private StructureShape getCfnResourceStructure(Model model, ResourceShape resour
return builder.build();
}

private String getTagsProperty(ResourceShape resource) {
private String getTagMemberName(ResourceShape resource) {
return resource.getTrait(TaggableTrait.class)
.flatMap(TaggableTrait::getProperty)
.map(property -> {
Expand All @@ -414,21 +414,21 @@ private void injectTagsIfNecessary(
ResourceShape resource,
CfnResource cfnResource
) {
String tagPropertyName = getTagsProperty(resource);
String tagMemberName = getTagMemberName(resource);
if (resource.hasTrait(TaggableTrait.class)) {
AwsTagIndex tagIndex = AwsTagIndex.of(model);
TaggableTrait trait = resource.expectTrait(TaggableTrait.class);
if (!trait.getProperty().isPresent() || !cfnResource.getProperties()
.containsKey(trait.getProperty().get())) {
if (trait.getProperty().isPresent()) {
ShapeId definition = resource.getProperties().get(trait.getProperty().get());
builder.addMember(tagPropertyName, definition);
builder.addMember(tagMemberName, definition);
} else {
// A valid TagResource operation certainly has a single tags input member.
AwsTagIndex awsTagIndex = AwsTagIndex.of(model);
Optional<ShapeId> tagOperation = tagIndex.getTagResourceOperation(resource.getId());
MemberShape member = awsTagIndex.getTagsMember(tagOperation.get()).get();
member = member.toBuilder().id(builder.getId().withMember(tagPropertyName)).build();
member = member.toBuilder().id(builder.getId().withMember(tagMemberName)).build();
builder.addMember(member);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
},
"tagging": {
"tagOnCreate": false,
"tagProperty": "Tags",
"tagProperty": "/properties/Tags",
"tagUpdatable": true,
"cloudFormationSystemTags": true,
"taggable": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"tagging": {
"tagOnCreate": false,
"tagProperty": "Tags",
"tagProperty": "/properties/Tags",
"tagUpdatable": true,
"cloudFormationSystemTags": true,
"taggable": true
Expand Down
Loading