Skip to content

Commit

Permalink
fix: Add '.', ':', to IMAGE_ALIAS regex (#513)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jaysoffian and Jay Soffian authored May 1, 2023
1 parent 83cf52a commit 3aafee7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions test/config/regex.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 3aafee7

Please sign in to comment.