Skip to content

add npx wrangler containers registry commands - #10605

Merged
emily-shen merged 15 commits into
mainfrom
emily/registries-cmd
Nov 5, 2025
Merged

add npx wrangler containers registry commands#10605
emily-shen merged 15 commits into
mainfrom
emily/registries-cmd

Conversation

@emily-shen

@emily-shen emily-shen commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

CC-5835

Add commands to support configuring credentials for external (non cloudflare) registries. Currently this should only be AWS ECR. We are still working on this incrementally so the commands are hidden.

This works by integrating with the secrets store. Credentials for registries usually consist of a public and private component - only the actually secret bit is stored in the secret store, which wrangler will create for you. The secret is either added interactively or piped in. Currently we don't allow you to provide an existing secret. The secret store id and secret name are then passed to the containers control plane.

The public part is passed in via --public-credential and stored in the containers control plane.

You can provide a store id but currently secret store only allows for one store per account so that is a bit redundant.


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: wip feature
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: new feature

@changeset-bot

changeset-bot Bot commented Sep 10, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a52538e

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2025

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10605

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10605

miniflare

npm i https://pkg.pr.new/miniflare@10605

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10605

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10605

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10605

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10605

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10605

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@10605

wrangler

npm i https://pkg.pr.new/wrangler@10605

commit: a52538e

@emily-shen emily-shen changed the title [draft] add npx wrangler containers registry configure command [draft] add npx wrangler containers registry put command Sep 11, 2025
Comment thread packages/containers-shared/src/images.ts Fixed
Comment thread packages/wrangler/src/containers/config.ts Fixed
@emily-shen
emily-shen changed the base branch from main to cdr/containers-push-resolve September 12, 2025 14:26
@IRCody
IRCody force-pushed the cdr/containers-push-resolve branch 2 times, most recently from 2756e4a to 4767a79 Compare September 17, 2025 22:21
@IRCody
IRCody force-pushed the cdr/containers-push-resolve branch from 4767a79 to 9555cd6 Compare September 23, 2025 19:56
@petebacondarwin
petebacondarwin force-pushed the cdr/containers-push-resolve branch from 9555cd6 to 19e753d Compare September 26, 2025 12:51
Base automatically changed from cdr/containers-push-resolve to main September 26, 2025 15:54
Comment thread packages/wrangler/src/__tests__/containers/registries.test.ts Outdated
Comment thread packages/containers-shared/src/login.ts Outdated
Comment thread packages/containers-shared/src/login.ts Outdated
@emily-shen emily-shen changed the title [draft] add npx wrangler containers registry put command [draft] add npx wrangler containers registry commands Sep 30, 2025
@emily-shen
emily-shen force-pushed the emily/registries-cmd branch 2 times, most recently from f6643b0 to 643f892 Compare October 1, 2025 10:49
@emily-shen emily-shen changed the title [draft] add npx wrangler containers registry commands add npx wrangler containers registry commands Oct 1, 2025
@emily-shen
emily-shen force-pushed the emily/registries-cmd branch 2 times, most recently from 1f4e96e to 05c4367 Compare October 1, 2025 11:55
Comment thread packages/wrangler/src/containers/registries.ts Outdated
Comment thread packages/wrangler/src/containers/registries.ts Outdated
Comment thread packages/wrangler/src/containers/registries.ts Outdated
Comment thread packages/wrangler/src/containers/registries.ts Outdated
Comment thread packages/wrangler/src/containers/registries.ts
@emily-shen
emily-shen force-pushed the emily/registries-cmd branch from 05c4367 to d1a85f8 Compare October 6, 2025 17:03
Comment thread packages/wrangler/src/containers/index.ts Outdated
Comment thread packages/wrangler/src/containers/registries.ts Outdated
@emily-shen
emily-shen force-pushed the emily/registries-cmd branch from d1a85f8 to 7e1f886 Compare October 16, 2025 10:39
});

