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
12 changes: 12 additions & 0 deletions .changeset/solid-sloths-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"wrangler": minor
---

Show possible local vs. dashboard diff information on deploys

When re-deploying a Worker using `wrangler deploy`, if the configuration has been modified in the Cloudflare dashboard, the local configuration will overwrite the remote one. This can lead to unexpected results for users. To address this, currently `wrangler deploy` warns users about potential configuration overrides (without presenting them) and prompts them to confirm whether they want to proceed.

The changes here improve the above flow in the following way:

- If the local changes only add new configurations (without modifying or removing existing ones), the deployment proceeds automatically without warnings or prompts, as these changes are non-destructive and safe.
- If the local changes modify or remove existing configurations, `wrangler deploy` now displays a git-like diff showing the differences between the dashboard and local configurations. This allows users to review and understand the impact of their changes before confirming the deployment.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe("getPlatformProxy - env", () => {
"..",
"custom-toml",
"path",
"test-toml"
"test.toml"
),
});
try {
Expand Down
32 changes: 1 addition & 31 deletions packages/wrangler/src/__tests__/cloudchamber/apply.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ describe("cloudchamber apply", () => {
│ ...
│ instance_type = \\"dev\\"
│ [containers.constraints]
│ - tier = 3
│ + tier = 2
Expand Down Expand Up @@ -588,27 +587,21 @@ describe("cloudchamber apply", () => {
│ ...
│ value = \\"value\\"
│ [[containers.configuration.labels]]
│ + name = \\"name-1\\"
│ + value = \\"value-1\\"
│ +
│ + [[containers.configuration.labels]]
│ +
│ name = \\"name-2\\"
│ value = \\"value-2\\"
│ ...
│ type = \\"env\\"
│ [[containers.configuration.secrets]]
│ - name = \\"MY_SECRET_1\\"
│ - secret = \\"SECRET_NAME_1\\"
│ - type = \\"env\\"
│ -
│ - [[containers.configuration.secrets]]
│ -
│ name = \\"MY_SECRET_2\\"
│ secret = \\"SECRET_NAME_2\\"
│ type = \\"env\\"
Expand Down Expand Up @@ -1004,11 +997,8 @@ describe("cloudchamber apply", () => {
│ image = \\"docker.io/beep:boop\\"
│ instance_type = \\"dev\\"
│ + [containers.configuration.observability.logs]
│ + enabled = true
│ +
│ +
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1074,11 +1064,8 @@ describe("cloudchamber apply", () => {
│ image = \\"docker.io/beep:boop\\"
│ instance_type = \\"dev\\"
│ + [containers.configuration.observability.logs]
│ + enabled = true
│ +
│ +
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1148,11 +1135,9 @@ describe("cloudchamber apply", () => {
├ EDIT my-container-app
│ instance_type = \\"dev\\"
│ [containers.configuration.observability.logs]
│ - enabled = true
│ + enabled = false
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1222,11 +1207,9 @@ describe("cloudchamber apply", () => {
├ EDIT my-container-app
│ instance_type = \\"dev\\"
│ [containers.configuration.observability.logs]
│ - enabled = true
│ + enabled = false
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1295,11 +1278,9 @@ describe("cloudchamber apply", () => {
├ EDIT my-container-app
│ instance_type = \\"dev\\"
│ [containers.configuration.observability.logs]
│ - enabled = true
│ + enabled = false
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1371,11 +1352,9 @@ describe("cloudchamber apply", () => {
├ EDIT my-container-app
│ instance_type = \\"dev\\"
│ [containers.configuration.observability.logs]
│ - enabled = true
│ + enabled = false
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1726,12 +1705,10 @@ describe("cloudchamber apply", () => {
│ + instances = 4
│ name = \\"my-container-app\\"
│ scheduling_policy = \\"regional\\"
│ [containers.configuration]
│ image = \\"docker.io/beep:boop\\"
│ - instance_type = \\"dev\\"
│ + instance_type = \\"standard\\"
│ [containers.constraints]
│ - tier = 3
│ + tier = 2
Expand Down Expand Up @@ -1807,21 +1784,17 @@ describe("cloudchamber apply", () => {
│ + instances = 4
│ name = \\"my-container-app\\"
│ scheduling_policy = \\"regional\\"
│ [containers.configuration]
│ image = \\"docker.io/beep:boop\\"
│ memory = \\"256MB\\"
│ - memory_mib = 256
│ + memory_mib = 1_024
│ - vcpu = 0.0625
│ + vcpu = 1
│ [containers.configuration.disk]
│ size = \\"2GB\\"
│ - size_mb = 2_000
│ + size_mb = 6_000
│ [containers.constraints]
│ - tier = 3
│ + tier = 2
Expand Down Expand Up @@ -1892,12 +1865,10 @@ describe("cloudchamber apply", () => {
│ + instances = 4
│ name = \\"my-container-app\\"
│ scheduling_policy = \\"regional\\"
│ [containers.configuration]
│ image = \\"docker.io/beep:boop\\"
│ - instance_type = \\"basic\\"
│ + instance_type = \\"dev\\"
│ [containers.constraints]
│ - tier = 3
│ + tier = 2
Expand Down Expand Up @@ -2026,10 +1997,9 @@ describe("cloudchamber apply", () => {
├ EDIT my-container-app
│ [containers.configuration]
│ image = \\"${registry}/some-account-id/hello:1.0\\"
│ image = \\"registry.cloudflare.com/some-account-id/hello:1.0\\"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is intentional, I don't think that using string interpolation in an inline snapshot is correct at all

I can understand the intent but I do not think that it is a correct use of inline snapshots (updating the snapshot will always change this line)

I think that if we do want to use the registry variable then we should not use inline snapshots for these checks, or if we do not care about the variable, we can then inline the value as I did here.

Assuming that the Cloudflare registry address is very stable I thought that here it would be correct to inline the value.

@emily-shen do you have some context regarding this by any chance? 🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah its fine. strictly speaking registry comes from an env var so there is also a cloudchamber registry url, but i don't think it really matters in this test here.

│ - instance_type = \\"dev\\"
│ + instance_type = \\"standard\\"
│ [containers.constraints]
│ - tier = 3
│ + tier = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2656,6 +2656,7 @@ describe("normalizeAndValidateConfig()", () => {
RESOURCES_PROVISION: true,
MULTIWORKER: false,
REMOTE_BINDINGS: false,
DEPLOY_REMOTE_DIFF_CHECK: false,
},
() =>
normalizeAndValidateConfig(
Expand Down Expand Up @@ -2812,6 +2813,7 @@ describe("normalizeAndValidateConfig()", () => {
RESOURCES_PROVISION: true,
MULTIWORKER: false,
REMOTE_BINDINGS: false,
DEPLOY_REMOTE_DIFF_CHECK: false,
},
() =>
normalizeAndValidateConfig(
Expand Down Expand Up @@ -3150,6 +3152,7 @@ describe("normalizeAndValidateConfig()", () => {
RESOURCES_PROVISION: true,
MULTIWORKER: false,
REMOTE_BINDINGS: false,
DEPLOY_REMOTE_DIFF_CHECK: false,
},
() =>
normalizeAndValidateConfig(
Expand Down
18 changes: 0 additions & 18 deletions packages/wrangler/src/__tests__/containers/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,12 +587,10 @@ describe("wrangler deploy with containers", () => {
│ - rollout_active_grace_period = 500
│ + rollout_active_grace_period = 600
│ scheduling_policy = \\"default\\"
│ [containers.configuration]
│ - image = \\"registry.cloudflare.com/some-account-id/my-container:old\\"
│ + image = \\"registry.cloudflare.com/some-account-id/my-container:Galaxy\\"
│ instance_type = \\"dev\\"
│ [containers.constraints]
Expand Down Expand Up @@ -728,12 +726,10 @@ describe("wrangler deploy with containers", () => {
│ + max_instances = 10
│ name = \\"my-container\\"
│ scheduling_policy = \\"default\\"
│ [containers.configuration]
│ - image = \\"registry.cloudflare.com/some-account-id/my-container:old\\"
│ + image = \\"registry.cloudflare.com/some-account-id/my-container:Galaxy\\"
│ instance_type = \\"dev\\"
│ [containers.constraints]
Expand Down Expand Up @@ -896,11 +892,8 @@ describe("wrangler deploy with containers", () => {
│ image = \\"docker.io/hello:world\\"
│ instance_type = \\"dev\\"
│ + [containers.configuration.observability.logs]
│ + enabled = true
│ +
│ +
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -942,11 +935,8 @@ describe("wrangler deploy with containers", () => {
│ image = \\"docker.io/hello:world\\"
│ instance_type = \\"dev\\"
│ + [containers.configuration.observability.logs]
│ + enabled = true
│ +
│ +
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1000,11 +990,9 @@ describe("wrangler deploy with containers", () => {
├ EDIT my-container
│ instance_type = \\"dev\\"
│ [containers.configuration.observability.logs]
│ - enabled = true
│ + enabled = false
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1058,11 +1046,9 @@ describe("wrangler deploy with containers", () => {
├ EDIT my-container
│ instance_type = \\"dev\\"
│ [containers.configuration.observability.logs]
│ - enabled = true
│ + enabled = false
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1112,11 +1098,9 @@ describe("wrangler deploy with containers", () => {
├ EDIT my-container
│ instance_type = \\"dev\\"
│ [containers.configuration.observability.logs]
│ - enabled = true
│ + enabled = false
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -1171,11 +1155,9 @@ describe("wrangler deploy with containers", () => {
├ EDIT my-container
│ instance_type = \\"dev\\"
│ [containers.configuration.observability.logs]
│ - enabled = true
│ + enabled = false
│ [containers.constraints]
│ tier = 1
Expand Down
Loading
Loading