Skip to content

Commit

Permalink
fix(provider-generator): Render interpolationForAttribute instead of …
Browse files Browse the repository at this point in the history
…getAnyAttribute for skipped attributes since the latter doesn't actually exist
  • Loading branch information
ansgarm committed Sep 9, 2024
1 parent 549f694 commit abbb0c1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class DataAwsQuicksightAnalysis extends cdktf.TerraformDataSource {
// definition - computed: true, optional: false, required: false
public get definition() {
return this.getAnyAttribute('definition');
return this.interpolationForAttribute('definition');
}
// id - computed: true, optional: true, required: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface AttributeModelOptions {
getAttCall?: string;
provider: boolean;
required: boolean;
forcePlainGetterType?: boolean; // used for skipping attribute type attributes that use the SkippedAttributeTypeModel which returns an interpolation and has no stored type
}

export function escapeAttributeName(name: string) {
Expand Down Expand Up @@ -67,6 +68,7 @@ export class AttributeModel {
private _description?: string;
public provider: boolean;
public required: boolean;
public forcePlainGetterType?: boolean;

constructor(options: AttributeModelOptions) {
this.storageName = options.storageName;
Expand All @@ -79,6 +81,7 @@ export class AttributeModel {
this._description = options.description;
this.provider = options.provider;
this.required = options.required;
this.forcePlainGetterType = options.forcePlainGetterType;
}

public get typeDefinition() {
Expand All @@ -105,6 +108,10 @@ export class AttributeModel {
public get getterType(): GetterType {
let getterType: GetterType = { _type: "plain" };

if (this.forcePlainGetterType) {
return getterType;
}

if (this.isProvider) {
return getterType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,10 @@ class Parser {
block.attributes || {}
)) {
let type: AttributeTypeModel;
let forcePlainGetterType = false;
if (shouldSkipAttribute(parentType.fullName(terraformAttributeName))) {
type = new SimpleAttributeTypeModel("any");
type = new SkippedAttributeTypeModel();
forcePlainGetterType = true;
} else {
type = this.renderAttributeType(
[
Expand Down Expand Up @@ -430,6 +432,7 @@ class Parser {
type,
provider: parentType.isProvider,
required: !!att.required,
forcePlainGetterType,
})
);
}
Expand Down

0 comments on commit abbb0c1

Please sign in to comment.