Skip to content
This repository was archived by the owner on May 2, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/configure/clients/github/TemplateServiceClient.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,9 +12,17 @@ export class TemplateServiceClient {

public async getTemplates(body: RepositoryAnalysisParameters): Promise<PipelineTemplateMetadata[]> {
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<PipelineTemplateNew> {
return this.restClient.sendRequest2(
'https://tswithouthmac.azurewebsites.net/Templates/' + templateId + '/parameters',
'GET',
'2019-05-01',
null);
}
}
13 changes: 12 additions & 1 deletion src/configure/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<void> {
let resourceNode = await this.analyzeNode(node);

Expand All @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions src/configure/helper/templateHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ 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';
import { TracePoints } from '../resources/tracePoints';
import { MustacheHelper } from './mustacheHelper';
import { telemetryHelper } from './telemetryHelper';

export async function getTemplate(templateId: string): Promise<PipelineTemplateNew> {

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<AnalysisResult> {
let localRepoAnalysisResult = await analyzeRepo(repoPath);
let analysisResult = localRepoAnalysisResult;
Expand Down
9 changes: 9 additions & 0 deletions src/configure/model/DataSource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface DataSource {

Id: string;
EndpointUrlStem: string;
HttpMethod: string;
RequestBody: string;
ResultSelector: string;
ResultTemplate: string;
}
42 changes: 42 additions & 0 deletions src/configure/model/InputDescriptor.ts
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 6 additions & 0 deletions src/configure/model/InputGroup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface InputGroup {

id: string;
name: string;
properties: { key: string, value: any }[];
}
11 changes: 11 additions & 0 deletions src/configure/model/PipelineTemplateNew.ts
Original file line number Diff line number Diff line change
@@ -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 }[];
}
2 changes: 2 additions & 0 deletions src/configure/model/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -83,6 +84,7 @@ export class AzureSession {
export class PipelineConfiguration {
filePath: string;
template: PipelineTemplate;
templateNew: PipelineTemplateNew;
templateInfo: PipelineTemplateMetadata;
workingDirectory: string;
params: { [key: string]: any } = {};
Expand Down