Skip to content

Commit

Permalink
fix(3106): Allow user to customize job when using pipeline template (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyi committed Jun 6, 2024
1 parent 0530a47 commit af17ddb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
20 changes: 13 additions & 7 deletions config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,26 @@ const SCHEMA_SUBSCRIBE = Joi.object().keys({
)
});

const ALLOWED_JOB_FIELDS_WITH_PIPELINE_TEMPLATE = Joi.object().keys({
image: Job.image,
environment: Job.environment,
settings: Job.settings,
requires: Job.requires
});

const SCHEMA_CONFIG_PRE_TEMPLATE_MERGE = Joi.object()
.keys({
template: Joi.string().regex(Regex.FULL_TEMPLATE_NAME_WITH_NAMESPACE),
version: Joi.number().integer().min(1).max(50),
annotations: Annotations.annotations,
jobs: SCHEMA_JOBS.when('template', { is: Joi.exist(), then: Joi.forbidden(), otherwise: Joi.required() }),
jobs: Joi.when('template', {
is: Joi.exist(),
then: Joi.object().pattern(Job.jobName, ALLOWED_JOB_FIELDS_WITH_PIPELINE_TEMPLATE).unknown(false),
otherwise: SCHEMA_JOBS.required()
}),
shared: Joi.when('template', {
is: Joi.exist(),
then: Joi.object().keys({
image: Job.image,
environment: Job.environment,
settings: Job.settings,
requires: Job.requires
}),
then: ALLOWED_JOB_FIELDS_WITH_PIPELINE_TEMPLATE,
otherwise: SCHEMA_SHARED
}),
cache: SCHEMA_CACHE,
Expand Down
10 changes: 10 additions & 0 deletions test/data/config.base.pipelineTemplate-customized.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ shared:
settings:
email: foo@example.com
requires: ~commit

jobs:
main:
requires: [~commit]
image: node:20
settings:
email: [test@email.com, test3@email.com]
environment:
VAR3: "three"
VAR1: "empty"

0 comments on commit af17ddb

Please sign in to comment.