export const validateSecretName = (name: string) => {
const validName = /^[A-z0-9-_]+$/;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a valid concern, maybe switch to /^[\w-]+$/ (\w include _)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is the same regex that secret store applies api side


/**
* Request body for creating a new image registry configuration
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this comment removed?
Should the new fields be documented?

Comment on lines +1 to +4
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this be removed everywhere it is added (not applicable to this repo)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

everything in containers-shared/src/client/ is autogenerated from an openapi spec in the cloudchamber repo, and this is unfortunately full of 'any' uses so we do actually need to disable eslint.
we could remove the others but again i'd like to avoid unnecessarily increasing the diff here.

* The type of external registry that is being configured.
*/
export enum ExternalRegistryKind {
ECR = "ECR",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: any particular reason to give this an explicit name ( = "ECR")?

/* eslint-disable */

/**
* A JSON string that encodes the auth required to authenticate with an external image registry. The format of the JSON object is determined by the registry being configured.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

string ?

options: Exclude<ContainerDevOptions, DockerfileConfig>
): Promise<{ abort: () => void; ready: Promise<void> }> {
await dockerLoginManagedRegistry(dockerPath);
const domain = new URL(`http://${options.image_uri}`).hostname;

@vicb vicb Nov 4, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could throw, should the error be handled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this will already be validated by this point so it shouldn't, adding a comment to explain

Comment thread packages/containers-shared/src/images.ts
Comment on lines +182 to +190
let url: URL;
try {
url = new URL(`http://${domain}`);
} catch (e) {
if (e instanceof Error) {
throw new Error(`${domain} is invalid:\n${e.message}`);
}
throw e;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could use URL.canParse here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

alas we still support node 20 where this doesn't exist

Comment thread packages/wrangler/src/index.ts Outdated

// containers
wrangler.command("containers", false, (containersArgs) => {
wrangler.command("containers", "📦 Manage Containers ", (containersArgs) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
wrangler.command("containers", "📦 Manage Containers ", (containersArgs) => {
wrangler.command("containers", "📦 Manage Containers", (containersArgs) => {

Not sure if this will break all the snapshots!

}

const acceptedRegistries: RegistryPattern[] = [
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to consolidate this object (for ext registries) and type in an ExternalRegistry.ts file that would also have the content from the current ExternalRegistryKind.ts

@emily-shen emily-shen Nov 4, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Everything in containers-shared/src/client/ is autogenerated from an open api spec in the cloudchamber internal repo, and I would prefer to not mix in hand written code with the autogenerated code. also the autogenerated client will be removed soon anyway in favour of the cloudflare ts sdk :)

expect(result[0].rollout_step_percentage).toBe(100);
});

describe("image validation and resolution", async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is "image validation" accurate here?
It looks like this is validating registries instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it is also validating how we resolve image names (e.g. adding account ids)

)
.command(
"registries",
// hide for now so it doesn't show up in help while we not publicly available

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// hide for now so it doesn't show up in help while we not publicly available
// hide for now so it doesn't show up in help while not publicly available

description:
"The public part of the registry credentials, e.g. `AWS_ACCESS_KEY_ID` for ECR",
demandOption: true,
alias: ["aws-access-key-id"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't that going to be a problem when we add more registry types?
i.e. you'll be able to use aws-access-key-id to configure GCP containers

Comment on lines +129 to +130
log("\n");
log("Setting up integration with Secrets Store...\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
log("\n");
log("Setting up integration with Secrets Store...\n");
log("\nSetting up integration with Secrets Store...\n");

const stores = await listStores(config, accountId);
if (stores.length === 0) {
const defaultStoreName = "default_secret_store";
const check = await confirm(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: use yes/create instead? The former is consistent with other usage in this PR, create is also nice to describe what is being done/asked.

@vicb vicb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The regexp should be updated.

Also added other minor comments.

LGTM with the changes.

@emily-shen
emily-shen force-pushed the emily/registries-cmd branch from 0f96364 to a52538e Compare November 4, 2025 12:11
/**
* get type of container registry, and validate
* currently we support cloudflare managed registries and AWS ECR
* when using cloudflare mananged registries we expect CLOUDFLARE_CONTAINER_REGISTRY to be set

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* when using cloudflare mananged registries we expect CLOUDFLARE_CONTAINER_REGISTRY to be set
* when using cloudflare managed registries we expect CLOUDFLARE_CONTAINER_REGISTRY to be set

}

/**
* get type of container registry, and validate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* get type of container registry, and validate
* Get type of container registry, and validate

@emily-shen

Copy link
Copy Markdown
Contributor Author

merging this as-is because the remaining comments are nits, this is hidden and i am going to do a follow-up pr immediately after

@emily-shen
emily-shen merged commit b55a3c7 into main Nov 5, 2025
38 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Nov 5, 2025
@emily-shen
emily-shen deleted the emily/registries-cmd branch November 5, 2025 11:03
emily-shen added a commit that referenced this pull request Nov 5, 2025
@lrapoport-cf lrapoport-cf mentioned this pull request Nov 6, 2025
6 tasks
emily-shen added a commit that referenced this pull request Nov 20, 2025
emily-shen added a commit that referenced this pull request Dec 17, 2025
edmundhung pushed a commit that referenced this pull request Dec 17, 2025
nikitassharma added a commit that referenced this pull request Dec 17, 2025
…n for `fedramp_high` (#11196)

* Fix nits from #10605

* non-secret-store mode

* update containers api client

* clean up fedramp region code

* add tests

* changeset

* containers-shared minor

* prettify

---------

Co-authored-by: Nikita Sharma <nsharma@cloudflare.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants