Skip to content

Commit

Permalink
feat(core): Expand Image Provider validation to find image stages (#9647
Browse files Browse the repository at this point in the history
)
  • Loading branch information
caseyhebebrand committed Sep 7, 2021
1 parent da063fb commit c6cd62f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ angular
},
{
type: 'imageProviderBeforeType',
message: 'You must have a trigger that provides the image metadata before any deploy stage.',
message: 'You must provide the image metadata before any deploy stage.',
triggerTypes: ['docker', 'jenkins'],
skipValidation: (pipeline, stage) =>
(stage.clusters || []).every(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IStageOrTriggerValidator, IValidatorConfig, PipelineConfigValidator } from './PipelineConfigValidator';
import { ICluster, IPipeline, IStage, IStageOrTriggerTypeConfig } from '../../../domain';
import { PipelineConfigService } from '../services/PipelineConfigService';

export interface IImageProviderBeforeTypeValidationConfig extends IValidatorConfig {
triggerTypes?: string[];
Expand All @@ -25,8 +26,14 @@ export class ImageProviderBeforeTypeValidator implements IStageOrTriggerValidato
(cluster: ICluster) => cluster.imageId && cluster.imageId !== '${trigger.properties.imageName}',
);

if (!hasImageProvider && !hasCustomImage) {
return `${validator.message} Add a trigger or manually input the imageId. Suggested triggers: ${(
const stageTypes = ['findAmi', 'findImage', 'findImageFromTags'];
const stagesToTest = PipelineConfigService.getAllUpstreamDependencies(pipeline, stage);
const hasFindImageStage = stagesToTest.some((test) => stageTypes.includes(test.type));

if (!hasImageProvider && !hasCustomImage && !hasFindImageStage) {
return `${
validator.message
} Update the pipeline with a find image stage or pipeline trigger or update this stage by manually inputting the imageId. Suggested triggers: ${(
validator.triggerTypes || []
).join(', ')}`;
}
Expand Down

0 comments on commit c6cd62f

Please sign in to comment.