@@ -6,8 +6,8 @@ import * as toolcache from "@actions/tool-cache";
6
6
import { pki } from "node-forge" ;
7
7
8
8
import * as actionsUtil from "./actions-util" ;
9
- import * as util from "./util" ;
10
9
import { getActionsLogger , Logger } from "./logging" ;
10
+ import * as util from "./util" ;
11
11
12
12
const UPDATEJOB_PROXY = "update-job-proxy" ;
13
13
const UPDATEJOB_PROXY_VERSION = "v2.0.20240722180912" ;
@@ -100,7 +100,11 @@ async function runWrapper() {
100
100
101
101
// Get the configuration options
102
102
const credentials = getCredentials ( logger ) ;
103
- logger . info ( `Credentials loaded for the following registries:\n ${ credentials . map ( c => credentialToStr ( c ) ) . join ( "\n" ) } ` ) ;
103
+ logger . info (
104
+ `Credentials loaded for the following registries:\n ${ credentials
105
+ . map ( ( c ) => credentialToStr ( c ) )
106
+ . join ( "\n" ) } `,
107
+ ) ;
104
108
105
109
const ca = generateCertificateAuthority ( ) ;
106
110
const proxyAuth = getProxyAuth ( ) ;
@@ -116,7 +120,12 @@ async function runWrapper() {
116
120
await startProxy ( proxyBin , proxyConfig , proxyLogFilePath , logger ) ;
117
121
}
118
122
119
- async function startProxy ( binPath : string , config : ProxyConfig , logFilePath : string , logger : Logger ) {
123
+ async function startProxy (
124
+ binPath : string ,
125
+ config : ProxyConfig ,
126
+ logFilePath : string ,
127
+ logger : Logger ,
128
+ ) {
120
129
const host = "127.0.0.1" ;
121
130
let port = 49152 ;
122
131
try {
@@ -170,10 +179,12 @@ async function startProxy(binPath: string, config: ProxyConfig, logFilePath: str
170
179
// It prefers `registries_credentials` over `registry_secrets`.
171
180
// If neither is set, it returns an empty array.
172
181
function getCredentials ( logger : Logger ) : Credential [ ] {
173
- const registriesCredentials = actionsUtil . getOptionalInput ( "registries_credentials" ) ;
182
+ const registriesCredentials = actionsUtil . getOptionalInput (
183
+ "registries_credentials" ,
184
+ ) ;
174
185
const registrySecrets = actionsUtil . getOptionalInput ( "registry_secrets" ) ;
175
186
176
- var credentialsStr : string ;
187
+ let credentialsStr : string ;
177
188
if ( registriesCredentials !== undefined ) {
178
189
logger . info ( `Using registries_credentials input.` ) ;
179
190
credentialsStr = Buffer . from ( registriesCredentials , "base64" ) . toString ( ) ;
@@ -187,36 +198,35 @@ function getCredentials(logger: Logger): Credential[] {
187
198
188
199
// Parse and validate the credentials
189
200
const parsed = JSON . parse ( credentialsStr ) as Credential [ ] ;
190
- let out : Credential [ ] = [ ]
191
- parsed . forEach ( e => {
201
+ const out : Credential [ ] = [ ] ;
202
+ for ( const e of parsed ) {
192
203
if ( e . url === undefined && e . host === undefined ) {
193
- throw "Invalid credentials - must specify host or url"
204
+ throw new Error ( "Invalid credentials - must specify host or url" ) ;
194
205
}
195
206
out . push ( {
196
- type : e . type ,
197
- host : e . host ,
198
- url : e . url ,
199
- username : e . username ,
200
- password : e . password ,
201
- token : e . token ,
202
- } )
203
- } ) ;
207
+ type : e . type ,
208
+ host : e . host ,
209
+ url : e . url ,
210
+ username : e . username ,
211
+ password : e . password ,
212
+ token : e . token ,
213
+ } ) ;
214
+ }
204
215
return out ;
205
216
}
206
217
207
218
// getProxyAuth returns the authentication information for the proxy itself.
208
- function getProxyAuth ( ) : BasicAuthCredentials | undefined {
219
+ function getProxyAuth ( ) : BasicAuthCredentials | undefined {
209
220
const proxy_password = actionsUtil . getOptionalInput ( "proxy_password" ) ;
210
221
if ( proxy_password ) {
211
222
return {
212
223
username : PROXY_USER ,
213
224
password : proxy_password ,
214
225
} ;
215
226
}
216
- return ;
227
+ return ;
217
228
}
218
229
219
-
220
230
async function getProxyBinaryPath ( ) : Promise < string > {
221
231
let proxyBin = toolcache . find ( UPDATEJOB_PROXY , UPDATEJOB_PROXY_VERSION ) ;
222
232
if ( ! proxyBin ) {
@@ -233,8 +243,9 @@ async function getProxyBinaryPath(): Promise<string> {
233
243
}
234
244
235
245
function credentialToStr ( c : Credential ) : string {
236
- return `Type: ${ c . type } ; Host: ${ c . host } ; Url: ${ c . url } Username: ${ c . username } ; Password: ${ c . password !== undefined } ; Token: ${ c . token !== undefined } `
246
+ return `Type: ${ c . type } ; Host: ${ c . host } ; Url: ${ c . url } Username: ${
247
+ c . username
248
+ } ; Password: ${ c . password !== undefined } ; Token: ${ c . token !== undefined } `;
237
249
}
238
250
239
-
240
251
void runWrapper ( ) ;
0 commit comments