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.
Comment thread
petebacondarwin marked this conversation as resolved.
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",
}
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."
);
Comment thread
nikitassharma marked this conversation as resolved.
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