-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(1040): resolve job image alias with template images (#67)
- Loading branch information
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"annotations": {}, | ||
"jobs": { | ||
"main": [ | ||
{ | ||
"annotations": {}, | ||
"commands": [ | ||
{ | ||
"command": "npm install", | ||
"name": "install" | ||
}, | ||
{ | ||
"command": "echo hello world", | ||
"name": "hello" | ||
} | ||
], | ||
"environment": { | ||
"SD_TEMPLATE_FULLNAME": "ImagesTestNamespace/imagestemplate", | ||
"SD_TEMPLATE_NAME": "imagestemplate", | ||
"SD_TEMPLATE_NAMESPACE": "ImagesTestNamespace", | ||
"SD_TEMPLATE_VERSION": "2" | ||
}, | ||
"image": "node:5", | ||
"secrets": [], | ||
"settings": {} | ||
} | ||
], | ||
"publish": [ | ||
{ | ||
"annotations": {}, | ||
"commands": [ | ||
{ | ||
"command": "npm publish", | ||
"name": "publish" | ||
} | ||
], | ||
"description": "This is the publish description", | ||
"environment": {}, | ||
"image": "node:4", | ||
"secrets": [], | ||
"settings": {} | ||
} | ||
] | ||
}, | ||
"workflowGraph": { | ||
"edges": [], | ||
"nodes": [ | ||
{ | ||
"name": "~pr" | ||
}, | ||
{ | ||
"name": "~commit" | ||
}, | ||
{ | ||
"name": "publish" | ||
}, | ||
{ | ||
"name": "main" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
jobs: | ||
main: | ||
image: latest-image | ||
template: ImagesTestNamespace/imagestemplate@2 | ||
description: "This is the main description" | ||
publish: | ||
image: node:4 | ||
description: "This is the publish description" | ||
steps: | ||
- publish: "npm publish" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"namespace": "ImagesTestNamespace", | ||
"name": "imagestemplate", | ||
"version": "2", | ||
"description": "test template", | ||
"maintainer": "[email protected]", | ||
"labels": [], | ||
"images": { | ||
"stable-image": "node:4", | ||
"latest-image": "node:5" | ||
}, | ||
"config": { | ||
"image": "node:4", | ||
"steps": [ | ||
{ "install": "npm install" }, | ||
{ "hello": "echo hello world" } | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,18 +227,22 @@ describe('config parser', () => { | |
let secondTemplate; | ||
let namespaceTemplate; | ||
let defaultTemplate; | ||
let imagesTemplate; | ||
|
||
beforeEach(() => { | ||
firstTemplate = JSON.parse(loadData('template.json')); | ||
secondTemplate = JSON.parse(loadData('template-2.json')); | ||
namespaceTemplate = JSON.parse(loadData('templateWithNamespace.json')); | ||
defaultTemplate = JSON.parse(loadData('templateWithDefaultNamespace.json')); | ||
imagesTemplate = JSON.parse(loadData('templateWithImages.json')); | ||
templateFactoryMock.getTemplate.withArgs('[email protected]') | ||
.resolves(firstTemplate); | ||
templateFactoryMock.getTemplate.withArgs('yourtemplate@2') | ||
.resolves(secondTemplate); | ||
templateFactoryMock.getTemplate.withArgs('mynamespace/[email protected]') | ||
.resolves(namespaceTemplate); | ||
templateFactoryMock.getTemplate.withArgs('ImagesTestNamespace/imagestemplate@2') | ||
.resolves(imagesTemplate); | ||
}); | ||
|
||
it('flattens templates successfully', () => | ||
|
@@ -269,6 +273,12 @@ describe('config parser', () => { | |
data, JSON.parse(loadData('basic-job-with-template-override-steps.json')))) | ||
); | ||
|
||
it('flattens templates with images', () => | ||
parser(loadData('basic-job-with-images.yaml'), templateFactoryMock) | ||
.then(data => assert.deepEqual( | ||
data, JSON.parse(loadData('basic-job-with-images.json')))) | ||
); | ||
|
||
it('returns error if template does not exist', () => { | ||
templateFactoryMock.getTemplate.withArgs('[email protected]').resolves(null); | ||
|
||
|