Skip to content

Commit a7f6966

Browse files
staging wrangler should push images to staging.registry.cloudflare.com (#10808)
1 parent d0801b1 commit a7f6966

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.changeset/open-birds-argue.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@cloudflare/containers-shared": patch
3+
---
4+
5+
When returning the default managed registry, inspect the environment variable
6+
`WRANGLER_API_ENVIRONMENT` to determine if we should be returning the production
7+
or staging registry.

packages/containers-shared/src/knobs.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import { MF_DEV_CONTAINER_PREFIX } from "./registry";
22

3-
// default cloudflare managed registry, can be overriden with the env var - CLOUDFLARE_CONTAINER_REGISTRY
3+
// Will return the default cloudflare managed registry for either a staging or production envrionment
4+
// based on the env var WRANGLER_API_ENVIRONMENT. The default registry can be overriden with the env
5+
// var CLOUDFLARE_CONTAINER_REGISTRY.
46
export const getCloudflareContainerRegistry = () => {
57
// previously defaulted to registry.cloudchamber.cfdata.org
6-
return process.env.CLOUDFLARE_CONTAINER_REGISTRY ?? "registry.cloudflare.com";
8+
return (
9+
process.env.CLOUDFLARE_CONTAINER_REGISTRY ??
10+
(process.env.WRANGLER_API_ENVIRONMENT === "staging"
11+
? "staging.registry.cloudflare.com"
12+
: "registry.cloudflare.com")
13+
);
714
};
815

916
/**
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { getCloudflareContainerRegistry } from "./../src/knobs";
2+
3+
describe("getCloudflareContainerRegistry", () => {
4+
it("should return the managed registry", () => {
5+
expect(getCloudflareContainerRegistry()).toBe("registry.cloudflare.com");
6+
vi.stubEnv("WRANGLER_API_ENVIRONMENT", "production");
7+
expect(getCloudflareContainerRegistry()).toBe("registry.cloudflare.com");
8+
});
9+
10+
it("should return the staging registry", () => {
11+
vi.stubEnv("WRANGLER_API_ENVIRONMENT", "staging");
12+
expect(getCloudflareContainerRegistry()).toBe(
13+
"staging.registry.cloudflare.com"
14+
);
15+
});
16+
});

turbo.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"TEST_REPORT_PATH",
1313
"CLOUDFLARE_CONTAINER_REGISTRY",
1414
"DOCKER_HOST",
15-
"WRANGLER_DOCKER_HOST"
15+
"WRANGLER_DOCKER_HOST",
16+
"WRANGLER_API_ENVIRONMENT"
1617
],
1718
"tasks": {
1819
"dev": {

0 commit comments

Comments
 (0)