Skip to content

Commit 1f2dfd7

Browse files
committed
fix incorrect MultiCOntainerWorkload types
1 parent 168cf94 commit 1f2dfd7

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
registry-url: 'https://registry.npmjs.org'
159159

160160
- name: Update npm to latest
161-
run: npm install -g npm@latest
161+
run: bun install -g npm@latest
162162

163163
- name: Create GitHub Release
164164
id: create_release

scripts/code-generation/generate-augmented-props.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,14 @@ function generateAugmentedPropsType(
169169
): string {
170170
const lines: string[] = [];
171171

172+
// Special handling for ContainerWorkloadProps - also omit 'containers' to replace with augmented container type
173+
const isContainerWorkload = resourceType === 'MultiContainerWorkload';
174+
const omitFields = isContainerWorkload
175+
? "'connectTo' | 'environment' | 'containers'"
176+
: "'connectTo' | 'environment'";
177+
172178
// Start the type declaration
173-
lines.push(`export type ${propsType} = Omit<${originalPropsType}, 'connectTo' | 'environment'> & {`);
179+
lines.push(`export type ${propsType} = Omit<${originalPropsType}, ${omitFields}> & {`);
174180

175181
// Add connectTo property with JSDoc
176182
const connectToProperty = getConnectToPropertyInfo(originalPropsType, connectToType);
@@ -180,6 +186,15 @@ function generateAugmentedPropsType(
180186
const environmentProperty = getEnvironmentPropertyInfo(originalPropsType);
181187
lines.push(generatePropertyWithJSDoc(environmentProperty));
182188

189+
// Add containers with augmented type for ContainerWorkload
190+
if (isContainerWorkload) {
191+
lines.push(` /**
192+
* A list of containers that will run in this workload.
193+
* Containers within the same workload share computing resources and scale together.
194+
*/
195+
containers: ContainerWithObjectEnv[];`);
196+
}
197+
183198
// Add overrides and transforms if needed
184199
if (includeOverridesAndTransforms) {
185200
const overridesProperty = getOverridesPropertyInfo(`${resourceType}Overrides`);
@@ -194,6 +209,25 @@ function generateAugmentedPropsType(
194209
return lines.join('\n');
195210
}
196211

212+
/**
213+
* Generates augmented container types with object-style environment
214+
*/
215+
function generateContainerAugmentedTypes(): string {
216+
return `// Augmented container types with object-style environment
217+
/**
218+
* Container configuration with object-style environment variables.
219+
* Environment is specified as { KEY: 'value' } for better developer experience.
220+
*/
221+
export type ContainerWithObjectEnv = Omit<import('./sdk').ContainerWorkloadContainer, 'environment'> & {
222+
/**
223+
* Environment variables to inject into the container.
224+
* Specified as key-value pairs: { PORT: '3000', NODE_ENV: 'production' }
225+
*/
226+
environment?: { [envVarName: string]: string | number | boolean };
227+
};
228+
`;
229+
}
230+
197231
/**
198232
* Generates a WithOverrides type for resources without augmented props
199233
* Also includes transforms
@@ -248,6 +282,10 @@ export function generateAugmentedPropsTypes(): string {
248282
}
249283

250284
result.push('');
285+
286+
// Generate augmented container types (for MultiContainerWorkload)
287+
result.push(generateContainerAugmentedTypes());
288+
251289
result.push('// Augmented props types with connectTo, environment, overrides, and transforms');
252290
result.push('');
253291

0 commit comments

Comments
 (0)