diff --git a/src/configure/clients/github/TemplateServiceClient.ts b/src/configure/clients/github/TemplateServiceClient.ts index cb1082da..763dc0b1 100644 --- a/src/configure/clients/github/TemplateServiceClient.ts +++ b/src/configure/clients/github/TemplateServiceClient.ts @@ -1,4 +1,3 @@ -import { ServiceClientCredentials } from "ms-rest"; import { ExtendedPipelineTemplate } from "../../model/Contracts"; import { RepositoryAnalysisParameters } from "../../model/models"; import { PipelineTemplateMetadata } from "../../model/templateModels"; @@ -6,26 +5,492 @@ import { RestClient } from "../restClient"; export class TemplateServiceClient { private restClient: RestClient; - private readonly templateServiceUri: string = "https://pepfcusc.portalext.visualstudio.com/_apis/TemplateService"; + private readonly templateServiceUri: string = "https://tswithouthmac.azurewebsites.net/Templates"; - constructor(credentials: ServiceClientCredentials) { - this.restClient = new RestClient(credentials); + public constructor() { + this.restClient = new RestClient(); } public async getTemplates(body: RepositoryAnalysisParameters): Promise { return this.restClient.sendRequest2( this.templateServiceUri, 'POST', - '6.0-preview.1', + '2019-05-01', body); } public async getTemplateParameters(templateId: string): Promise { - var requestUri = this.templateServiceUri + "/" + templateId + "/parameters"; - return this.restClient.sendRequest2( + var requestUri = this.templateServiceUri + "/" + templateId + "/parameters"; + var extendedPipelineTemplate = await this.restClient.sendRequest2( requestUri, 'GET', - '6.0-preview.1' + '2019-05-01' ); + //return extendedPipelineTemplate; + var extendedPipelineTemplate2 = + { + "groups": [ + { + "id": "cdResource", + "name": "Existing resource on which CD is getting setup", + "properties": { + "context": "cdResource" + } + }, + { + "id": "containerRegistry", + "name": "Container Registry", + "properties": { + "context": "service" + } + }, + { + "id": "dockerInputs", + "name": "Application Settings", + "properties": { + "context": "application" + } + } + ], + "dataSources": [ + { + "id": "listExistingAKS", + "endpointUrlStem": "/subscriptions/{{{inputs.subscriptionId}}}/providers/Microsoft.ContainerService/managedClusters?api-version=2018-03-31", + "httpMethod": "GET", + "resultSelector": "$.value", + "resultTemplate": "{\"DisplayValue\":\"{{{name}}}\", \"Value\":\"{{{id}}}\", \"Group\":\"{{#parseAzureResourceId}}{{{id}}} 4{{/parseAzureResourceId}}\"}" + }, + { + "id": "httpApplicationRoutingDomain", + "endpointUrlStem": "{{{inputs.clusterId}}}?api-version=2018-03-31", + "httpMethod": null, + "requestBody": null, + "resultSelector": "$.properties.addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName", + "resultTemplate": null + }, + { + "id": "kubernetesVersion", + "endpointUrlStem": "{{{inputs.clusterId}}}?api-version=2018-03-31", + "httpMethod": null, + "requestBody": null, + "resultSelector": "$.properties.kubernetesVersion", + "resultTemplate": null + }, + { + "id": "getResourceGroupLocation", + "endpointUrlStem": "subscriptions/{{{inputs.subscriptionId}}}/resourceGroups//{{#parseAzureResourceId}}{{{inputs.clusterId}}} 4{{/parseAzureResourceId}}?api-version=2014-04-01-preview", + "httpMethod": "GET", + "resultTemplate": "{{{location}}}" + }, + { + "id": "fetchExistingContainerRegistriesInSubscription", + "endpointUrlStem": "/subscriptions/{{{inputs.subscriptionId}}}/providers/Microsoft.ContainerRegistry/registries?api-version=2017-03-01", + "httpMethod": null, + "requestBody": null, + "resultSelector": "$.value.[?(@.type === 'Microsoft.ContainerRegistry/registries')]", + "resultTemplate": "{\"Value\":\"{{{id}}}\",\"DisplayValue\":\"{{{name}}}\"}" + }, + { + "id": "fetchContainerRegistryLocations", + "endpointUrlStem": "/subscriptions/{{{inputs.subscriptionId}}}/providers/Microsoft.ContainerRegistry?api-version=2016-09-01", + "httpMethod": null, + "requestBody": null, + "resultSelector": "$.resourceTypes[?(@.resourceType === 'locations')].locations", + "resultTemplate": null + }, + { + "id": "checkContainerRegistryAvailability", + "endpointUrlStem": "subscriptions/{{{inputs.subscriptionId}}}/providers/Microsoft.ContainerRegistry/checkNameAvailability?api-version=2017-10-01", + "httpMethod": "POST", + "requestBody": "{\"name\":\"{{{inputs.containerRegistryName}}}\",\"type\":\"Microsoft.ContainerRegistry/registries\"}", + "resultSelector": null, + "resultTemplate": "{\"value\":\"{{{nameAvailable}}}\",\"message\":\"{{{message}}}\"}" + }, + { + "id": "getContainerRegistryResourceGroupLocation", + "endpointUrlStem": "/subscriptions/{{{inputs.subscriptionId}}}/resourceGroups/{{#parseAzureResourceId}}{{{inputs.existingContainerRegistryId}}} 4{{/parseAzureResourceId}}?api-version=2018-05-01", + "httpMethod": null, + "requestBody": null, + "resultSelector": "$.location", + "resultTemplate": null + }, + { + "id": "checkDreamSparkQuotaId", + "endpointUrlStem": "subscriptions/{{{inputs.subscriptionId}}}?api-version=2014-04-01", + "httpMethod": "GET", + "requestBody": null, + "resultSelector": "$.subscriptionPolicies", + "resultTemplate": "{\"value\":\"{{#equals}}{{{quotaId}}} 'DreamSpark_2015-02-01' true false true{{/equals}}\"}" + } + ], + "inputs": [ + { + "name": "Subscription", + "groupId": "cdResource", + "isRequired": true, + "sublabel": null, + "properties": { + "resourceProviders": "Microsoft.ContainerService;Microsoft.ContainerRegistry;Microsoft.Resources;Microsoft.Insights;Microsoft.OperationalInsights;Microsoft.OperationsManagement;Microsoft.Compute;Microsoft.Network;Microsoft.Storage;" + }, + "inputMode": 30, + "dataSourceId": null, + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [ + { + "dataSourceId": "checkDreamSparkQuotaId", + "resultTemplate": null, + "errorMessage": "The resource providers 'Microsoft.Storage' and 'Microsoft.ContainerRegistry' do not support DreamSpark subscriptions. Either select a different subscription or select a scenario where all the resource providers support DreamSpark subscriptions." + } + ], + "visibleRule": null, + "id": "subscriptionId", + "description": "Id of subscription where AKS cluster is present.", + "type": 0, + "possibleValues": [] + }, + { + "name": "Cluster name", + "groupId": "cdResource", + "isRequired": true, + "sublabel": null, + "properties": { + "deployTarget": "true" + }, + "inputMode": 80, + "dataSourceId": "listExistingAKS", + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": null, + "id": "clusterId", + "description": "The name of the Azure Kubernetes Service cluster", + "type": "string", + "possibleValues": [] + }, + { + "name": "Resource group", + "groupId": "cdResource", + "isRequired": true, + "sublabel": null, + "properties": {}, + "inputMode": 10, + "dataSourceId": null, + "defaultValue": "{{#parseAzureResourceId}}{{{inputs.clusterId}}} 4{{/parseAzureResourceId}}", + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": "clusterId == empty", + "id": "resourceGroup", + "description": "Name of the resource group where AKS cluster is present.", + "type": "string", + "possibleValues": [] + }, + { + "name": "HTTP application routing domain", + "groupId": "cdResource", + "isRequired": false, + "sublabel": null, + "properties": {}, + "inputMode": 0, + "dataSourceId": "httpApplicationRoutingDomain", + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": null, + "id": "httpApplicationRoutingDomain", + "description": "The HTTP application routing domain of Azure Kubernetes Service cluster", + "type": "string", + "possibleValues": [] + }, + { + "name": "kubernetes Version", + "groupId": "cdResource", + "isRequired": false, + "sublabel": null, + "properties": {}, + "inputMode": 0, + "dataSourceId": "kubernetesVersion", + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": null, + "id": "kubernetesVersion", + "description": "The kubernetes version present in Azure Kubernetes Service cluster", + "type": 0, + "possibleValues": [] + }, + { + "name": "Location", + "groupId": "cdResource", + "isRequired": true, + "sublabel": null, + "properties": {}, + "inputMode": 10, + "dataSourceId": "getResourceGroupLocation", + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": "clusterId == empty", + "id": "location", + "description": "Choose the Azure region that's right for you and your customers.", + "type": "string", + "possibleValues": [] + }, + { + "name": "Container Registry Selection", + "groupId": "containerRegistry", + "isRequired": true, + "sublabel": null, + "properties": {}, + "inputMode": 80, + "dataSourceId": null, + "defaultValue": "true", + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": null, + "id": "reuseACR", + "description": null, + "type": 0, + "possibleValues": [] + }, + { + "name": "Container Registry Name", + "groupId": "containerRegistry", + "isRequired": true, + "sublabel": null, + "properties": {}, + "inputMode": 30, + "dataSourceId": "fetchExistingContainerRegistriesInSubscription", + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": "reuseACR == true", + "id": "existingContainerRegistryId", + "description": null, + "type": 0, + "possibleValues": [] + }, + { + "name": "ACR Resource group", + "groupId": "containerRegistry", + "isRequired": true, + "sublabel": null, + "properties": {}, + "inputMode": 10, + "dataSourceId": null, + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": "reuseACR == false", + "id": "acrResourceGroup", + "description": "Name of the resource group where Azure Container registry is present.", + "type": "string", + "possibleValues": [] + }, + { + "name": "Container Registry Resource Group Location", + "groupId": "containerRegistry", + "isRequired": false, + "sublabel": null, + "properties": {}, + "inputMode": 10, + "dataSourceId": "getContainerRegistryResourceGroupLocation", + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": "reuseACR == invalid", + "id": "existingContainerRegistryResourceGroupLocation", + "description": null, + "type": 0, + "possibleValues": [] + }, + { + "name": "Container Registry Name", + "groupId": "containerRegistry", + "isRequired": true, + "sublabel": null, + "properties": {}, + "inputMode": 10, + "dataSourceId": null, + "defaultValue": "{{#parseAzureResourceId}}{{{inputs.clusterId}}} 6{{/parseAzureResourceId}}", + "staticValidation": { + "pattern": "[a-zA-Z0-9]*", + "regexFlags": null, + "errorMessage": "Resource names may contain alpha numeric characters only and must be between 5 and 50 characters.", + "minLength": 5, + "maxLength": 50 + }, + "dynamicValidations": [ + { + "dataSourceId": "checkContainerRegistryAvailability", + "resultTemplate": null, + "errorMessage": "Registry with this name already exists." + } + ], + "visibleRule": "reuseACR == false", + "id": "containerRegistryName", + "description": null, + "type": 0, + "possibleValues": [] + }, + { + "name": "Container Registry SKU", + "groupId": "containerRegistry", + "isRequired": true, + "sublabel": null, + "properties": {}, + "inputMode": 30, + "dataSourceId": null, + "defaultValue": "Standard", + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": "reuseACR == false", + "id": "containerRegistrySKU", + "description": "Azure Container Registry is a private Docker registry for hosting container images. All SKUs provide the same programmatic capabilities. Choosing a higher SKU will provide more performance and scale. More info on pricing and capabilities.", + "type": 0, + "possibleValues": [ + { + "value": "Basic", + "displayValue": "Basic" + }, + { + "value": "Standard", + "displayValue": "Standard" + }, + { + "value": "Premium", + "displayValue": "Premium" + } + ] + }, + { + "name": "Container Registry Location", + "groupId": "containerRegistry", + "isRequired": true, + "sublabel": null, + "properties": {}, + "inputMode": 30, + "dataSourceId": "fetchContainerRegistryLocations", + "defaultValue": "South Central US", + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": "reuseACR == false", + "id": "containerRegistryLocation", + "description": null, + "type": 0, + "possibleValues": [] + }, + { + "name": null, + "groupId": null, + "isRequired": false, + "sublabel": null, + "properties": { + "scope": [ + "{{#equals}}{{{inputs.reuseACR}}} false true '/subscriptions/{{{inputs.subscriptionId}}}/resourceGroups/{{{inputs.acrResourceGroup}}}'{{/equals}}{{#equals}}{{{inputs.reuseACR}}} true true '{{{inputs.existingContainerRegistryId}}}'{{/equals}}" + ], + "location": [ + "{{inputs.location}}", + "{{#equals}}{{{inputs.reuseACR}}} true true '{{{inputs.existingContainerRegistryResourceGroupLocation}}}' {{/equals}}" + ] + }, + "inputMode": 0, + "dataSourceId": null, + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": null, + "id": "azureAuth", + "description": "Authorization for Azure ARM endpoints.", + "type": 4, + "possibleValues": [] + }, + { + "name": null, + "groupId": null, + "isRequired": false, + "sublabel": null, + "properties": {}, + "inputMode": 0, + "dataSourceId": null, + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": null, + "id": "azureDevOpsAuth", + "description": "Azure DevOps authorization", + "type": 4, + "possibleValues": [] + }, + { + "name": "Dockerfile path", + "groupId": "dockerInputs", + "isRequired": true, + "sublabel": null, + "properties": { + + }, + "inputMode": 10, + "dataSourceId": null, + "defaultValue": null, + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": null, + "id": "dockerFilePath", + "description": "The path to the Dockerfile used for building the container image. Minimatch patterns are supported, for example: **/Dockerfile. The complete path from the repository root to the Dockerfile can also be used. For example: Fabrikam/WebApp/Dockerfile.", + "type": 0, + "possibleValues": [] + }, + { + "name": "PORT", + "groupId": "dockerInputs", + "isRequired": false, + "sublabel": null, + "properties": { + + }, + "inputMode": 10, + "dataSourceId": null, + "defaultValue": "", + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": null, + "id": "containerPort", + "description": "Specify port to expose in container.", + "type": 0, + "possibleValues": [] + }, + { + "name": "Docker build context", + "groupId": "dockerInputs", + "isRequired": false, + "sublabel": null, + "properties": {}, + "inputMode": 10, + "dataSourceId": null, + "defaultValue": "", + "staticValidation": null, + "dynamicValidations": [], + "visibleRule": null, + "id": "dockerContext", + "description": "Specify the source directory path which will be used for building container.", + "type": "string", + "possibleValues": [] + } + ], + "id": "ms.vss-continuous-delivery-pipeline-templates.aks-cd-with-dockerfile-github", + "description": "i18n:Template for configuring github workflow on an AKS cluster using dockerfile", + "attributes": { + "language": "Docker", + "buildTarget": "Dockerfile", + "deployTarget": "Azure:AKS", + "serviceId": "ms.vss-continuous-delivery-pipeline-templates.service-type-aks", + "templateType": "continuous-delivery", + "pipelineType": "github", + "codeRepositoryType": "BYOC" + } + }; + + return extendedPipelineTemplate2 || extendedPipelineTemplate; } } \ No newline at end of file diff --git a/src/configure/configure.ts b/src/configure/configure.ts index a1bdead9..6fffd72c 100644 --- a/src/configure/configure.ts +++ b/src/configure/configure.ts @@ -13,6 +13,7 @@ import { AzureDevOpsHelper } from './helper/devOps/azureDevOpsHelper'; import { GitHubProvider } from './helper/gitHubHelper'; import { LocalGitRepoHelper } from './helper/LocalGitRepoHelper'; import { RepoAnalysisHelper } from './helper/repoAnalysisHelper'; +//import { RepoAnalysisHelper } from './helper/repoAnalysisHelper'; import { Result, telemetryHelper } from './helper/telemetryHelper'; import * as templateHelper from './helper/templateHelper'; import { TemplateParameterHelper } from './helper/templateParameterHelper'; @@ -22,11 +23,9 @@ import * as constants from './resources/constants'; import { Messages } from './resources/messages'; import { TelemetryKeys } from './resources/telemetryKeys'; import { TracePoints } from './resources/tracePoints'; -import { InputControlProvider as InputControlProvider } from './templateInputHelper/InputControlProvider'; +import { InputControlProvider as InputControlProvider } from './utilities/InputControlProvider'; -const uuid = require('uuid/v4'); const Layer: string = 'configure'; - export let UniqueResourceNameSuffix: string = uuid().substr(0, 5); export async function configurePipeline(node: AzureTreeItem) { @@ -91,8 +90,6 @@ class Orchestrator { if (this.continueOrchestration) { let pipelineConfigurer = ConfigurerFactory.GetConfigurer(this.inputs.sourceRepository, this.inputs.azureSession, this.inputs.subscriptionId); - let selectedCICDProvider = (pipelineConfigurer.constructor.name === "GitHubWorkflowConfigurer") ? constants.githubWorkflow : constants.azurePipeline; - telemetryHelper.setTelemetry(TelemetryKeys.SelectedCICDProvider, selectedCICDProvider); await pipelineConfigurer.getInputs(this.inputs); telemetryHelper.setCurrentStep('CreatePreRequisites'); @@ -126,11 +123,12 @@ class Orchestrator { if (this.inputs.pipelineConfiguration.templateInfo) { - let extendedPipelineTemplate = await templateHelper.getTemplateParameteres(this.inputs.azureSession, this.inputs.pipelineConfiguration.templateInfo); - let context: { [key: string]: any } = {}; - context['subscriptionId'] = this.inputs.subscriptionId; - let controlProvider = new InputControlProvider(extendedPipelineTemplate, context); - this.inputs.pipelineConfiguration.parameters = await controlProvider.getAllPipelineTemplateInputs(this.inputs.azureSession); + //this.inputs.pipelineConfiguration.template.extendedPipelineTemplate = + let extendedPipelineTemplate = await templateHelper.getTemplateParameteres(this.inputs.pipelineConfiguration.templateInfo); + let inputs: { [key: string]: any } = {}; + inputs['subscriptionId'] = this.inputs.subscriptionId; + let controlProvider = new InputControlProvider(extendedPipelineTemplate, inputs); + this.inputs.pipelineConfiguration.parameters = await controlProvider.getAllInputUxDescriptors(this.inputs.azureSession, resourceNode); } else { if (this.inputs.pipelineConfiguration.template.label === "Containerized application to AKS") { @@ -274,7 +272,6 @@ class Orchestrator { } // set telemetry telemetryHelper.setTelemetry(TelemetryKeys.RepoProvider, this.inputs.sourceRepository.repositoryProvider); - telemetryHelper.setTelemetry(TelemetryKeys.RepoId, this.inputs.sourceRepository.repositoryId); } private setDefaultRepositoryDetails(): void { @@ -391,8 +388,6 @@ class Orchestrator { let selectedSubscription: QuickPickItemWithData = await this.controlProvider.showQuickPick(constants.SelectSubscription, subscriptionList, { placeHolder: Messages.selectSubscription }, TelemetryKeys.SubscriptionListCount); this.inputs.subscriptionId = selectedSubscription.data.subscription.subscriptionId; this.inputs.azureSession = getSubscriptionSession(this.inputs.subscriptionId); - - telemetryHelper.setTelemetry(TelemetryKeys.SubscriptionId, this.inputs.subscriptionId); } private async getAzureResourceDetails(): Promise { @@ -431,17 +426,17 @@ class Orchestrator { var repoAnalysisResult = await repoAnalysisHelper.getRepositoryAnalysis(this.inputs.sourceRepository, this.inputs.pipelineConfiguration.workingDirectory.split('/').join('\\')); - extensionVariables.templateServiceEnabled = true; + extensionVariables.templateServiceEnabled = false; let appropriatePipelines; // TO:DO- Get applicable pipelines for the repo type and azure target type if target already selected if (extensionVariables.templateServiceEnabled) { repoAnalysisResult = null; + appropriatePipelines = await vscode.window.withProgress( { location: vscode.ProgressLocation.Notification, title: Messages.analyzingRepo }, () => templateHelper.analyzeRepoAndListAppropriatePipeline2( - this.inputs.azureSession, this.inputs.sourceRepository.localPath, this.inputs.sourceRepository.repositoryProvider, repoAnalysisResult, @@ -510,12 +505,12 @@ class Orchestrator { return applicationSetting.language === this.inputs.pipelineConfiguration.template.language; }); - if (!applicationSettings || applicationSettings.length === 0) { + if (!applicationSettings || applicationSettings.length == 0) { return; } let workspacePaths = Array.from(new Set(applicationSettings.map(a => a.settings.workingDirectory))); - if (workspacePaths.length === 1) { + if (workspacePaths.length == 1) { this.inputs.repositoryAnalysisApplicationSettings = applicationSettings[0]; this.inputs.pipelineConfiguration.workingDirectory = applicationSettings[0].settings.workingDirectory; return; @@ -565,7 +560,6 @@ class Orchestrator { await templateHelper.renderContent(this.inputs.pipelineConfiguration.template.path, mustacheContext), this.inputs.pipelineConfiguration.filePath); await vscode.window.showTextDocument(vscode.Uri.file(this.inputs.pipelineConfiguration.filePath)); - telemetryHelper.setTelemetry(TelemetryKeys.DisplayWorkflow, 'true'); } catch (error) { telemetryHelper.logError(Layer, TracePoints.AddingContentToPipelineFileFailed, error); diff --git a/src/configure/templateInputHelper/InputControl.ts b/src/configure/templateInputHelper/InputControl.ts index cb68b38c..b77d6c2d 100644 --- a/src/configure/templateInputHelper/InputControl.ts +++ b/src/configure/templateInputHelper/InputControl.ts @@ -1,8 +1,9 @@ import { InputBoxOptions, QuickPickItem } from 'vscode'; import { IAzureQuickPickOptions } from 'vscode-azureextensionui'; +import { MustacheHelper } from '../helper/mustacheHelper'; import { telemetryHelper } from '../helper/telemetryHelper'; import { ExtendedInputDescriptor, InputMode } from "../model/Contracts"; -import { AzureSession, ControlType, extensionVariables } from '../model/models'; +import { AzureSession, ControlType, extensionVariables, StringMap } from '../model/models'; import { Messages } from '../resources/messages'; import { TelemetryKeys } from '../resources/telemetryKeys'; import { DataSourceExpression } from './utilities/DataSourceExpression'; @@ -103,6 +104,21 @@ export class InputControl { } } + public getPropertyValue(propertyName: string, inputs?: StringMap): string { + var properties = this.inputDescriptor.properties; + var value: string; + + if (!!properties) { + value = properties[propertyName]; + if (!!value && !!inputs && typeof value === "string") { + return MustacheHelper.render(value, { inputs: inputs }); + } else if (!!value && !!inputs) { + return MustacheHelper.renderObject(value, { inputs: inputs }); + } + } + return value; + } + private _getDataSourceInputs(): { [key: string]: any } { var inputs: { [key: string]: any } = {}; for (var dataSourceInput of this.dataSourceInputControls) { diff --git a/src/configure/templateInputHelper/InputControlProvider.ts b/src/configure/templateInputHelper/InputControlProvider.ts index eef8766b..f1f24af6 100644 --- a/src/configure/templateInputHelper/InputControlProvider.ts +++ b/src/configure/templateInputHelper/InputControlProvider.ts @@ -1,3 +1,4 @@ +import { GenericResource } from "azure-arm-resource/lib/resource/models"; import { MustacheHelper } from "../helper/mustacheHelper"; import { ExtendedInputDescriptor, ExtendedPipelineTemplate, InputDataType, InputMode } from "../model/Contracts"; import { AzureSession, ControlType, IPredicate, StringMap } from '../model/models'; @@ -16,12 +17,17 @@ export class InputControlProvider { this._createControls(context); } - public async getAllPipelineTemplateInputs(azureSession: AzureSession) { + public async getAllPipelineTemplateInputs(azureSession: AzureSession, resourceNode?: GenericResource) { let parameters: { [key: string]: any } = {}; for (let inputControl of this._inputControlsMap.values()) { - this._setInputControlVisibility(inputControl); - this._setupInputControlDefaultValue(inputControl); - await inputControl.setInputControlValue(azureSession); + if (inputControl.getPropertyValue('deployTarget') === "true" && !!resourceNode) { + inputControl.setValue(resourceNode.id); + } + else { + this._setInputControlVisibility(inputControl); + this._setupInputControlDefaultValue(inputControl); + await inputControl.setInputControlValue(azureSession); + } parameters[inputControl.getInputControlId()] = inputControl.getValue(); } return parameters;