Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/famous-coats-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@cloudflare/containers-shared": patch
"wrangler": patch
---

Add the option to allow all tiers when creating a container
2 changes: 1 addition & 1 deletion packages/containers-shared/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type SharedContainerConfig = {
constraints: {
regions?: string[];
cities?: string[];
tier: number;
tier: number | undefined;
};
observability: { logs_enabled: boolean };
} & InstanceTypeOrLimits;
Expand Down
29 changes: 29 additions & 0 deletions packages/wrangler/src/__tests__/containers/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,33 @@ describe("getNormalizedContainerOptions", () => {
expect(result[0]).toHaveProperty("image_build_context");
expect(result[0]).not.toHaveProperty("image_uri");
});

it("should be able to specify all tiers", async () => {
writeFileSync("Dockerfile", "FROM scratch");
const config: Config = {
name: "test-worker",
containers: [
{
class_name: "TestContainer",
image: `${getCloudflareContainerRegistry()}/test:latest`,
name: "test-container",
constraints: {
tier: -1,
},
},
],
durable_objects: {
bindings: [
{
name: "TEST_DO",
class_name: "TestContainer",
},
],
},
} as Partial<Config> as Config;

const result = await getNormalizedContainerOptions(config);
expect(result).toHaveLength(1);
expect(result[0].constraints.tier).toBeUndefined();
});
});
8 changes: 7 additions & 1 deletion packages/wrangler/src/containers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ export const getNormalizedContainerOptions = async (
scheduling_policy: (container.scheduling_policy ??
SchedulingPolicy.DEFAULT) as SchedulingPolicy,
constraints: {
tier: container.constraints?.tier ?? 1,
// if the tier is -1, then we allow all tiers
// Wrangler will default an input value to 1. The API, however, will
// treat an undefined value to mean no constraints on tier (i.e. "all tiers")
tier:
container.constraints?.tier === -1
? undefined
: container.constraints?.tier ?? 1,
regions: container.constraints?.regions?.map((region) =>
region.toUpperCase()
),
Expand Down
Loading