Skip to content

Commit

Permalink
Merge pull request #38 from screwdriver-cd/allow-descriptions
Browse files Browse the repository at this point in the history
feat(423): Allow parsing of description in config-parser
  • Loading branch information
joelseq authored Jun 23, 2017
2 parents c58f973 + d7d2968 commit 7356c74
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/phase/flatten.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function flattenSharedIntoJobs(shared, jobs) {
const oldJob = clone(jobs[jobName]);

// Replace
['image', 'matrix', 'steps', 'template'].forEach((key) => {
['image', 'matrix', 'steps', 'template', 'description'].forEach((key) => {
if (oldJob[key]) {
newJob[key] = oldJob[key];
}
Expand Down
9 changes: 7 additions & 2 deletions lib/phase/permutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ module.exports = validatedDoc => (
annotations: Hoek.reach(doc, `jobs.${jobName}.annotations`, {
default: {}
}),
image: Hoek.reach(doc, `jobs.${jobName}.image`),
commands: Hoek.reach(doc, `jobs.${jobName}.commands`),
secrets: Hoek.reach(doc, `jobs.${jobName}.secrets`),
environment: Hoek.reach(doc, `jobs.${jobName}.environment`, {
default: {}
}),
image: Hoek.reach(doc, `jobs.${jobName}.image`),
secrets: Hoek.reach(doc, `jobs.${jobName}.secrets`),
settings: Hoek.reach(doc, `jobs.${jobName}.settings`, {
default: {}
})
};

if (doc.jobs[jobName].description !== undefined) {
job.description = doc.jobs[jobName].description;
}

const matrix = Hoek.reach(doc, `jobs.${jobName}.matrix`, {
default: {}
});
Expand Down
9 changes: 9 additions & 0 deletions test/data/basic-job-with-description.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
shared:
image: node:4

jobs:
main:
description: "This is a description"
steps:
- hello: "echo hi world"
- maybe: "which asdfzxcvasdfqwer1234"
9 changes: 9 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ describe('config parser', () => {
assert.deepEqual(data, JSON.parse(loadData('pipeline-annotations.json')));
})
);

it('allows a description key', () =>
parser(loadData('basic-job-with-description.yaml'))
.then((data) => {
assert.isDefined(data.jobs.main[0].description);
assert.equal(data.jobs.main[0].description,
'This is a description');
})
);
});

describe('permutation', () => {
Expand Down

0 comments on commit 7356c74

Please sign in to comment.