Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit f335cd3

Browse files
committed
fix: update type definitions for helpers
1 parent aebf095 commit f335cd3

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

test.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,22 @@ export const execContainer = async (
7676
};
7777
};
7878

79+
type TerraformStateResource = {
80+
type: string;
81+
name: string;
82+
provider: string;
83+
instances: [{ attributes: Record<string, any> }];
84+
};
85+
7986
export interface TerraformState {
8087
outputs: {
8188
[key: string]: {
8289
type: string;
8390
value: any;
8491
};
85-
}
86-
resources: [
87-
{
88-
type: string;
89-
name: string;
90-
provider: string;
91-
instances: [
92-
{
93-
attributes: {
94-
[key: string]: any;
95-
};
96-
},
97-
];
98-
},
99-
];
92+
};
93+
94+
resources: [TerraformStateResource, ...TerraformStateResource[]];
10095
}
10196

10297
export interface CoderScriptAttributes {
@@ -168,9 +163,11 @@ export const testRequiredVariables = (
168163
// runTerraformApply runs terraform apply in the given directory
169164
// with the given variables. It is fine to run in parallel with
170165
// other instances of this function, as it uses a random state file.
171-
export const runTerraformApply = async (
166+
export const runTerraformApply = async <
167+
TVars extends Readonly<Record<string, string>>,
168+
>(
172169
dir: string,
173-
vars: Record<string, string>,
170+
vars: TVars,
174171
): Promise<TerraformState> => {
175172
const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`;
176173
const env = {};
@@ -221,5 +218,5 @@ export const createJSONResponse = (obj: object, statusCode = 200): Response => {
221218
"Content-Type": "application/json",
222219
},
223220
status: statusCode,
224-
})
225-
}
221+
});
222+
};

0 commit comments

Comments
 (0)