Skip to content

Commit

Permalink
fix(provider-generator): fix oci provider by skipping attributes that…
Browse files Browse the repository at this point in the history
… conflict after being camel cased
  • Loading branch information
ansgarm committed Nov 21, 2023
1 parent 9f70e6f commit 19768a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/@cdktf/commons/src/provider-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface BaseAttribute {
optional?: boolean;
computed?: boolean;
sensitive?: boolean;
deprecated?: boolean;
}

interface NestedTypeAttribute extends BaseAttribute {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Parser {
const fileName = getFileName(provider, baseName);

const filePath = `providers/${toSnakeCase(provider)}/${fileName}`;
const attributes = this.renderAttributesForBlock(
let attributes = this.renderAttributesForBlock(
new Scope({
name: baseName,
isProvider,
Expand Down Expand Up @@ -211,6 +211,17 @@ class Parser {
}
);

// Remove deprecated attributes that may conflict after being snake cased
// Example: oci_core_ipsec_connection_tunnel_management (hashicorp/oci@=5.21.0) has bgp_ipv6_state and bgp_ipv6state
// (which both result in "bgpIpv6State" when camel-cased, with the second one being deprecated: true)
// As we currently don't handle any deprecated ones at all, we'll just delete one of the two attributes for now
attributes = attributes.filter((attr, idx) => {
const hasOtherWithSameName = attributes
.slice(idx + 1) // only search after the index of the current attribute to avoid deleting both
.some((other) => other.name === attr.name && other !== attr);
return !hasOtherWithSameName;
});

const resourceModel = new ResourceModel({
terraformType: type,
baseName,
Expand Down

0 comments on commit 19768a4

Please sign in to comment.