@@ -26,7 +26,7 @@ async function patch(patchPath, registry, registryPath) {
26
26
if ( patchConfig . deleteUntaggedImages && patchConfig . imageIds ) {
27
27
await deleteUntaggedImages ( patchConfig . imageIds , registry ) ;
28
28
}
29
-
29
+
30
30
console . log ( '\n(*) Done!' )
31
31
}
32
32
@@ -36,17 +36,16 @@ async function patchImage(imageId, patchPath, dockerFilePath, bumpVersion, regis
36
36
37
37
// Get repository and tag list for imageId
38
38
let repoAndTagList = await getImageRepositoryAndTags ( imageId , registry ) ;
39
- if ( repoAndTagList . length === 0 ) {
39
+ if ( repoAndTagList . length === 0 ) {
40
40
console . log ( '(*) No tags to patch. Skipping.' ) ;
41
41
return ;
42
42
}
43
43
44
- console . log ( `(*) Tags to update: ${
45
- JSON . stringify ( repoAndTagList . reduce ( ( prev , repoAndTag ) => { return prev + repoAndTag . repository + ':' + repoAndTag . tag + ' ' } , '' ) , undefined , 4 )
44
+ console . log ( `(*) Tags to update: ${ JSON . stringify ( repoAndTagList . reduce ( ( prev , repoAndTag ) => { return prev + repoAndTag . repository + ':' + repoAndTag . tag + ' ' } , '' ) , undefined , 4 )
46
45
} `) ;
47
46
48
47
// Bump breakfix number of it applies
49
- if ( bumpVersion ) {
48
+ if ( bumpVersion ) {
50
49
repoAndTagList = updateVersionTags ( repoAndTagList ) ;
51
50
}
52
51
@@ -59,7 +58,7 @@ async function patchImage(imageId, patchPath, dockerFilePath, bumpVersion, regis
59
58
let retry = false ;
60
59
do {
61
60
try {
62
- await asyncUtils . spawn ( 'docker' , [
61
+ await asyncUtils . spawn ( 'docker' , [
63
62
'build' ,
64
63
'--pull' ,
65
64
'--build-arg' ,
@@ -76,7 +75,7 @@ async function patchImage(imageId, patchPath, dockerFilePath, bumpVersion, regis
76
75
} else {
77
76
throw ex ;
78
77
}
79
- }
78
+ }
80
79
} while ( retry ) ;
81
80
82
81
// Push updates
@@ -145,7 +144,9 @@ async function deleteUntaggedImages(imageIds, registry) {
145
144
'delete' ,
146
145
'--yes' ,
147
146
'--name' , registryName ,
148
- '--image' , fullImageId
147
+ '--image' , fullImageId ,
148
+ '--username' , '$TOKEN_NAME' ,
149
+ '--password' , '$PASSWORD'
149
150
] , spawnOpts ) ;
150
151
} ) ;
151
152
@@ -159,22 +160,44 @@ async function getImageRepositoryAndTags(imageId, registry) {
159
160
160
161
// Get list of repositories
161
162
console . log ( `(*) Getting repository list for ACR "${ registryName } "...` )
162
- const repositoryListOutput = await asyncUtils . spawn ( 'az' ,
163
- [ 'acr' , 'repository' , 'list' , '--name' , registryName ] ,
163
+ const repositoryListOutput = await asyncUtils . spawn ( 'az' , [
164
+ 'acr' ,
165
+ 'repository' ,
166
+ 'list' ,
167
+ '--name' ,
168
+ registryName ,
169
+ '--username' ,
170
+ '$TOKEN_NAME' ,
171
+ '--password' ,
172
+ '$PASSWORD'
173
+ ] ,
164
174
{ shell : true , stdio : 'pipe' } ) ;
165
175
const repositoryList = JSON . parse ( repositoryListOutput ) ;
166
176
167
177
let repoAndTagList = [ ] ;
168
178
await asyncUtils . forEach ( repositoryList , async ( repository ) => {
169
179
console . log ( `(*) Checking in for "${ imageId } " in "${ repository } "...` ) ;
170
- const tagListOutput = await asyncUtils . spawn ( 'az' ,
171
- [ 'acr' , 'repository' , 'show-tags' , '--detail' , '--name' , registryName , '--repository' , repository , "--query" , `"[?digest=='${ imageId } '].name"` ] ,
172
- { shell : true , stdio : 'pipe' } ) ;
180
+ const tagListOutput = await asyncUtils . spawn ( 'az' , [
181
+ 'acr' ,
182
+ 'repository' ,
183
+ 'show-tags' ,
184
+ '--detail' ,
185
+ '--name' ,
186
+ registryName ,
187
+ '--repository' ,
188
+ repository ,
189
+ "--query" ,
190
+ `"[?digest=='${ imageId } '].name"` ,
191
+ '--username' ,
192
+ '$TOKEN_NAME' ,
193
+ '--password' ,
194
+ '$PASSWORD'
195
+ ] , { shell : true , stdio : 'inherit' } ) ;
173
196
const additionalTags = JSON . parse ( tagListOutput ) ;
174
197
repoAndTagList = repoAndTagList . concat ( additionalTags . map ( ( tag ) => {
175
- return {
176
- repository :repository ,
177
- tag :tag
198
+ return {
199
+ repository : repository ,
200
+ tag : tag
178
201
} ;
179
202
} ) ) ;
180
203
} ) ;
@@ -190,8 +213,8 @@ async function getImageManifests(imageIds, registry) {
190
213
// Get list of repositories
191
214
console . log ( `(*) Getting repository list for ACR "${ registryName } "...` )
192
215
const repositoryListOutput = await asyncUtils . spawn ( 'az' ,
193
- [ 'acr' , 'repository' , 'list' , '--name' , registryName ] ,
194
- { shell : true , stdio : 'pipe ' } ) ;
216
+ [ 'acr' , 'repository' , 'list' , '--name' , registryName , '--username' , '$TOKEN_NAME' , '--password' , '$PASSWORD' ] ,
217
+ { shell : true , stdio : 'inherit ' } ) ;
195
218
const repositoryList = JSON . parse ( repositoryListOutput ) ;
196
219
197
220
// Query each repository for images, then add any tags found to the list
@@ -201,8 +224,8 @@ async function getImageManifests(imageIds, registry) {
201
224
await asyncUtils . forEach ( repositoryList , async ( repository ) => {
202
225
console . log ( `(*) Getting manifests from "${ repository } "...` ) ;
203
226
const registryManifestListOutput = await asyncUtils . spawn ( 'az' ,
204
- [ 'acr' , 'repository' , 'show-manifests' , '--name' , registryName , '--repository' , repository , "--query" , query ] ,
205
- { shell : true , stdio : 'pipe ' } ) ;
227
+ [ 'acr' , 'repository' , 'show-manifests' , '--name' , registryName , '--repository' , repository , "--query" , query , '--username' , '$TOKEN_NAME' , '--password' , '$PASSWORD' ] ,
228
+ { shell : true , stdio : 'inherit ' } ) ;
206
229
let registryManifestList = JSON . parse ( registryManifestListOutput ) ;
207
230
registryManifestList = registryManifestList . map ( ( manifest ) => {
208
231
manifest . repository = repository ;
0 commit comments