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
8 changes: 8 additions & 0 deletions .changeset/plenty-paws-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@cloudflare/containers-shared": patch
"wrangler": patch
---

add library-push flag to containers registries credentials

This flag is not available for public use.
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ This is the **Cloudflare Workers SDK** monorepo containing tools and libraries f
- Use `node:` prefix for Node.js imports (`import/enforce-node-protocol-usage`)
- Prefix unused variables with `_`
- No `.only()` in tests (`no-only-tests/no-only-tests`)
- Format with Prettier - run `pnpm prettify` in the workspace root before committing
- Format with oxfmt - run `pnpm prettify` in the workspace root before committing
- All changes to published packages require a changeset (see below)

**Formatting (Prettier):**
**Formatting (oxfmt):**

- Tabs (not spaces), double quotes, semicolons, trailing commas (es5)
- Import order enforced: builtins → third-party → parent → sibling → index → types
- `prettier-plugin-packagejson` sorts package.json keys
- `sortPackageJson` option sorts package.json keys

**Security:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
export enum ImageRegistryPermissions {
PULL = "pull",
PUSH = "push",
LIBRARY_PUSH = "library_push",
}
1 change: 0 additions & 1 deletion packages/create-cloudflare/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Project scaffolding CLI for Cloudflare Workers. Single entry: `src/cli.ts` serve
## CONVENTIONS

- `no-console: error` — use project's logging utilities
- Own `.prettierrc` — same settings as root but without `prettier-plugin-packagejson`
- Templates excluded from linting (except `c3.ts` files within templates)
- Templates excluded from formatting (except hello-world templates)

Expand Down
13 changes: 13 additions & 0 deletions packages/wrangler/src/__tests__/containers/registries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,19 @@ describe("containers registries credentials", () => {
expect(std.out).toMatchInlineSnapshot(`"custom-expiry-token"`);
});

it("should generate credentials with --library-push", async () => {
setIsTTY(false);
mockGenerateCredentials("registry.cloudflare.com", "test-password", 15, [
"library_push",
]);

await runWrangler(
"containers registries credentials registry.cloudflare.com --library-push"
);

expect(std.out).toMatchInlineSnapshot(`"test-password"`);
});

it("should output valid JSON when --json flag is used", async () => {
setIsTTY(false);
mockGenerateCredentials("registry.cloudflare.com", "test-password", 15, [
Expand Down
14 changes: 13 additions & 1 deletion packages/wrangler/src/containers/registries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ async function registryCredentialsCommand(credentialsArgs: {
expirationMinutes: number;
push?: boolean;
pull?: boolean;
libraryPush?: boolean;
json?: boolean;
}) {
const cloudflareRegistry = getCloudflareContainerRegistry();
Expand All @@ -511,7 +512,11 @@ async function registryCredentialsCommand(credentialsArgs: {
);
}

if (!credentialsArgs.pull && !credentialsArgs.push) {
if (
!credentialsArgs.pull &&
!credentialsArgs.push &&
!credentialsArgs.libraryPush
) {
throw new UserError(
"You have to specify either --push or --pull in the command."
);
Expand All @@ -523,6 +528,7 @@ async function registryCredentialsCommand(credentialsArgs: {
permissions: [
...(credentialsArgs.push ? ["push"] : []),
...(credentialsArgs.pull ? ["pull"] : []),
...(credentialsArgs.libraryPush ? ["library_push"] : []),
] as ImageRegistryPermissions[],
});
if (credentialsArgs.json) {
Expand Down Expand Up @@ -623,6 +629,12 @@ export const containersRegistriesCredentialsCommand = createCommand({
type: "boolean",
description: "If you want these credentials to be able to pull",
},
"library-push": {
type: "boolean",
description:
"If you want these credentials to be able to push to the public library namespace",
hidden: true,
},
json: {
type: "boolean",
description: "Format output as JSON",
Expand Down
Loading