From afc8d310be32a1b71f24a7b7f5ad385c220203ed Mon Sep 17 00:00:00 2001
From: Lars Wander
If you want to start from scratch, select "None".
You can always edit the cluster configuration after you've created it.
`, - 'pipeline.config.expectedArtifact.fieldName': ` -The Artifact field name.
`, - 'pipeline.config.expectedArtifact.fieldType': ` -The Artifact field type. This must be one of 'MUST_MATCH' or 'FIND_IF_MISSING'.
-MUST_MATCH means the incoming Artifact's field value must match exactly with the expected value.
-FIND_IF_MISSING means the field is optional and a 'Missing Policy' will fire if the value is not present.
`, - 'pipeline.config.expectedArtifact.missingPolicy': ` -The policy if the field type is 'FIND_IF_MISSING' and the field value is not present.
-FAIL_PIPELINE fails the pipeline if the field value is missing.
-IGNORE ignores the fact that the value is missing and runs the pipeline anyway.
-PRIOR_PIPELINE looks up the field's value from a prior pipeline execution.
`, + 'pipeline.config.expectedArtifact.custom.matchArtifact': ` +This specifies which fields in your incoming artifact to match against. Every field that you supply will be used to match against all incoming artifacts. If all fields specified match, the incoming artifact is bound to your pipeline context.
+For example, if you want to match against any GCS object, only supply type=gcs/object. If you also want to restrict the matches by other fields, include those as well.
`, + 'pipeline.config.expectedArtifact.custom.ifMissing': ` +If no artifact was supplied by your trigger to match against this expected artifact, you have a few options: +
Configures the timeout, in seconds, for reaching the healthCheck target. Must be less than the interval.
Default: 5
', 'loadBalancer.advancedSettings.healthInterval': 'Configures the interval, in seconds, between ELB health checks. Must be greater than the timeout.
Default: 10
', 'loadBalancer.advancedSettings.healthyThreshold': 'Configures the number of healthy observations before reinstituting an instance into the ELB’s traffic rotation.
Default: 10
', diff --git a/app/scripts/modules/core/src/pipeline/config/pipelineConfig.less b/app/scripts/modules/core/src/pipeline/config/pipelineConfig.less index 4b078b060f6..60593fba6db 100644 --- a/app/scripts/modules/core/src/pipeline/config/pipelineConfig.less +++ b/app/scripts/modules/core/src/pipeline/config/pipelineConfig.less @@ -225,7 +225,7 @@ triggers { margin-top: 25px; margin-bottom: 10px; } - trigger, artifact { + trigger, expected-artifact { display: block; padding: 10px 20px; background-color: var(--color-white); diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.component.ts b/app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.component.ts index 685a17f5433..337c9af2f2e 100644 --- a/app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.component.ts +++ b/app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.component.ts @@ -1,64 +1,17 @@ import { IComponentController, IComponentOptions, module } from 'angular'; import { PIPELINE_CONFIG_PROVIDER } from 'core/pipeline/config/pipelineConfigProvider'; -import { FieldType, IArtifactField, IExpectedArtifact, MissingArtifactPolicy } from 'core/domain/IExpectedArtifact'; -import { IPipeline } from 'core/domain/IPipeline'; +import { IArtifact } from 'core/domain/IArtifact'; class ArtifactController implements IComponentController { - public artifact: IExpectedArtifact; - public pipeline: IPipeline; - public missingPolicies: string[] = Object.keys(MissingArtifactPolicy).map(key => MissingArtifactPolicy[key as any]); - public fieldNames: string[] = ['type', 'name', 'version', 'location', 'reference', 'artifactAccount', 'provenance', 'uuid']; - public fieldTypes: string[] = Object.keys(FieldType).map(key => FieldType[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.equals(a, this.artifact))); - } - - public addField(): void { - const newField: IArtifactField = { - fieldName: '', - fieldType: FieldType.MustMatch, - value: '', - missingPolicy: MissingArtifactPolicy.FailPipeline - }; - - if (!this.artifact.fields) { - this.artifact.fields = []; - } - this.artifact.fields.push(newField); - } - - public removeField(fieldIndex: number): void { - this.artifact.fields.splice(fieldIndex, 1); - } - - private equals(first: IExpectedArtifact, other: IExpectedArtifact): boolean { - const fieldIsEqual = (firstField: IArtifactField, otherField: IArtifactField): boolean => { - return firstField.fieldName === otherField.fieldName - && firstField.fieldType === otherField.fieldType - && firstField.value === otherField.value - && firstField.missingPolicy === otherField.missingPolicy - && firstField.expression === otherField.expression; - }; - if (first.fields.length !== other.fields.length) { - return false; - } - - return first.fields.every(firstField => { - return other.fields.some(otherField => fieldIsEqual(firstField, otherField)); - }); - } + public artifact: IArtifact; } class ArtifactComponent implements IComponentOptions { - public bindings = { artifact: '<', pipeline: '<' }; + public bindings = { artifact: '=' }; public templateUrl = require('./artifact.html'); public controller = ArtifactController; + public controllerAs = 'ctrl'; } export const ARTIFACT = 'spinnaker.core.pipeline.trigger.artifact'; diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.html b/app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.html index 838348efd91..d058393b6c2 100644 --- a/app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.html +++ b/app/scripts/modules/core/src/pipeline/config/triggers/artifacts/artifact.html @@ -1,87 +1,47 @@ -- You don't have any fields declared for this artifact. -
-diff --git a/app/scripts/modules/core/src/pipeline/config/validation/pipelineConfig.validator.ts b/app/scripts/modules/core/src/pipeline/config/validation/pipelineConfig.validator.ts index 2e3561ed698..1178af6fd71 100644 --- a/app/scripts/modules/core/src/pipeline/config/validation/pipelineConfig.validator.ts +++ b/app/scripts/modules/core/src/pipeline/config/validation/pipelineConfig.validator.ts @@ -10,7 +10,6 @@ import { ITriggerTypeConfig } from 'core/domain'; import { PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from 'core/pipeline/config/pipelineConfigProvider'; -import { FieldType } from '@spinnaker/core'; export interface IStageValidationResults { stage: IStage; @@ -149,11 +148,8 @@ export class PipelineConfigValidator implements IServiceProvider { if (pipeline.strategy && !(pipeline.stages.some(stage => stage.type === 'deploy'))) { messages.push('To be able to create new server groups, a custom strategy should contain a Deploy stage.'); } - if ((pipeline.expectedArtifacts || []).some(a => a.fields.some(f => !f.fieldName || !f.fieldType || !f.value))) { - messages.push('Name, Type, Value are required attributes for artifact fields.'); - } - if ((pipeline.expectedArtifacts || []).some(a => a.fields.some(f => f.fieldType === FieldType.FindIfMissing && !f.missingPolicy))) { - messages.push('If Field Type is set to "FIND_IF_MISSING", a Missing Policy must be set.'); + if ((pipeline.expectedArtifacts || []).some(a => !a.matchArtifact || a.matchArtifact === {})) { + messages.push('Every expected artifact must specify an artifact to match against.'); } return messages; }