Skip to content

Commit

Permalink
Fix for tagsProperty in CFN schema creation
Browse files Browse the repository at this point in the history
  • Loading branch information
kstich committed Nov 7, 2024
1 parent 31f10c5 commit 37e0dec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
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

0 comments on commit 37e0dec

Please sign in to comment.