@@ -38,6 +38,8 @@ const core = __importStar(require("@actions/core"));
3838const exec = __importStar ( require ( "@actions/exec" ) ) ;
3939const os = __importStar ( require ( "os" ) ) ;
4040const sendReportRetryCount = 1 ;
41+ const GetScanContextURL = "https://dfdinfra-afdendpoint-prod-d5fqbucbg7fue0cf.z01.azurefd.net/github/v1/auth-push/GetScanContext?context=authOnly" ;
42+ const ContainerMappingURL = "https://dfdinfra-afdendpoint-prod-d5fqbucbg7fue0cf.z01.azurefd.net/github/v1/container-mappings" ;
4143class ContainerMapping {
4244 constructor ( ) {
4345 this . succeedOnError = true ;
@@ -166,7 +168,6 @@ class ContainerMapping {
166168 return __awaiter ( this , void 0 , void 0 , function * ( ) {
167169 return new Promise ( ( resolve , reject ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
168170 let apiTime = new Date ( ) . getMilliseconds ( ) ;
169- let url = "https://dfdinfra-afdendpoint-prod-d5fqbucbg7fue0cf.z01.azurefd.net/github/v1/container-mappings" ;
170171 let options = {
171172 method : 'POST' ,
172173 timeout : 2500 ,
@@ -176,8 +177,8 @@ class ContainerMapping {
176177 'Content-Length' : data . length
177178 }
178179 } ;
179- core . debug ( `${ options [ 'method' ] . toUpperCase ( ) } ${ url } ` ) ;
180- const req = https . request ( url , options , ( res ) => {
180+ core . debug ( `${ options [ 'method' ] . toUpperCase ( ) } ${ ContainerMappingURL } ` ) ;
181+ const req = https . request ( ContainerMappingURL , options , ( res ) => {
181182 let resData = '' ;
182183 res . on ( 'data' , ( chunk ) => {
183184 resData += chunk . toString ( ) ;
@@ -215,32 +216,31 @@ class ContainerMapping {
215216 }
216217 else {
217218 core . debug ( `Unexpected status code: ${ statusCode } ` ) ;
218- if ( retryCount == 0 ) {
219- return false ;
220- }
221- else {
222- core . info ( `Retrying API call.\nRetry count: ${ retryCount } ` ) ;
223- retryCount -- ;
224- return yield this . checkCallerIsCustomer ( bearerToken , retryCount ) ;
225- }
219+ return yield this . retryCall ( bearerToken , retryCount ) ;
226220 }
227221 } ) )
228222 . catch ( ( error ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
229- if ( retryCount == 0 ) {
230- return false ;
231- }
232- else {
233- core . info ( `Retrying checkCallerIsCustomer call due to error: ${ error } .\nRetry count: ${ retryCount } ` ) ;
234- retryCount -- ;
235- return yield this . checkCallerIsCustomer ( bearerToken , retryCount ) ;
236- }
223+ core . info ( `Unexpected error: ${ error } .` ) ;
224+ return yield this . retryCall ( bearerToken , retryCount ) ;
237225 } ) ) ;
238226 } ) ;
239227 }
228+ retryCall ( bearerToken , retryCount ) {
229+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
230+ if ( retryCount == 0 ) {
231+ core . info ( `All retries failed.` ) ;
232+ return false ;
233+ }
234+ else {
235+ core . info ( `Retrying checkCallerIsCustomer.\nRetry count: ${ retryCount } ` ) ;
236+ retryCount -- ;
237+ return yield this . checkCallerIsCustomer ( bearerToken , retryCount ) ;
238+ }
239+ } ) ;
240+ }
240241 _checkCallerIsCustomer ( bearerToken ) {
241242 return __awaiter ( this , void 0 , void 0 , function * ( ) {
242243 return new Promise ( ( resolve , reject ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
243- let url = "https://dfdinfra-afdendpoint-prod-d5fqbucbg7fue0cf.z01.azurefd.net/github/v1/auth-push/GetScanContext?context=authOnly" ;
244244 let options = {
245245 method : 'GET' ,
246246 timeout : 2500 ,
@@ -249,8 +249,8 @@ class ContainerMapping {
249249 'Authorization' : 'Bearer ' + bearerToken ,
250250 }
251251 } ;
252- core . debug ( `${ options [ 'method' ] . toUpperCase ( ) } ${ url } ` ) ;
253- const req = https . request ( url , options , ( res ) => {
252+ core . debug ( `${ options [ 'method' ] . toUpperCase ( ) } ${ GetScanContextURL } ` ) ;
253+ const req = https . request ( GetScanContextURL , options , ( res ) => {
254254 res . on ( 'end' , ( ) => {
255255 resolve ( res . statusCode ) ;
256256 } ) ;
0 commit comments