11import {
22 deleteCertificate ,
33 deleteContainerApplication ,
4+ deleteContainerImage ,
45 deleteDatabase ,
56 deleteHyperdriveConfig ,
67 deleteKVNamespace ,
78 deleteProject ,
89 deleteWorker ,
910 listCertificates ,
11+ listE2eContainerImages ,
1012 listHyperdriveConfigs ,
1113 listTmpDatabases ,
1214 listTmpE2EContainerApplications ,
@@ -34,6 +36,24 @@ run().catch((e) => {
3436async function run ( ) {
3537 // KV namespaces don't have a creation timestamp, but deletion will fail if there is a worker bound to it
3638 // so delete these first to avoid interrupting running e2e jobs (unless you are very very unlucky)
39+ await deleteKVNamespaces ( ) ;
40+
41+ await deleteProjects ( ) ;
42+
43+ await deleteWorkers ( ) ;
44+
45+ await deleteD1Databases ( ) ;
46+
47+ await deleteHyperdriveConfigs ( ) ;
48+
49+ await deleteMtlsCertificates ( ) ;
50+
51+ await deleteContainerApplications ( ) ;
52+
53+ deleteContainerImages ( ) ;
54+ }
55+
56+ async function deleteKVNamespaces ( ) {
3757 const kvNamespacesToDelete = await listTmpKVNamespaces ( ) ;
3858 for ( const kvNamespace of kvNamespacesToDelete ) {
3959 console . log ( "Deleting KV namespace: " + kvNamespace . title ) ;
@@ -45,7 +65,9 @@ async function run() {
4565 if ( kvNamespacesToDelete . length === 0 ) {
4666 console . log ( `No KV namespaces to delete.` ) ;
4767 }
68+ }
4869
70+ async function deleteProjects ( ) {
4971 const projectsToDelete = await listTmpE2EProjects ( ) ;
5072
5173 for ( const project of projectsToDelete ) {
@@ -58,7 +80,24 @@ async function run() {
5880 if ( projectsToDelete . length === 0 ) {
5981 console . log ( `No projects to delete.` ) ;
6082 }
83+ }
84+
85+ function deleteContainerImages ( ) {
86+ const containerImagesToDelete = listE2eContainerImages ( ) ;
87+
88+ for ( const image of containerImagesToDelete ) {
89+ console . log ( "Deleting Container image: " + image . name + ":" + image . tag ) ;
90+ deleteContainerImage ( image )
91+ ? console . log ( `Successfully deleted project ${ image . name } :${ image . tag } ` )
92+ : console . log ( `Successfully deleted project ${ image . name } :${ image . tag } ` ) ;
93+ }
94+
95+ if ( containerImagesToDelete . length === 0 ) {
96+ console . log ( `No container image to delete.` ) ;
97+ }
98+ }
6199
100+ async function deleteWorkers ( ) {
62101 const workersToDelete = await listTmpE2EWorkers ( ) ;
63102
64103 for ( const worker of workersToDelete ) {
@@ -71,8 +110,11 @@ async function run() {
71110 if ( workersToDelete . length === 0 ) {
72111 console . log ( `No workers to delete.` ) ;
73112 }
113+ }
74114
115+ async function deleteD1Databases ( ) {
75116 const d1DatabasesToDelete = await listTmpDatabases ( ) ;
117+
76118 for ( const db of d1DatabasesToDelete ) {
77119 console . log ( "Deleting D1 database: " + db . name ) ;
78120 ( await deleteDatabase ( db . uuid ) )
@@ -82,7 +124,9 @@ async function run() {
82124 if ( d1DatabasesToDelete . length === 0 ) {
83125 console . log ( `No D1 databases to delete.` ) ;
84126 }
127+ }
85128
129+ async function deleteHyperdriveConfigs ( ) {
86130 const hyperdriveConfigsToDelete = await listHyperdriveConfigs ( ) ;
87131 for ( const config of hyperdriveConfigsToDelete ) {
88132 console . log ( "Deleting Hyperdrive configs: " + config . id ) ;
@@ -94,7 +138,9 @@ async function run() {
94138 if ( hyperdriveConfigsToDelete . length === 0 ) {
95139 console . log ( `No Hyperdrive configs to delete.` ) ;
96140 }
141+ }
97142
143+ async function deleteMtlsCertificates ( ) {
98144 const mtlsCertificates = await listCertificates ( ) ;
99145 for ( const certificate of mtlsCertificates ) {
100146 console . log ( "Deleting mTLS certificate: " + certificate . id ) ;
@@ -107,7 +153,9 @@ async function run() {
107153 `Successfully deleted ${ mtlsCertificates . length } mTLS certificates`
108154 ) ;
109155 }
156+ }
110157
158+ async function deleteContainerApplications ( ) {
111159 const containers = await listTmpE2EContainerApplications ( ) ;
112160 for ( const container of containers ) {
113161 await deleteContainerApplication ( container ) ;
0 commit comments