From 3aafee7993d8177e565db98aedaa2d8f439326fa Mon Sep 17 00:00:00 2001 From: Jay Soffian <155970+jaysoffian@users.noreply.github.com> Date: Mon, 1 May 2023 14:35:54 -0400 Subject: [PATCH] fix: Add '.', ':', to IMAGE_ALIAS regex (#513) This change will allow for an alias such as `xcode:14.1`. Without this change the alias needs to be something unnatural such as `xcode-14_1`. The image aliases are essentially only dictionary keys, so it's not clear why their naming need be restricted at all, much less be any more restrictive than the image name itself. However, on the assumption that there is a reason for the naming restriction, this commit take the conservative approach of adding only two additional characters. Co-authored-by: Jay Soffian --- config/regex.js | 4 ++-- config/template.js | 2 +- test/config/regex.test.js | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config/regex.js b/config/regex.js index 691e8f20..cbce76b8 100644 --- a/config/regex.js +++ b/config/regex.js @@ -97,8 +97,8 @@ module.exports = { // First group: SCM plugin name (e.g. github) // Second group: SCM host name (e.g. github.com) SCM_CONTEXT: /^([^:]+):([^:]+)$/, - // Image aliases can only contain A-Z,a-z,0-9,-,_ - IMAGE_ALIAS: /^[\w-]+$/, + // Image aliases can only contain A-Z,a-z,0-9,-,_,.,: + IMAGE_ALIAS: /^[\w-.:]+$/, // Valid Events for webhook WEBHOOK_EVENT: /^~([\w-]+)$/, // Provider region. e.g. us-west-1, ap-northeast-2 diff --git a/config/template.js b/config/template.js index 2ec1a04f..c3795fca 100644 --- a/config/template.js +++ b/config/template.js @@ -53,7 +53,7 @@ const TEMPLATE_MAINTAINER = Joi.string() const TEMPLATE_IMAGES = Joi.object() .pattern(Regex.IMAGE_ALIAS, Job.image) .messages({ - 'object.unknown': '{{#label}} only supports the following characters A-Z,a-z,0-9,-,_' + 'object.unknown': '{{#label}} only supports the following characters A-Z,a-z,0-9,-,_,.,:' }) .min(1); diff --git a/test/config/regex.test.js b/test/config/regex.test.js index e1e048e2..610a846d 100644 --- a/test/config/regex.test.js +++ b/test/config/regex.test.js @@ -239,6 +239,7 @@ describe('config regex', () => { describe('images', () => { it('checks good image names', () => { assert.isTrue(config.regex.IMAGE_NAME.test('10-13_931-9E501_20180531234344_platform')); + assert.isTrue(config.regex.IMAGE_NAME.test('xcode:14.2')); }); it('fails on bad image names', () => {