-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pipeline): Add pipeline config section for artifacts. (#4118)
Adds a section to pipeline config for declaring expected artifacts from trigger sources, and adds support in pub/sub triggers to select artifacts the trigger can produce.
- Loading branch information
Showing
14 changed files
with
196 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface IExpectedArtifact { | ||
name: string; | ||
type: string; | ||
missingPolicy: MissingArtifactPolicy; | ||
} | ||
|
||
export enum MissingArtifactPolicy { | ||
FailPipeline = 'FailPipeline', | ||
Ignore = 'Ignore' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { IComponentController, IComponentOptions, module } from 'angular'; | ||
|
||
import { PIPELINE_CONFIG_PROVIDER } from 'core/pipeline/config/pipelineConfigProvider'; | ||
import { IExpectedArtifact, MissingArtifactPolicy } from 'core/domain/IExpectedArtifact'; | ||
import { IPipeline } from 'core/domain/IPipeline'; | ||
|
||
class ArtifactController implements IComponentController { | ||
public artifact: IExpectedArtifact; | ||
public pipeline: IPipeline; | ||
public missingPolicies: string[] = Object.keys(MissingArtifactPolicy).map(key => MissingArtifactPolicy[key as any]); | ||
|
||
public removeArtifact(): void { | ||
const artifactIndex = this.pipeline.expectedArtifacts.indexOf(this.artifact); | ||
this.pipeline.expectedArtifacts.splice(artifactIndex, 1); | ||
|
||
this.pipeline.triggers | ||
.forEach(t => t.expectedArtifacts = t.expectedArtifacts.filter(a => !this.isEqual(a, this.artifact))); | ||
} | ||
|
||
private isEqual(first: IExpectedArtifact, other: IExpectedArtifact): boolean { | ||
return first.name === other.name | ||
&& first.type === other.type; | ||
} | ||
} | ||
|
||
class ArtifactComponent implements IComponentOptions { | ||
public bindings = { artifact: '<', pipeline: '<' }; | ||
public templateUrl = require('./artifact.html'); | ||
public controller = ArtifactController; | ||
} | ||
|
||
export const ARTIFACT = 'spinnaker.core.pipeline.trigger.artifact'; | ||
module(ARTIFACT, [ | ||
PIPELINE_CONFIG_PROVIDER, | ||
]).component('artifact', new ArtifactComponent()); |
65 changes: 65 additions & 0 deletions
65
app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="form-horizontal panel-pipeline-phase"> | ||
<div class="form-group row"> | ||
<div class="col-md-10"> | ||
<div class="row"> | ||
<label class="col-md-3 sm-label-right"> | ||
Type | ||
<help-field key="pipeline.config.artifact.type"></help-field> | ||
</label> | ||
<div class="col-md-9"> | ||
<input type="text" | ||
required | ||
class="form-control input-sm" | ||
ng-model="$ctrl.artifact.type"/> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="col-md-2 text-right"> | ||
<button class="btn btn-sm btn-default" ng-click="$ctrl.removeArtifact()"> | ||
<span class="glyphicon glyphicon-trash" uib-tooltip="Remove artifact"></span> | ||
<span class="visible-xl-inline">Remove artifact</span> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group row"> | ||
<div class="col-md-10"> | ||
<div class="row"> | ||
<label class="col-md-3 sm-label-right"> | ||
Name | ||
<help-field key="pipeline.config.artifact.name"></help-field> | ||
</label> | ||
<div class="col-md-9"> | ||
<input type="text" | ||
required | ||
class="form-control input-sm" | ||
ng-model="$ctrl.artifact.name"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group row"> | ||
<div class="col-md-10"> | ||
<div class="row"> | ||
<label class="col-md-3 sm-label-right" help-key="pipeline.config.artifact.missingPolicy"> | ||
Missing Policy | ||
<help-field key="pipeline.config.artifact.missingPolicy"></help-field> | ||
</label> | ||
<div class="col-md-9"> | ||
<select class="form-control input-sm" | ||
required | ||
ng-options="policy for policy in $ctrl.missingPolicies" | ||
ng-model="$ctrl.artifact.missingPolicy"> | ||
<option value="">Select...</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters