Skip to content

Commit c3d5006

Browse files
committed
print containers
1 parent c39c089 commit c3d5006

File tree

5 files changed

+56
-21
lines changed

5 files changed

+56
-21
lines changed

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

Lines changed: 25 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
@@ -284,10 +290,14 @@ describe("wrangler deploy with containers", () => {
284290
──────────────────
285291
Total Upload: xx KiB / gzip: xx KiB
286292
Worker Startup Time: 100 ms
293+
287294
Your Worker has access to the following bindings:
288295
Binding Resource
289296
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
290297
298+
The following containers are available:
299+
- my-container (registry.cloudflare.com/hello:world)
300+
291301
Uploaded test-name (TIMINGS)
292302
Deployed test-name triggers (TIMINGS)
293303
https://test-name.test-sub-domain.workers.dev
@@ -386,6 +396,9 @@ describe("wrangler deploy with containers", () => {
386396
Binding Resource
387397
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
388398
399+
The following containers are available:
400+
- my-container (registry.cloudflare.com/hello:world)
401+
389402
Uploaded test-name (TIMINGS)
390403
Deployed test-name triggers (TIMINGS)
391404
https://test-name.test-sub-domain.workers.dev
@@ -476,23 +489,6 @@ describe("wrangler deploy with containers", () => {
476489

477490
await runWrangler("deploy --cwd src");
478491

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-
`);
496492
expect(std.err).toMatchInlineSnapshot(`""`);
497493
expect(std.warn).toMatchInlineSnapshot(`""`);
498494
});
@@ -549,6 +545,9 @@ describe("wrangler deploy with containers", () => {
549545
Binding Resource
550546
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
551547
548+
The following containers are available:
549+
- my-container (<cwd>/Dockerfile)
550+
552551
Uploaded test-name (TIMINGS)
553552
Building image my-container:Galaxy
554553
Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
@@ -1838,6 +1837,9 @@ describe("wrangler deploy with containers", () => {
18381837
──────────────────
18391838
Total Upload: xx KiB / gzip: xx KiB
18401839
Worker Startup Time: 100 ms
1840+
The following containers are available:
1841+
- my-container (registry.cloudflare.com/hello:world)
1842+
18411843
Uploaded test-name (TIMINGS)
18421844
Deployed test-name triggers (TIMINGS)
18431845
https://test-name.test-sub-domain.workers.dev
@@ -2086,6 +2088,9 @@ describe("wrangler deploy with containers dry run", () => {
20862088
Binding Resource
20872089
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
20882090
2091+
The following containers are available:
2092+
- my-container (<cwd>/Dockerfile)
2093+
20892094
--dry-run: exiting now."
20902095
`);
20912096
expect(cliStd.stdout).toMatchInlineSnapshot(`""`);
@@ -2113,6 +2118,9 @@ describe("wrangler deploy with containers dry run", () => {
21132118
Binding Resource
21142119
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
21152120
2121+
The following containers are available:
2122+
- my-container (registry.cloudflare.com/hello:world)
2123+
21162124
--dry-run: exiting now."
21172125
`);
21182126
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
@@ -915,6 +915,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
915915
{ ...withoutStaticAssets, vars: maskedVars },
916916
config.tail_consumers,
917917
config.streaming_tail_consumers,
918+
config.containers,
918919
{ warnIfNoBindings: true }
919920
);
920921
} else {
@@ -1054,7 +1055,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10541055
printBindings(
10551056
{ ...withoutStaticAssets, vars: maskedVars },
10561057
config.tail_consumers,
1057-
config.streaming_tail_consumers
1058+
config.streaming_tail_consumers,
1059+
config.containers
10581060
);
10591061

10601062
versionId = parseNonHyphenedUuid(result.deployment_id);
@@ -1084,7 +1086,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10841086
printBindings(
10851087
{ ...withoutStaticAssets, vars: maskedVars },
10861088
config.tail_consumers,
1087-
config.streaming_tail_consumers
1089+
config.streaming_tail_consumers,
1090+
config.containers
10881091
);
10891092
}
10901093
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: 24 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,27 @@ export function printBindings(
739744
);
740745
}
741746

747+
if (containers.length > 0) {
748+
let containersTitle: string;
749+
if (context.name && getFlag("MULTIWORKER")) {
750+
containersTitle = `The following containers are available from ${chalk.blue(context.name)}:`;
751+
} else {
752+
}
753+
754+
logger.log(
755+
`${containersTitle}\n${containers
756+
.map((c) => {
757+
return `- ${c.name} (${c.image})`;
758+
})
759+
.join("\n")}`
760+
);
761+
logger.log();
762+
}
763+
742764
if (hasConnectionStatus) {
743765
logger.once.info(
744766
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`
767+
`\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`
746768
)
747769
);
748770
}

0 commit comments

Comments
 (0)