From fac4e5654beb2c58c3ce46b04848ccc0d112d2fe Mon Sep 17 00:00:00 2001 From: Chandni Patel Date: Mon, 15 Aug 2022 13:56:14 -0500 Subject: [PATCH] validation for windows only --- lib/utils/client.js | 70 +++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/lib/utils/client.js b/lib/utils/client.js index 88b64fd9b..647c83ce9 100644 --- a/lib/utils/client.js +++ b/lib/utils/client.js @@ -14,6 +14,7 @@ const WebClient_1 = require("azure-actions-webclient/WebClient"); const logger_1 = require("./logger"); const exceptions_1 = require("../exceptions"); const authentication_type_1 = require("../constants/authentication_type"); +const runtime_stack_1 = require("../constants/runtime_stack"); const fs = require("fs"); class Client { static ping(url, retryCount = 1, retryIntervalSecond = 5) { @@ -104,15 +105,16 @@ class Client { let username = ""; let password = ""; let uri = ""; - if (context.authenticationType === authentication_type_1.AuthenticationType.Scm) { - logger_1.Logger.Info("Validating deployment package for functions app before Zip Deploy (SCM)"); - if (context.scmCredentials) { - username = context.scmCredentials.username; - password = context.scmCredentials.password; - uri = context.scmCredentials.uri; - } - } - else if (context.authenticationType === authentication_type_1.AuthenticationType.Rbac) { + // if (context.authenticationType === AuthenticationType.Scm) { + // Logger.Info("Validating deployment package for functions app before Zip Deploy (SCM)"); + // if (context.scmCredentials){ + // username = context.scmCredentials.username; + // password = context.scmCredentials.password; + // uri = context.scmCredentials.uri; + // } + // } + if (context.authenticationType === authentication_type_1.AuthenticationType.Rbac && + context.os === runtime_stack_1.RuntimeStackConstant.Windows) { logger_1.Logger.Info("Validating deployment package for functions app before Zip Deploy (RBAC)"); var publishingCredentials = yield context.appService.getPublishingCredentials(); if (publishingCredentials.properties["scmUri"]) { @@ -120,32 +122,32 @@ class Client { password = publishingCredentials.properties["publishingPassword"]; uri = publishingCredentials.properties["scmUri"]; } - } - const base64Cred = Buffer.from(`${username}:${password}`).toString('base64'); - let request = { - method: 'POST', - uri: `${uri}/api/zipdeploy/validate`, - headers: { - 'Content-Type': 'application/json', - 'Authorization': `Basic ${base64Cred}` - }, - body: fs.createReadStream(webPackage) - }; - let response = yield Client.webClient.sendRequest(request); - if (response.statusCode == 200) { - logger_1.Logger.Info(`##[debug]Validation passed response: ${JSON.stringify(response)}`); - if (response.body && response.body.result) { - logger_1.Logger.Warn(JSON.stringify(response.body.result)); + const base64Cred = Buffer.from(`${username}:${password}`).toString('base64'); + let request = { + method: 'POST', + uri: `${uri}/api/zipdeploy/validate`, + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Basic ${base64Cred}` + }, + body: fs.createReadStream(webPackage) + }; + let response = yield Client.webClient.sendRequest(request); + if (response.statusCode == 200) { + logger_1.Logger.Info(`##[debug]Validation passed response: ${JSON.stringify(response)}`); + if (response.body && response.body.result) { + logger_1.Logger.Warn(JSON.stringify(response.body.result)); + } + return null; + } + else if (response.statusCode == 400) { + logger_1.Logger.Info(`##[debug]Validation failed response: ${JSON.stringify(response)}`); + throw response; + } + else { + logger_1.Logger.Info(`##[debug]Skipping validation with status: ${response.statusCode}`); + return null; } - return null; - } - else if (response.statusCode == 400) { - logger_1.Logger.Info(`##[debug]Validation failed response: ${JSON.stringify(response)}`); - throw response; - } - else { - logger_1.Logger.Info(`##[debug]Skipping validation with status: ${response.statusCode}`); - return null; } } catch (error) {