-
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(artifacts): Simplify expected artifacts (#4266)
- Loading branch information
Showing
15 changed files
with
172 additions
and
184 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,11 @@ | ||
export interface IArtifact { | ||
type: string; | ||
name: string; | ||
version: string; | ||
location: string; | ||
reference: string; | ||
metadata: any; | ||
artifactAccount: string; | ||
provenance: string; | ||
uuid: string; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,8 @@ | ||
export interface IExpectedArtifact { | ||
fields: IArtifactField[]; | ||
} | ||
|
||
export interface IArtifactField { | ||
fieldName: string; | ||
fieldType: FieldType; | ||
value?: string; | ||
missingPolicy?: MissingArtifactPolicy; | ||
expression?: string; | ||
} | ||
import { IArtifact } from 'core/domain/IArtifact'; | ||
|
||
export enum FieldType { | ||
MustMatch = 'MUST_MATCH', | ||
FindIfMissing = 'FIND_IF_MISSING' | ||
export interface IExpectedArtifact { | ||
matchArtifact: IArtifact; | ||
usePriorArtifact: boolean; | ||
defaultArtifact: IArtifact; | ||
} | ||
|
||
export enum MissingArtifactPolicy { | ||
FailPipeline = 'FAIL_PIPELINE', | ||
Ignore = 'IGNORE', | ||
PriorPipeline = 'PRIOR_PIPELINE' | ||
} |
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
55 changes: 4 additions & 51 deletions
55
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
128 changes: 44 additions & 84 deletions
128
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 |
---|---|---|
@@ -1,87 +1,47 @@ | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="form-horizontal panel-pipeline-phase"> | ||
<div class="row" ng-repeat="field in $ctrl.artifact.fields"> | ||
<div class="form-group row"> | ||
<div class="col-md-12"> | ||
<div class="form-group row"> | ||
<label class="col-md-3 sm-label-right"> | ||
Field Name | ||
<help-field key="pipeline.config.expectedArtifact.fieldName"></help-field> | ||
</label> | ||
<div class="col-md-3"> | ||
<select class="input-sm" | ||
required | ||
ng-options="fieldName for fieldName in $ctrl.fieldNames" | ||
ng-model="field.fieldName"> | ||
<option value="">Select...</option> | ||
</select> | ||
</div> | ||
<label class="col-md-2 sm-label-right"> | ||
Field Type | ||
<help-field key="pipeline.config.expectedArtifact.fieldType"></help-field> | ||
</label> | ||
<div class="col-md-3"> | ||
<select class="input-sm" | ||
required | ||
ng-options="fieldType for fieldType in $ctrl.fieldTypes" | ||
ng-model="field.fieldType"> | ||
<option value="">Select...</option> | ||
</select> | ||
<button class="btn-link" ng-click="$ctrl.removeField($index)"> | ||
<span class="glyphicon glyphicon-trash" uib-tooltip="Delete Field"></span><span class="sr-only">Delete Field</span> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-md-12"> | ||
<div class="form-group row"> | ||
<label class="col-md-3 sm-label-right"> | ||
Field Value | ||
</label> | ||
<div class="col-md-3"> | ||
<input type="text" | ||
required | ||
class="form-control input-sm" | ||
ng-model="field.value"/> | ||
</div> | ||
<div ng-if="field.fieldType === 'FIND_IF_MISSING'"> | ||
<label class="col-md-2 sm-label-right"> | ||
Missing Policy | ||
<help-field key="pipeline.config.expectedArtifact.missingPolicy"></help-field> | ||
</label> | ||
<div class="col-md-3"> | ||
<select class="input-sm" | ||
required | ||
ng-options="policy for policy in $ctrl.missingPolicies" | ||
ng-model="field.missingPolicy"> | ||
<option value="">Select...</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<hr/> | ||
</div> | ||
<div class="row" ng-if="!$ctrl.artifact.fields.length"> | ||
<p class="col-md-12"> | ||
You don't have any fields declared for this artifact. | ||
</p> | ||
</div> | ||
<div class="form-group row"> | ||
<div class="col-md-12"> | ||
<button class="btn btn-block btn-add-trigger add-new" ng-click="$ctrl.addField()"> | ||
<span class="glyphicon glyphicon-plus-sign"></span> Add Field | ||
</button> | ||
</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 class="col-md-12"> | ||
<div class="form-group row"> | ||
<label class="col-md-2 sm-label-right"> | ||
Type | ||
</label> | ||
<div class="col-md-3"> | ||
<input type="text" | ||
class="form-control input-sm" | ||
ng-model="ctrl.artifact.type"/> | ||
</div> | ||
<label class="col-md-2 sm-label-right"> | ||
Name | ||
</label> | ||
<div class="col-md-3"> | ||
<input type="text" | ||
class="form-control input-sm" | ||
ng-model="ctrl.artifact.name"/> | ||
</div> | ||
</div> | ||
<div class="form-group row"> | ||
<label class="col-md-2 sm-label-right"> | ||
Version | ||
</label> | ||
<div class="col-md-3"> | ||
<input type="text" | ||
class="form-control input-sm" | ||
ng-model="ctrl.artifact.version"/> | ||
</div> | ||
<label class="col-md-2 sm-label-right"> | ||
Location | ||
</label> | ||
<div class="col-md-3"> | ||
<input type="text" | ||
class="form-control input-sm" | ||
ng-model="ctrl.artifact.location"/> | ||
</div> | ||
</div> | ||
<div class="form-group row"> | ||
<label class="col-md-2 sm-label-right"> | ||
Reference | ||
</label> | ||
<div class="col-md-8"> | ||
<input type="text" | ||
class="form-control input-sm" | ||
ng-model="ctrl.artifact.reference"/> | ||
</div> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
...scripts/modules/core/src/pipeline/config/triggers/artifacts/expectedArtifact.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,36 @@ | ||
import { equals, IComponentController, IComponentOptions, module } from 'angular'; | ||
|
||
import { PIPELINE_CONFIG_PROVIDER } from 'core/pipeline/config/pipelineConfigProvider'; | ||
import { IExpectedArtifact } from 'core/domain/IExpectedArtifact'; | ||
import { IPipeline } from 'core/domain/IPipeline'; | ||
|
||
class ExpectedArtifactController implements IComponentController { | ||
public expectedArtifact: IExpectedArtifact; | ||
public pipeline: IPipeline; | ||
|
||
private static expectedArtifactEquals(first: IExpectedArtifact, other: IExpectedArtifact): boolean { | ||
// Interesting to point out that if two artifact's match artifacts equal, they match the same artifacts & are effectively equal | ||
return equals(first.matchArtifact, other.matchArtifact); | ||
} | ||
|
||
public removeExpectedArtifact(): void { | ||
this.pipeline.expectedArtifacts = this.pipeline.expectedArtifacts | ||
.filter(a => !ExpectedArtifactController.expectedArtifactEquals(a, this.expectedArtifact)); | ||
|
||
this.pipeline.triggers | ||
.forEach(t => t.expectedArtifacts = t.expectedArtifacts | ||
.filter(a => !ExpectedArtifactController.expectedArtifactEquals(a, this.expectedArtifact))); | ||
} | ||
} | ||
|
||
class ExpectedArtifactComponent implements IComponentOptions { | ||
public bindings = { expectedArtifact: '=', pipeline: '=' }; | ||
public templateUrl = require('./expectedArtifact.html'); | ||
public controller = ExpectedArtifactController; | ||
public controllerAs = 'ctrl'; | ||
} | ||
|
||
export const EXPECTED_ARTIFACT = 'spinnaker.core.pipeline.trigger.expected.artifact'; | ||
module(EXPECTED_ARTIFACT, [ | ||
PIPELINE_CONFIG_PROVIDER, | ||
]).component('expectedArtifact', new ExpectedArtifactComponent()); |
43 changes: 43 additions & 0 deletions
43
app/scripts/modules/core/src/pipeline/config/triggers/artifacts/expectedArtifact.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,43 @@ | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="form-horizontal panel-pipeline-phase"> | ||
<div class="form-group row"> | ||
<div class="col-md-3"> | ||
Match against | ||
<help-field key="pipeline.config.expectedArtifact.custom.matchArtifact"></help-field> | ||
</div> | ||
<div class="col-md-2 col-md-offset-7"> | ||
<button class="btn btn-sm btn-default" ng-click="ctrl.removeExpectedArtifact()"> | ||
<span class="glyphicon glyphicon-trash" uib-tooltip="Remove expected artifact"></span> | ||
<span class="visible-xl-inline">Remove artifact</span> | ||
</button> | ||
</div> | ||
</div> | ||
<artifact artifact="ctrl.expectedArtifact.matchArtifact"></artifact> | ||
If missing | ||
<help-field key="pipeline.config.expectedArtifact.custom.ifMissing"></help-field> | ||
<div class="form-group row"> | ||
<label class="col-md-3 sm-label-right"> | ||
Use Prior Execution | ||
</label> | ||
<input class="col-md-1" type="checkbox" ng-model="ctrl.expectedArtifact.usePriorExecution"> | ||
</div> | ||
<div class="form-group row"> | ||
<label class="col-md-3 sm-label-right"> | ||
Use Default Artifact | ||
</label> | ||
<input class="col-md-1" type="checkbox" ng-model="ctrl.expectedArtifact.useDefaultArtifact"> | ||
</div> | ||
<div ng-show="ctrl.expectedArtifact.useDefaultArtifact"> | ||
<div class="form-group row"> | ||
<div class="col-md-3"> | ||
Default artifact | ||
</div> | ||
</div> | ||
<div class="form-group row"> | ||
<artifact artifact="ctrl.expectedArtifact.defaultArtifact"></artifact> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.