File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff 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+
9194export async function buildAndMaybePush (
9295args : BuildArgs ,
9396pathToDocker : string ,
9497push : boolean ,
9598containerConfig ?: Exclude < ContainerNormalizedConfig , ImageURIConfig >
96- ) : Promise < { remoteDigest : string } | { newTag : string } > {
99+ ) : Promise < ImageRef > {
97100try {
98101const imageTag = `${ getCloudflareContainerRegistry ( ) } /${ args . tag } ` ;
99102const { buildCmd, dockerfile } = await constructBuildCommand (
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { logger } from "../logger";
88import { fetchVersion } from "../versions/api" ;
99import { buildAndMaybePush } from "./build" ;
1010import { fillOpenAPIConfiguration } from "./common" ;
11+ import type { ImageRef } from "./build" ;
1112import type {
1213ContainerNormalizedConfig ,
1314ImageURIConfig ,
@@ -19,7 +20,7 @@ export async function buildContainer(
1920imageTag : string ,
2021dryRun : boolean ,
2122pathToDocker : string
22- ) : Promise < { remoteDigest : string } | { newTag : string } > {
23+ ) : Promise < ImageRef > {
2324const imageFullName = containerConfig . name + ":" + imageTag . split ( "-" ) [ 0 ] ;
2425logger . log ( "Building image" , imageFullName ) ;
2526
@@ -57,7 +58,7 @@ export async function deployContainers(
5758
5859const pathToDocker = getDockerPath ( ) ;
5960const version = await fetchVersion ( config , accountId , scriptName , versionId ) ;
60- let imageRef : { remoteDigest : string } | { newTag : string } ;
61+ let imageRef : ImageRef ;
6162for ( const container of normalisedContainerConfig ) {
6263if ( "dockerfile" in container ) {
6364imageRef = await buildContainer (
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import {
3030sortObjectRecursive ,
3131stripUndefined ,
3232} from "../utils/sortObjectRecursive" ;
33+ import type { ImageRef } from "../cloudchamber/build" ;
3334import type { Config } from "../config" ;
3435import type { ContainerApp } from "../config/environment" ;
3536import type {
@@ -191,7 +192,7 @@ function containerConfigToCreateRequest(
191192
192193export async function apply (
193194args : {
194- imageRef : { remoteDigest : string } | { newTag : string } ;
195+ imageRef : ImageRef ;
195196durable_object_namespace_id : string ;
196197} ,
197198containerConfig : ContainerNormalizedConfig ,
You can’t perform that action at this time.
0 commit comments