File tree Expand file tree Collapse file tree 4 files changed +34
-3
lines changed
packages/containers-shared Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff line change 11import { 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.
46export 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/**
Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change 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" : {
You can’t perform that action at this time.
0 commit comments