From 8a12a0129b79c900b5231691a3f64c7773ccb41d Mon Sep 17 00:00:00 2001 From: Garrett Gu Date: Wed, 2 Apr 2025 15:30:39 -0500 Subject: [PATCH 1/2] IGLOO-45 replace underscore with slashes in catalog URI --- packages/wrangler/src/__tests__/r2.test.ts | 12 ++++++------ packages/wrangler/src/r2/catalog.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/wrangler/src/__tests__/r2.test.ts b/packages/wrangler/src/__tests__/r2.test.ts index 3462f25fbb..e48e092caa 100644 --- a/packages/wrangler/src/__tests__/r2.test.ts +++ b/packages/wrangler/src/__tests__/r2.test.ts @@ -973,7 +973,7 @@ describe("r2", () => { createFetchResult( { id: "test-warehouse-id", - name: "test-warehouse-name", + name: "test-account-id_test-warehouse-name", }, true ) @@ -986,8 +986,8 @@ describe("r2", () => { expect(std.out).toMatchInlineSnapshot( `"✨ Successfully enabled data catalog on bucket 'testBucket'. -Catalog URI: 'https://catalog.cloudflarestorage.com/test-warehouse-name' -Warehouse: 'test-warehouse-name' +Catalog URI: 'https://catalog.cloudflarestorage.com/test-account-id/test-warehouse-name' +Warehouse: 'test-account-id_test-warehouse-name' Use this Catalog URI with Iceberg-compatible query engines (Spark, PyIceberg etc.) to query data as tables. Note: You will need a Cloudflare API token with 'R2 Data Catalog' permission to authenticate your client with this catalog. @@ -1157,7 +1157,7 @@ For more details, refer to: https://developers.cloudflare.com/r2/api/s3/tokens/" createFetchResult( { id: "test-id", - name: "test-name", + name: "test-account-id_test-name", bucket: "test-bucket", status: "active", }, @@ -1172,8 +1172,8 @@ For more details, refer to: https://developers.cloudflare.com/r2/api/s3/tokens/" expect(std.out).toMatchInlineSnapshot(` "Getting data catalog status for 'test-bucket'... - Catalog URI: https://catalog.cloudflarestorage.com/test-name - Warehouse: test-name + Catalog URI: https://catalog.cloudflarestorage.com/test-account-id/test-name + Warehouse: test-account-id_test-name Status: active" `); }); diff --git a/packages/wrangler/src/r2/catalog.ts b/packages/wrangler/src/r2/catalog.ts index cf938802c8..907c8508ff 100644 --- a/packages/wrangler/src/r2/catalog.ts +++ b/packages/wrangler/src/r2/catalog.ts @@ -37,10 +37,11 @@ export const r2BucketCatalogEnableCommand = createCommand({ let catalogHost: string; const env = getCloudflareApiEnvironmentFromEnv(); + const path = response.name.replace("_", "/"); if (env === "staging") { - catalogHost = `https://catalog-staging.cloudflarestorage.com/${response.name}`; + catalogHost = `https://catalog-staging.cloudflarestorage.com/${path}`; } else { - catalogHost = `https://catalog.cloudflarestorage.com/${response.name}`; + catalogHost = `https://catalog.cloudflarestorage.com/${path}`; } logger.log( @@ -125,10 +126,11 @@ export const r2BucketCatalogGetCommand = createCommand({ const env = getCloudflareApiEnvironmentFromEnv(); let catalogHost: string; + const path = catalog.name.replace("_", "/"); if (env === "staging") { - catalogHost = `https://catalog-staging.cloudflarestorage.com/${catalog.name}`; + catalogHost = `https://catalog-staging.cloudflarestorage.com/${path}`; } else { - catalogHost = `https://catalog.cloudflarestorage.com/${catalog.name}`; + catalogHost = `https://catalog.cloudflarestorage.com/${path}`; } const output = { From 5e991cdfa92cf1ab2ded78429638a9ef448b988d Mon Sep 17 00:00:00 2001 From: Garrett Gu Date: Thu, 3 Apr 2025 14:59:59 -0500 Subject: [PATCH 2/2] Add changeset --- .changeset/fine-cameras-nail.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fine-cameras-nail.md diff --git a/.changeset/fine-cameras-nail.md b/.changeset/fine-cameras-nail.md new file mode 100644 index 0000000000..9755d9322e --- /dev/null +++ b/.changeset/fine-cameras-nail.md @@ -0,0 +1,5 @@ +--- +"wrangler": major +--- + +minor: R2 data catalog URIs now separate account ID and warehouse name with a slash rather than an underscore