Skip to content

Commit 0d48f51

Browse files
committed
print containers
1 parent a1ec9bb commit 0d48f51

File tree

5 files changed

+54
-21
lines changed

5 files changed

+54
-21
lines changed

packages/wrangler/src/__tests__/containers/deploy.test.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ describe("wrangler deploy with containers", () => {
127127
Binding Resource
128128
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
129129
130+
The following containers are available:
131+
- my-container (<cwd>/Dockerfile)
132+
130133
Uploaded test-name (TIMINGS)
131134
Building image my-container:Galaxy
132135
Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
@@ -202,6 +205,9 @@ describe("wrangler deploy with containers", () => {
202205
Binding Resource
203206
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
204207
208+
The following containers are available:
209+
- my-container (registry.cloudflare.com/hello:world)
210+
205211
Uploaded test-name (TIMINGS)
206212
Deployed test-name triggers (TIMINGS)
207213
https://test-name.test-sub-domain.workers.dev
@@ -288,6 +294,9 @@ describe("wrangler deploy with containers", () => {
288294
Binding Resource
289295
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
290296
297+
The following containers are available:
298+
- my-container (registry.cloudflare.com/hello:world)
299+
291300
Uploaded test-name (TIMINGS)
292301
Deployed test-name triggers (TIMINGS)
293302
https://test-name.test-sub-domain.workers.dev
@@ -386,6 +395,9 @@ describe("wrangler deploy with containers", () => {
386395
Binding Resource
387396
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
388397
398+
The following containers are available:
399+
- my-container (registry.cloudflare.com/hello:world)
400+
389401
Uploaded test-name (TIMINGS)
390402
Deployed test-name triggers (TIMINGS)
391403
https://test-name.test-sub-domain.workers.dev
@@ -476,23 +488,6 @@ describe("wrangler deploy with containers", () => {
476488

477489
await runWrangler("deploy --cwd src");
478490

479-
expect(std.out).toMatchInlineSnapshot(`
480-
"
481-
⛅️ wrangler x.x.x
482-
──────────────────
483-
Total Upload: xx KiB / gzip: xx KiB
484-
Worker Startup Time: 100 ms
485-
Your Worker has access to the following bindings:
486-
Binding Resource
487-
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
488-
489-
Uploaded test-name (TIMINGS)
490-
Building image my-container:Galaxy
491-
Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
492-
Deployed test-name triggers (TIMINGS)
493-
https://test-name.test-sub-domain.workers.dev
494-
Current Version ID: Galaxy-Class"
495-
`);
496491
expect(std.err).toMatchInlineSnapshot(`""`);
497492
expect(std.warn).toMatchInlineSnapshot(`""`);
498493
});
@@ -549,6 +544,9 @@ describe("wrangler deploy with containers", () => {
549544
Binding Resource
550545
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
551546
547+
The following containers are available:
548+
- my-container (<cwd>/Dockerfile)
549+
552550
Uploaded test-name (TIMINGS)
553551
Building image my-container:Galaxy
554552
Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
@@ -1838,6 +1836,9 @@ describe("wrangler deploy with containers", () => {
18381836
──────────────────
18391837
Total Upload: xx KiB / gzip: xx KiB
18401838
Worker Startup Time: 100 ms
1839+
The following containers are available:
1840+
- my-container (registry.cloudflare.com/hello:world)
1841+
18411842
Uploaded test-name (TIMINGS)
18421843
Deployed test-name triggers (TIMINGS)
18431844
https://test-name.test-sub-domain.workers.dev
@@ -2086,6 +2087,9 @@ describe("wrangler deploy with containers dry run", () => {
20862087
Binding Resource
20872088
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
20882089
2090+
The following containers are available:
2091+
- my-container (<cwd>/Dockerfile)
2092+
20892093
--dry-run: exiting now."
20902094
`);
20912095
expect(cliStd.stdout).toMatchInlineSnapshot(`""`);
@@ -2113,6 +2117,9 @@ describe("wrangler deploy with containers dry run", () => {
21132117
Binding Resource
21142118
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
21152119
2120+
The following containers are available:
2121+
- my-container (registry.cloudflare.com/hello:world)
2122+
21162123
--dry-run: exiting now."
21172124
`);
21182125
expect(cliStd.stdout).toMatchInlineSnapshot(`""`);

packages/wrangler/src/api/startDevWorker/ConfigController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ async function resolveBindings(
211211
},
212212
input.tailConsumers ?? config.tail_consumers,
213213
input.streamingTailConsumers ?? config.streaming_tail_consumers,
214+
config.containers,
214215
{
215216
registry,
216217
local: !input.dev?.remote,

packages/wrangler/src/deploy/deploy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
911911
{ ...withoutStaticAssets, vars: maskedVars },
912912
config.tail_consumers,
913913
config.streaming_tail_consumers,
914+
config.containers,
914915
{ warnIfNoBindings: true }
915916
);
916917
} else {
@@ -1050,7 +1051,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10501051
printBindings(
10511052
{ ...withoutStaticAssets, vars: maskedVars },
10521053
config.tail_consumers,
1053-
config.streaming_tail_consumers
1054+
config.streaming_tail_consumers,
1055+
config.containers
10541056
);
10551057

10561058
versionId = parseNonHyphenedUuid(result.deployment_id);
@@ -1080,7 +1082,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10801082
printBindings(
10811083
{ ...withoutStaticAssets, vars: maskedVars },
10821084
config.tail_consumers,
1083-
config.streaming_tail_consumers
1085+
config.streaming_tail_consumers,
1086+
config.containers
10841087
);
10851088
}
10861089
const message = await helpIfErrorIsSizeOrScriptStartup(

packages/wrangler/src/deployment-bundle/bindings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ export async function provisionBindings(
492492
printable,
493493
config.tail_consumers,
494494
config.streaming_tail_consumers,
495+
[],
495496
{ provisioning: true }
496497
);
497498
logger.log();

packages/wrangler/src/utils/print-bindings.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import chalk from "chalk";
44
import stripAnsi from "strip-ansi";
55
import { getFlag } from "../experimental-flags";
66
import { logger } from "../logger";
7-
import type { CfTailConsumer, CfWorkerInit } from "@cloudflare/workers-utils";
7+
import type {
8+
CfTailConsumer,
9+
CfWorkerInit,
10+
ContainerApp,
11+
} from "@cloudflare/workers-utils";
812
import type { WorkerRegistry } from "miniflare";
913

1014
/**
@@ -14,6 +18,7 @@ export function printBindings(
1418
bindings: Partial<CfWorkerInit["bindings"]>,
1519
tailConsumers: CfTailConsumer[] = [],
1620
streamingTailConsumers: CfTailConsumer[] = [],
21+
containers: ContainerApp[] = [],
1722
context: {
1823
registry?: WorkerRegistry | null;
1924
local?: boolean;
@@ -739,10 +744,26 @@ export function printBindings(
739744
);
740745
}
741746

747+
if (containers.length > 0) {
748+
let containersTitle = "The following containers are available:";
749+
if (context.name && getFlag("MULTIWORKER")) {
750+
containersTitle = `The following containers are available from ${chalk.blue(context.name)}:`;
751+
}
752+
753+
logger.log(
754+
`${containersTitle}\n${containers
755+
.map((c) => {
756+
return `- ${c.name} (${c.image})`;
757+
})
758+
.join("\n")}`
759+
);
760+
logger.log();
761+
}
762+
742763
if (hasConnectionStatus) {
743764
logger.once.info(
744765
dim(
745-
`\nService bindings, Durable Object bindings, and Tail consumers connect to other wrangler or vite dev processes running locally, with their connection status indicated by ${chalk.green("[connected]")} or ${chalk.red("[not connected]")}. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development\n`
766+
`\nService bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite dev processes running locally, with their connection status indicated by ${chalk.green("[connected]")} or ${chalk.red("[not connected]")}. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development\n`
746767
)
747768
);
748769
}

0 commit comments

Comments
 (0)