diff --git a/src/configure/clients/github/TemplateServiceClient.ts b/src/configure/clients/github/TemplateServiceClient.ts index ae9d3bda..49eab16d 100644 --- a/src/configure/clients/github/TemplateServiceClient.ts +++ b/src/configure/clients/github/TemplateServiceClient.ts @@ -1,6 +1,7 @@ import { RepositoryAnalysisParameters } from "../../model/models"; import { PipelineTemplateMetadata } from "../../model/templateModels"; import { RestClient } from "../restClient"; +import { PipelineTemplateNew } from "../../model/PipelineTemplateNew"; export class TemplateServiceClient { private restClient: RestClient; @@ -11,9 +12,17 @@ export class TemplateServiceClient { public async getTemplates(body: RepositoryAnalysisParameters): Promise { return this.restClient.sendRequest2( - 'https://ts21.azurewebsites.net/Templates', + 'https://tswithouthmac.azurewebsites.net/Templates', 'POST', '2019-05-01', body); } + + public async getTemplateById(templateId: string): Promise { + return this.restClient.sendRequest2( + 'https://tswithouthmac.azurewebsites.net/Templates/' + templateId + '/parameters', + 'GET', + '2019-05-01', + null); + } } \ No newline at end of file diff --git a/src/configure/configure.ts b/src/configure/configure.ts index 71e73d0e..acfabef8 100644 --- a/src/configure/configure.ts +++ b/src/configure/configure.ts @@ -18,7 +18,7 @@ import { Result, telemetryHelper } from './helper/telemetryHelper'; import * as templateHelper from './helper/templateHelper'; import { TemplateParameterHelper } from './helper/templateParameterHelper'; import { extensionVariables, GitBranchDetails, GitRepositoryParameters, MustacheContext, ParsedAzureResourceId, QuickPickItemWithData, RepositoryAnalysisApplicationSettings, RepositoryProvider, SourceOptions, TargetKind, TargetResourceType, WizardInputs } from './model/models'; -import { TemplateAssetType } from './model/templateModels'; +import { PipelineTemplateMetadata, TemplateAssetType } from './model/templateModels'; import * as constants from './resources/constants'; import { Messages } from './resources/messages'; import { TelemetryKeys } from './resources/telemetryKeys'; @@ -112,6 +112,12 @@ class Orchestrator { } } + private async processingTemplate(template: PipelineTemplateMetadata) { + + //getting the template + this.inputs.pipelineConfiguration.templateNew = await templateHelper.getTemplate(template.templateId); + } + private async getInputs(node: any): Promise { let resourceNode = await this.analyzeNode(node); @@ -120,6 +126,11 @@ class Orchestrator { await this.getAzureSession(); await this.getSelectedPipeline(); + //process the template + if (extensionVariables.templateServiceEnabled) { + await this.processingTemplate(this.inputs.pipelineConfiguration.templateInfo); + } + if (this.inputs.pipelineConfiguration.template.label === "Containerized application to AKS") { // try to see if node corresponds to any parameter of selected pipeline. if (resourceNode) { diff --git a/src/configure/helper/templateHelper.ts b/src/configure/helper/templateHelper.ts index 63b1794d..c0df2494 100644 --- a/src/configure/helper/templateHelper.ts +++ b/src/configure/helper/templateHelper.ts @@ -5,6 +5,7 @@ import * as path from 'path'; import * as Q from 'q'; import { TemplateServiceClient } from '../clients/github/TemplateServiceClient'; import { AzureConnectionType, extensionVariables, MustacheContext, RepositoryAnalysisParameters, RepositoryProvider, SupportedLanguage, TargetKind, TargetResourceType } from '../model/models'; +import { PipelineTemplateNew } from '../model/PipelineTemplateNew'; import { PipelineTemplate, PipelineTemplateMetadata, PreDefinedDataSourceIds, TemplateAssetType, TemplateParameterType } from '../model/templateModels'; import { PipelineTemplateLabels, RepoAnalysisConstants } from '../resources/constants'; import { Messages } from '../resources/messages'; @@ -12,6 +13,14 @@ import { TracePoints } from '../resources/tracePoints'; import { MustacheHelper } from './mustacheHelper'; import { telemetryHelper } from './telemetryHelper'; +export async function getTemplate(templateId: string): Promise { + + let serviceClient = new TemplateServiceClient(); + let template: PipelineTemplateNew; + template = await serviceClient.getTemplateById(templateId); + return template; +} + export async function mergingRepoAnalysisResults(repoPath: string, repositoryProvider: RepositoryProvider, repoAnalysisParameters: RepositoryAnalysisParameters): Promise { let localRepoAnalysisResult = await analyzeRepo(repoPath); let analysisResult = localRepoAnalysisResult; diff --git a/src/configure/model/DataSource.ts b/src/configure/model/DataSource.ts new file mode 100644 index 00000000..fee840c5 --- /dev/null +++ b/src/configure/model/DataSource.ts @@ -0,0 +1,9 @@ +export interface DataSource { + + Id: string; + EndpointUrlStem: string; + HttpMethod: string; + RequestBody: string; + ResultSelector: string; + ResultTemplate: string; +} \ No newline at end of file diff --git a/src/configure/model/InputDescriptor.ts b/src/configure/model/InputDescriptor.ts new file mode 100644 index 00000000..f2f773c9 --- /dev/null +++ b/src/configure/model/InputDescriptor.ts @@ -0,0 +1,42 @@ +export enum InputMode { + + None = 0, + TextBox = 10, + PasswordBox = 20, + Combo = 30, + CheckBox = 40, + AzureSubscription = 50, + TenantId = 60, + AadAccessToken = 70, + RadioButtons = 80, + VirtualMachineSizeControl = 90 +} + +export enum InputDataType { + + String = 0, + SecureString = 1, + Int = 2, + Bool = 3, + Authorization = 4 +} + +export interface InputDescriptor { + + name: string; + groupId: string; + isRequired: boolean; + sublabel: string; + properties: { key: string, value: any }[]; + inputMode: InputMode; + dataSourceId: string; + defaultValue: string; + staticValidation: { key: string, value: any }[]; + dynamicValidations: { key: string, value: any }[]; + visibleRule: string; + id: string; + description: string; + type: InputDataType; + possibleValues: { key: string, value: any }[]; + value: any; +} \ No newline at end of file diff --git a/src/configure/model/InputGroup.ts b/src/configure/model/InputGroup.ts new file mode 100644 index 00000000..f04723fa --- /dev/null +++ b/src/configure/model/InputGroup.ts @@ -0,0 +1,6 @@ +export interface InputGroup { + + id: string; + name: string; + properties: { key: string, value: any }[]; +} \ No newline at end of file diff --git a/src/configure/model/PipelineTemplateNew.ts b/src/configure/model/PipelineTemplateNew.ts new file mode 100644 index 00000000..8704c851 --- /dev/null +++ b/src/configure/model/PipelineTemplateNew.ts @@ -0,0 +1,11 @@ +import { DataSource } from "./DataSource"; +import { InputDescriptor } from "./InputDescriptor"; +import { InputGroup } from "./InputGroup"; + +export class PipelineTemplateNew { + + groups: InputGroup[]; + dataSources: DataSource[]; + inputs: InputDescriptor[]; + attributes: { key: string, value: any }[]; +} \ No newline at end of file diff --git a/src/configure/model/models.ts b/src/configure/model/models.ts index 0f75de44..26eaaae6 100644 --- a/src/configure/model/models.ts +++ b/src/configure/model/models.ts @@ -5,6 +5,7 @@ import { AzureEnvironment } from 'ms-rest-azure'; import { ExtensionContext, OutputChannel, QuickPickItem, workspace } from 'vscode'; import { IAzureUserInput, ITelemetryReporter, UIExtensionVariables } from 'vscode-azureextensionui'; import { Messages } from '../resources/messages'; +import { PipelineTemplateNew } from './PipelineTemplateNew'; import { PipelineTemplate, PipelineTemplateMetadata } from './templateModels'; class ExtensionVariables implements UIExtensionVariables { @@ -83,6 +84,7 @@ export class AzureSession { export class PipelineConfiguration { filePath: string; template: PipelineTemplate; + templateNew: PipelineTemplateNew; templateInfo: PipelineTemplateMetadata; workingDirectory: string; params: { [key: string]: any } = {};