From f6ffa184c9634fa94ec4d462ad897758a62a69dc Mon Sep 17 00:00:00 2001 From: Reetika R Date: Fri, 16 Jun 2017 10:30:04 -0700 Subject: [PATCH] fix(580): add pipeline annotations to models When a user calls a pipeline.get, we should properly return the annotations field along with workflow and other metadata. Related to: https://github.com/screwdriver-cd/screwdriver/issues/580 --- models/pipeline.js | 12 ++++++++---- package.json | 2 +- test/data/pipeline.get.yaml | 6 ++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/models/pipeline.js b/models/pipeline.js index 88b412c1..97120052 100644 --- a/models/pipeline.js +++ b/models/pipeline.js @@ -1,10 +1,11 @@ 'use strict'; +const Annotations = require('../config/annotations'); const Joi = require('joi'); -const mutate = require('../lib/mutate'); const Regex = require('../config/regex'); -const Workflow = require('../config/workflow'); const Scm = require('../core/scm'); +const Workflow = require('../config/workflow'); +const mutate = require('../lib/mutate'); const CHECKOUT_URL = { checkoutUrl: Joi @@ -39,7 +40,10 @@ const MODEL = { .example({ myself: true }), workflow: Workflow.workflow - .description('Current workflow of the pipeline') + .description('Current workflow of the pipeline'), + + annotations: Annotations.annotations + .description('Pipeline-level annotations') }; module.exports = { @@ -60,7 +64,7 @@ module.exports = { get: Joi.object(mutate(MODEL, [ 'id', 'scmUri', 'createTime', 'admins' ], [ - 'workflow', 'scmRepo' + 'workflow', 'scmRepo', 'annotations' ])).label('Get Pipeline'), /** diff --git a/package.json b/package.json index af6f3bb5..2c739f73 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,6 @@ "js-yaml": "^3.6.1" }, "dependencies": { - "joi": "^10.0.5" + "joi": "^10.6.0" } } diff --git a/test/data/pipeline.get.yaml b/test/data/pipeline.get.yaml index 46348c2f..e1c3d709 100644 --- a/test/data/pipeline.get.yaml +++ b/test/data/pipeline.get.yaml @@ -11,3 +11,9 @@ scmRepo: name: screwdriver-cd/screwdriver branch: master url: https://github.com/screwdriver-cd/screwdriver/tree/master +annotations: + screwdriver.cd/executor.resource: + - XCODE8 + - OSX-SIERRA + screwdriver.cd/notify.email: foo@example.com + beta.screwdriver.cd/auto_pr_builds: fork-only