Skip to content

Commit a1ea81d

Browse files
committed
pr feedback
1 parent f9e2788 commit a1ea81d

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

packages/wrangler/src/cloudchamber/build.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,22 @@ export function pushYargs(yargs: CommonYargsArgv) {
8181

8282
/**
8383
*
84-
* @returns `{ digest: string }` if the image already exists remotely. we will
84+
* `{ remoteDigest: string }` implies the image already exists remotely. we will
8585
* try and replace this with the image tag from the last deployment if possible.
8686
* If a deployment failed between push and deploy, we can't know for certain
87-
* what the tag of the last push was, so let's just use the digest instead.
87+
* what the tag of the last push was, so we will use the digest instead.
8888
*
89-
* @returns `{ tag: string }` if the image was built and pushed
89+
* `{ newTag: string }` implies the image was built and pushed and the deployment
90+
* should be associated with a new tag.
9091
*/
92+
export type ImageRef = { remoteDigest: string } | { newTag: string };
93+
9194
export async function buildAndMaybePush(
9295
args: BuildArgs,
9396
pathToDocker: string,
9497
push: boolean,
9598
containerConfig?: Exclude<ContainerNormalizedConfig, ImageURIConfig>
96-
): Promise<{ remoteDigest: string } | { newTag: string }> {
99+
): Promise<ImageRef> {
97100
try {
98101
const imageTag = `${getCloudflareContainerRegistry()}/${args.tag}`;
99102
const { buildCmd, dockerfile } = await constructBuildCommand(

packages/wrangler/src/cloudchamber/deploy.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { logger } from "../logger";
88
import { fetchVersion } from "../versions/api";
99
import { buildAndMaybePush } from "./build";
1010
import { fillOpenAPIConfiguration } from "./common";
11+
import type { ImageRef } from "./build";
1112
import type {
1213
ContainerNormalizedConfig,
1314
ImageURIConfig,
@@ -19,7 +20,7 @@ export async function buildContainer(
1920
imageTag: string,
2021
dryRun: boolean,
2122
pathToDocker: string
22-
): Promise<{ remoteDigest: string } | { newTag: string }> {
23+
): Promise<ImageRef> {
2324
const imageFullName = containerConfig.name + ":" + imageTag.split("-")[0];
2425
logger.log("Building image", imageFullName);
2526

@@ -57,7 +58,7 @@ export async function deployContainers(
5758

5859
const pathToDocker = getDockerPath();
5960
const version = await fetchVersion(config, accountId, scriptName, versionId);
60-
let imageRef: { remoteDigest: string } | { newTag: string };
61+
let imageRef: ImageRef;
6162
for (const container of normalisedContainerConfig) {
6263
if ("dockerfile" in container) {
6364
imageRef = await buildContainer(

packages/wrangler/src/containers/deploy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
sortObjectRecursive,
3131
stripUndefined,
3232
} from "../utils/sortObjectRecursive";
33+
import type { ImageRef } from "../cloudchamber/build";
3334
import type { Config } from "../config";
3435
import type { ContainerApp } from "../config/environment";
3536
import type {
@@ -191,7 +192,7 @@ function containerConfigToCreateRequest(
191192

192193
export async function apply(
193194
args: {
194-
imageRef: { remoteDigest: string } | { newTag: string };
195+
imageRef: ImageRef;
195196
durable_object_namespace_id: string;
196197
},
197198
containerConfig: ContainerNormalizedConfig,

0 commit comments

Comments
 (0)