Skip to content

Commit

Permalink
feat(bake/manifest): bake manifest stage config (#5128)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander committed Apr 10, 2018
1 parent 3d37206 commit 2a908d1
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/scripts/modules/core/src/help/help.contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ module(HELP_CONTENTS, [])
<p>The selected value can be used in a subsequent <strong>Check Preconditions</strong> stage to determine branching.</p>
<p>For example, if the user selects "rollback" from this list of options, that branch can be activated by using the expression:
<samp class="small">execution.stages[n].context.judgmentInput=="rollback"</samp></p>`,
'pipeline.config.bake.manifest.expectedArtifact': '<p>This is the template you want to render.</p>',
'pipeline.config.haltPipelineOnFailure': 'Immediately halts execution of all running stages and fails the entire execution.',
'pipeline.config.haltBranchOnFailure': 'Prevents any stages that depend on this stage from running, but allows other branches of the pipeline to run.',
'pipeline.config.haltBranchOnFailureFailPipeline': 'Prevents any stages that depend on this stage from running, but allows other branches of the pipeline to run. The pipeline will be marked as failed once complete.',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { IController, IScope } from 'angular';

import { AccountService, ExpectedArtifactService, IAccount, IExpectedArtifact } from 'core';

export class BakeManifestConfigCtrl implements IController {
public expectedArtifacts: IExpectedArtifact[];
public artifactAccounts: IAccount[];
public templateRenderers = ['HELM2'];

constructor(public $scope: IScope,
accountService: AccountService,
expectedArtifactService: ExpectedArtifactService ) {
'ngInject';
if (this.$scope.stage.isNew) {
const defaultSelection = {
templateRenderer: 'HELM2',
expectedArtifacts: [{
matchArtifact: {
type: 'embedded/base64',
name: ''
}
}]
};

Object.assign(this.$scope.stage, defaultSelection);
}

accountService.getArtifactAccounts().then(accounts => {
this.artifactAccounts = accounts;
});

this.expectedArtifacts = expectedArtifactService.getExpectedArtifactsAvailableToStage(this.$scope.stage, this.$scope.$parent.pipeline);
}

public outputNameChange() {
const expectedArtifacts = this.$scope.stage.expectedArtifacts;
if (expectedArtifacts
&& expectedArtifacts.length === 1
&& expectedArtifacts[0].matchArtifact
&& expectedArtifacts[0].matchArtifact.type === 'embedded/base64') {
expectedArtifacts[0].matchArtifact.name = this.$scope.stage.outputName;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<div class="form-horizontal" xmlns="http://www.w3.org/1999/html">
<div class="alert alert-warning">
<strong>Warning!</strong> This stage is under active development and is subject to change.
</div>
<h4>Template Renderer</h4>
<div class="form-group">
<div class="col-md-3 sm-label-right">
Render Engine
<help-field key="pipeline.config.bake.manifest.templateRenderer"></help-field>
</div>
<div class="col-md-3">
<select class="form-control input-sm"
ng-model="ctrl.$scope.stage.templateRenderer">
<option ng-repeat="renderer in ctrl.templateRenderers"
value="{{renderer}}"
ng-selected="ctrl.$scope.stage.templateRenderer === renderer">{{renderer}}</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-3 sm-label-right">
Name
</div>
<div class="col-md-3">
<input type="text" class="form-control input-sm"
ng-model="ctrl.$scope.stage.outputName"
ng-change="ctrl.outputNameChange()">
</input>
</div>
</div>

<h4>Template Artifact</h4>
<expected-artifact-selector command="ctrl.$scope.stage"
id-field="expectedArtifactId"
account-field="expectedArtifactAccount"
accounts="ctrl.artifactAccounts"
expected-artifacts="ctrl.expectedArtifacts"
help-field-key="pipeline.config.bake.manifest.expectedArtifact">
</expected-artifact-selector>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { module } from 'angular';

import {
ArtifactReferenceServiceProvider,
PIPELINE_CONFIG_PROVIDER,
PipelineConfigProvider,
SETTINGS
} from 'core';

import { BakeManifestConfigCtrl } from './bakeManifestConfig.controller';

export const BAKE_MANIFEST_STAGE = 'spinnaker.core.pipeline.stage.bakeManifestStage';

module(BAKE_MANIFEST_STAGE, [
PIPELINE_CONFIG_PROVIDER,
]).config((pipelineConfigProvider: PipelineConfigProvider, artifactReferenceServiceProvider: ArtifactReferenceServiceProvider) => {
if (SETTINGS.feature.versionedProviders) {
pipelineConfigProvider.registerStage({
label: 'Bake (Manifest)',
description: 'Bake a manifest (or multi-doc manifest set) using a template renderer such as Helm.',
key: 'bakeManifest',
templateUrl: require('./bakeManifestConfig.html'),
controller: 'BakeManifestConfigCtrl',
producesArtifacts: true,
cloudProvider: 'kubernetes',
controllerAs: 'ctrl',
});

artifactReferenceServiceProvider.registerReference('stage', () => [
['expectedArtifactId'],
]);
}
}).controller('BakeManifestConfigCtrl', BakeManifestConfigCtrl);
2 changes: 2 additions & 0 deletions app/scripts/modules/core/src/pipeline/pipeline.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { module } from 'angular';

import { APPLY_SOURCE_SERVER_GROUP_CAPACITY_STAGE } from './config/stages/applySourceServerGroupCapacity/applySourceServerGroupCapacityStage.module';
import { BAKE_MANIFEST_STAGE } from './config/stages/bakeManifest/bakeManifestStage'
import { CHECK_PRECONDITIONS_STAGE_MODULE } from './config/stages/checkPreconditions/checkPreconditionsStage.module';
import { CLONE_SERVER_GROUP_STAGE } from './config/stages/cloneServerGroup/cloneServerGroupStage.module';
import { COPY_STAGE_MODAL_CONTROLLER } from './config/copyStage/copyStage.modal.controller';
Expand Down Expand Up @@ -62,6 +63,7 @@ module(PIPELINE_MODULE, [
WEBHOOK_STAGE_MODULE,
UNMATCHED_STAGE_TYPE_STAGE,
require('./config/stages/bake/bakeStage.module').name,
BAKE_MANIFEST_STAGE,
CHECK_PRECONDITIONS_STAGE_MODULE,
CLONE_SERVER_GROUP_STAGE,
STAGE_CORE_MODULE,
Expand Down

0 comments on commit 2a908d1

Please sign in to comment.