Skip to content

Commit bfc02e6

Browse files
committed
add deprecation warnings
1 parent 34e0a3b commit bfc02e6

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

packages/wrangler/src/__tests__/cloudchamber/deploy.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe("wrangler deploy with containers", () => {
9696
containers: [
9797
{
9898
name: "my-container",
99-
instances: 10,
99+
max_instances: 10,
100100
class_name: "ExampleDurableObject",
101101
image: "./Dockerfile",
102102
},
@@ -147,7 +147,7 @@ describe("wrangler deploy with containers", () => {
147147
containers: [
148148
{
149149
name: "my-container",
150-
instances: 10,
150+
max_instances: 10,
151151
class_name: "ExampleDurableObject",
152152
image: "./Dockerfile",
153153
},
@@ -161,7 +161,7 @@ describe("wrangler deploy with containers", () => {
161161

162162
mockCreateApplication({
163163
name: "my-container",
164-
instances: 10,
164+
max_instances: 10,
165165
durable_objects: { namespace_id: "1" },
166166
configuration: {
167167
image:
@@ -206,7 +206,7 @@ describe("wrangler deploy with containers", () => {
206206
{
207207
image: "docker.io/hello:world",
208208
name: "my-container",
209-
instances: 10,
209+
max_instances: 10,
210210
class_name: "ExampleDurableObject",
211211
},
212212
],
@@ -217,7 +217,7 @@ describe("wrangler deploy with containers", () => {
217217

218218
mockCreateApplication({
219219
name: "my-container",
220-
instances: 10,
220+
max_instances: 10,
221221
durable_objects: { namespace_id: "1" },
222222
scheduling_policy: SchedulingPolicy.DEFAULT,
223223
});
@@ -287,7 +287,7 @@ describe("wrangler deploy with containers", () => {
287287
containers: [
288288
{
289289
name: "my-container",
290-
instances: 10,
290+
max_instances: 10,
291291
class_name: "ExampleDurableObject",
292292
image: "../Dockerfile",
293293
},
@@ -311,7 +311,7 @@ describe("wrangler deploy with containers", () => {
311311

312312
mockCreateApplication({
313313
name: "my-container",
314-
instances: 10,
314+
max_instances: 10,
315315
durable_objects: { namespace_id: "1" },
316316
configuration: {
317317
image:
@@ -391,7 +391,7 @@ describe("wrangler deploy with containers", () => {
391391
containers: [
392392
{
393393
name: "my-container",
394-
instances: 10,
394+
max_instances: 10,
395395
class_name: "ExampleDurableObject",
396396
image: "../Dockerfile",
397397
},
@@ -408,7 +408,7 @@ describe("wrangler deploy with containers", () => {
408408

409409
mockCreateApplication({
410410
name: "my-container",
411-
instances: 10,
411+
max_instances: 10,
412412
durable_objects: { namespace_id: "1" },
413413
configuration: {
414414
image:
@@ -453,7 +453,7 @@ describe("wrangler deploy with containers", () => {
453453
{
454454
image: "docker.io/hello:world",
455455
name: "my-container",
456-
instances: 10,
456+
max_instances: 10,
457457
class_name: "ExampleDurableObject",
458458
},
459459
],
@@ -515,7 +515,7 @@ describe("wrangler deploy with containers dry run", () => {
515515
{
516516
image: "./Dockerfile",
517517
name: "my-container",
518-
instances: 10,
518+
max_instances: 10,
519519
class_name: "ExampleDurableObject",
520520
},
521521
],

packages/wrangler/src/config/validation.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,6 +2411,11 @@ function validateContainerApp(
24112411
containerAppOptional.name,
24122412
"string"
24132413
);
2414+
if ("configuration" in containerAppOptional) {
2415+
diagnostics.warnings.push(
2416+
`"containers.configuration" is deprecated. Use top level "containers" fields instead. "configuration.image" should be "image", "configuration.disk" should be set via "instance_type".`
2417+
);
2418+
}
24142419
// try and add a default name
24152420
if (!containerAppOptional.name) {
24162421
// we need topLevelName and a containers.class_name if containers.name is not defined
@@ -2431,7 +2436,6 @@ function validateContainerApp(
24312436
name += config === undefined ? "" : `-${envName}`;
24322437
containerAppOptional.name = name.toLowerCase().replace(/ /g, "-");
24332438
}
2434-
24352439
if (
24362440
!containerAppOptional.configuration?.image &&
24372441
!containerAppOptional.image
@@ -2440,6 +2444,11 @@ function validateContainerApp(
24402444
`"containers.image" field must be defined for each container app. This should be the path to your Dockerfile or a image URI pointing to the Cloudflare registry.`
24412445
);
24422446
}
2447+
if ("configuration" in containerAppOptional) {
2448+
diagnostics.warnings.push(
2449+
`"containers.configuration" is deprecated. Use top level "containers" fields instead. "configuration.image" should be "image", "configuration.disk" should be set via "instance_type".`
2450+
);
2451+
}
24432452

24442453
// Validate that we have an image configuration for this container app.
24452454
// For legacy reasons we have to check both at containerAppOptional.image and
@@ -2532,6 +2541,19 @@ function validateContainerApp(
25322541
"string",
25332542
["regional", "moon", "default"]
25342543
);
2544+
2545+
// Add deprecation warnings for legacy fields
2546+
if ("instances" in containerAppOptional) {
2547+
diagnostics.warnings.push(
2548+
`"containers.instances" is deprecated. Use "containers.max_instances" instead.`
2549+
);
2550+
}
2551+
if ("durable_objects" in containerAppOptional) {
2552+
diagnostics.warnings.push(
2553+
`"containers.durable_objects" is deprecated. Use the "class_name" field instead.`
2554+
);
2555+
}
2556+
25352557
validateAdditionalProperties(
25362558
diagnostics,
25372559
field,
@@ -2550,6 +2572,7 @@ function validateContainerApp(
25502572
"constraints",
25512573
"rollout_step_percentage",
25522574
"rollout_kind",
2575+
"durable_objects",
25532576
]
25542577
);
25552578
}

0 commit comments

Comments
 (0)