11import { Buffer } from "node:buffer" ;
2- import { spawn , spawnSync } from "node:child_process" ;
2+ import { execFile , spawn , spawnSync } from "node:child_process" ;
33import { randomFillSync } from "node:crypto" ;
44import * as fs from "node:fs" ;
55import * as path from "node:path" ;
@@ -8708,6 +8708,28 @@ addEventListener('fetch', event => {});`
87088708 } ,
87098709 } as unknown as ChildProcess ;
87108710 }
8711+ vi . mocked ( execFile )
8712+ // docker images first call
8713+ . mockImplementationOnce ( ( cmd , args , callback ) => {
8714+ expect ( cmd ) . toBe ( "/usr/bin/docker" ) ;
8715+ expect ( args ) . toEqual ( [
8716+ "images" ,
8717+ "--digests" ,
8718+ "--format" ,
8719+ "{{.Digest}}" ,
8720+ getCloudflareContainerRegistry ( ) +
8721+ "/test_account_id/my-container:Galaxy" ,
8722+ ] ) ;
8723+ if ( callback ) {
8724+ const back = callback as (
8725+ error : Error | null ,
8726+ stdout : string ,
8727+ stderr : string
8728+ ) => void ;
8729+ back ( null , "three\n" , "" ) ;
8730+ }
8731+ return { } as ChildProcess ;
8732+ } ) ;
87118733
87128734 vi . mocked ( spawn )
87138735 // 1. docker build
@@ -8720,6 +8742,7 @@ addEventListener('fetch', event => {});`
87208742 "/test_account_id/my-container:Galaxy" ,
87218743 "--platform" ,
87228744 "linux/amd64" ,
8745+ "--provenance=false" ,
87238746 "-f" ,
87248747 "-" ,
87258748 "." ,
@@ -8808,7 +8831,40 @@ addEventListener('fetch', event => {});`
88088831 } ,
88098832 } as unknown as ChildProcess ;
88108833 } )
8811- // 4. docker push
8834+ // 4. docker manifest inspect
8835+ . mockImplementationOnce ( ( cmd , args ) => {
8836+ expect ( cmd ) . toBe ( "/usr/bin/docker" ) ;
8837+ expect ( args [ 0 ] ) . toBe ( "manifest" ) ;
8838+ expect ( args [ 1 ] ) . toBe ( "inspect" ) ;
8839+ expect ( args [ 2 ] ) . toEqual ( "my-container@three" ) ;
8840+ expect ( args ) . toEqual ( [
8841+ "manifest" ,
8842+ "inspect" ,
8843+ `${ getCloudflareContainerRegistry ( ) } /test_account_id/my-container@three` ,
8844+ ] ) ;
8845+ const readable = new Writable ( {
8846+ write ( ) { } ,
8847+ final ( ) { } ,
8848+ } ) ;
8849+ return {
8850+ stdout : Buffer . from (
8851+ "i promise I am an unsuccessful docker manifest call"
8852+ ) ,
8853+ stdin : readable ,
8854+ on : function (
8855+ reason : string ,
8856+ cbPassed : ( code : number ) => unknown
8857+ ) {
8858+ if ( reason === "close" ) {
8859+ // We always fail this for this test because this is meant to stop
8860+ // us pushing if it succeeds and we want to go through the push workflow also
8861+ cbPassed ( 1 ) ;
8862+ }
8863+ return this ;
8864+ } ,
8865+ } as unknown as ChildProcess ;
8866+ } )
8867+ // 5. docker push
88128868 . mockImplementationOnce ( ( cmd , args ) => {
88138869 expect ( cmd ) . toBe ( "/usr/bin/docker" ) ;
88148870 expect ( args ) . toEqual ( [
@@ -8868,7 +8924,7 @@ addEventListener('fetch', event => {});`
88688924 async ( { request } ) => {
88698925 const json =
88708926 ( await request . json ( ) ) as ImageRegistryCredentialsConfiguration ;
8871- expect ( json . permissions ) . toEqual ( [ "push" ] ) ;
8927+ expect ( json . permissions ) . toEqual ( [ "push" , "pull" ] ) ;
88728928
88738929 return HttpResponse . json ( {
88748930 account_id : "test_account_id" ,
@@ -8928,6 +8984,7 @@ addEventListener('fetch', event => {});`
89288984
89298985 Uploaded test-name (TIMINGS)
89308986 Building image my-container:Galaxy
8987+ Image does not exist remotely, pushing: registry.cloudflare.com/test_account_id/my-container:Galaxy
89318988 Deployed test-name triggers (TIMINGS)
89328989 https://test-name.test-sub-domain.workers.dev
89338990 Current Version ID: Galaxy-Class"
0 commit comments