From 708a497c369601909bc57768bc929fdccc235406 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 18 Jan 2018 15:14:28 +0200 Subject: Change: rename 'name' field on pipelines to 'pipeline' For consistency. --- NEWS | 1 + ick2/pipelineapi.py | 2 +- ick2/projectapi_tests.py | 6 +++--- ick2/state.py | 2 +- ick2/workapi.py | 6 +++--- ick2/workapi_tests.py | 2 +- icktool | 8 ++++---- yarns/100-projects.yarn | 2 +- yarns/150-pipelines.yarn | 20 ++++++++++---------- yarns/400-build.yarn | 2 +- yarns/500-build-fail.yarn | 2 +- yarns/600-unauthz.yarn | 2 +- 12 files changed, 28 insertions(+), 27 deletions(-) diff --git a/NEWS b/NEWS index 7985b22..bcfe459 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,7 @@ along with this program. If not, see . Version 0.22+git, not yet released ---------------------------------- +* The `name` field in pipeline resources is now called `pipeline`. Version 0.22, released 2018-01-15 ---------------------------------- diff --git a/ick2/pipelineapi.py b/ick2/pipelineapi.py index 061505e..c774df3 100644 --- a/ick2/pipelineapi.py +++ b/ick2/pipelineapi.py @@ -22,4 +22,4 @@ class PipelineAPI(ick2.ResourceApiBase): super().__init__('pipelines', state) def get_resource_name(self, resource): - return resource['name'] + return resource.get('pipeline') diff --git a/ick2/projectapi_tests.py b/ick2/projectapi_tests.py index 4e55ccf..c3e35f5 100644 --- a/ick2/projectapi_tests.py +++ b/ick2/projectapi_tests.py @@ -45,7 +45,7 @@ class ProjectAPITests(unittest.TestCase): def test_creates_project(self): pipeline = { - 'name': 'build', + 'pipeline': 'build', 'actions': [ {'shell': 'step-1'}, ], @@ -72,7 +72,7 @@ class ProjectAPITests(unittest.TestCase): 'project': 'foo', 'pipelines': [ { - 'name': 'build', + 'pipeline': 'build', 'actions': [ { 'shell': 'step-1', @@ -138,7 +138,7 @@ class ProjectAPITests(unittest.TestCase): def test_updates_pipeline_status(self): pipeline = { - 'name': 'build', + 'pipeline': 'build', 'actions': [ {'shell': 'step-1'}, ], diff --git a/ick2/state.py b/ick2/state.py index 2456bfc..c7bed19 100644 --- a/ick2/state.py +++ b/ick2/state.py @@ -175,7 +175,7 @@ class Builds(ResourceStore): # pragma: no cover class PipelineInstances(ResourceStore): # pragma: no cover def __init__(self, state): - super().__init__(state, 'pipeline_instances', 'name') + super().__init__(state, 'pipeline_instances', 'pipeline') def _name(self, project_name, pipeline_name): return '{} {}'.format(project_name, pipeline_name) diff --git a/ick2/workapi.py b/ick2/workapi.py index 8237ff4..e12b0d8 100644 --- a/ick2/workapi.py +++ b/ick2/workapi.py @@ -64,7 +64,7 @@ class WorkAPI(ick2.APIbase): 'build_id': build_id, 'worker': worker, 'project': project['project'], - 'pipeline': pipeline['name'], + 'pipeline': pipeline['pipeline'], 'parameters': project.get('parameters', {}), 'step': actions[current_action], 'log': '/logs/{}'.format(build_id), @@ -90,7 +90,7 @@ class WorkAPI(ick2.APIbase): def _update_pipeline(self, project, pipeline_instance): project_name = project['project'] - pipeline_name = pipeline_instance['name'] + pipeline_name = pipeline_instance['pipeline'] try: self._pinstances.update_instance( project_name, pipeline_name, pipeline_instance) @@ -110,7 +110,7 @@ class WorkAPI(ick2.APIbase): 'log': '/logs/{}'.format(build_id), 'worker': worker, 'project': project['project'], - 'pipeline': pipeline['name'], + 'pipeline': pipeline['pipeline'], 'parameters': parameters, 'status': 'building', 'actions': actions, diff --git a/ick2/workapi_tests.py b/ick2/workapi_tests.py index 48c9bbb..049e17c 100644 --- a/ick2/workapi_tests.py +++ b/ick2/workapi_tests.py @@ -35,7 +35,7 @@ class WorkAPITests(unittest.TestCase): def create_project_api(self): pipeline = { - 'name': 'build', + 'pipeline': 'build', 'actions': [ {'shell': 'step-1'}, {'shell': 'step-2'}, diff --git a/icktool b/icktool index 35cb251..494c85c 100755 --- a/icktool +++ b/icktool @@ -169,7 +169,7 @@ class Icktool(cliapp.Application): projects = self._new_rc('/projects', 'project') self._make_it_so(projects, obj.get('projects', [])) - pipelines = self._new_rc('/pipelines', 'name') + pipelines = self._new_rc('/pipelines', 'pipeline') self._make_it_so(pipelines, obj.get('pipelines', [])) def _make_it_so(self, rc, objs): @@ -203,16 +203,16 @@ class Icktool(cliapp.Application): rc.delete(name) def cmd_list_pipelines(self, args): - rc = self._new_rc('/pipelines', 'name') + rc = self._new_rc('/pipelines', 'pipeline') self._prettyson(rc.list()) def cmd_create_pipeline(self, args): - rc = self._new_rc('/pipelines', 'name') + rc = self._new_rc('/pipelines', 'pipeline') obj = self._read_object() rc.create(obj) def cmd_update_pipeline(self, args): - rc = self._new_rc('/pipelines', 'name') + rc = self._new_rc('/pipelines', 'pipeline') obj = self._read_object() rc.update(obj) diff --git a/yarns/100-projects.yarn b/yarns/100-projects.yarn index ba723d3..7c03619 100644 --- a/yarns/100-projects.yarn +++ b/yarns/100-projects.yarn @@ -63,7 +63,7 @@ building them. We start by starting an instance of the controller. WHEN user makes request POST /pipelines with a valid token and body ... { - ... "name": "build", + ... "pipeline": "build", ... "actions": [ ... { "shell": "git clone git://repo src" }, ... { "shell": "mkdir html" }, diff --git a/yarns/150-pipelines.yarn b/yarns/150-pipelines.yarn index f0f678e..2b8c4b6 100644 --- a/yarns/150-pipelines.yarn +++ b/yarns/150-pipelines.yarn @@ -25,7 +25,7 @@ They're described like resources like this: EXAMPLE pipeline resource { - "name": "build-website", + "pipeline": "build-website", "parameters": { "foo": "bar" }, @@ -71,7 +71,7 @@ running them. We start by starting an instance of the controller. WHEN user makes request POST /pipelines with a valid token and body ... { - ... "name": "build_website", + ... "pipeline": "build_website", ... "actions": [ ... { "shell": "git clone git://repo src" }, ... { "shell": "mkdir html" }, @@ -81,7 +81,7 @@ running them. We start by starting an instance of the controller. THEN result has status code 201 AND body matches ... { - ... "name": "build_website", + ... "pipeline": "build_website", ... "actions": [ ... { "shell": "git clone git://repo src" }, ... { "shell": "mkdir html" }, @@ -93,7 +93,7 @@ Creating a new pipeline with the same name is forbidden. WHEN user makes request POST /pipelines with a valid token and body ... { - ... "name": "build_website" + ... "pipeline": "build_website" ... } THEN result has status code 409 @@ -103,7 +103,7 @@ Creating a new pipeline with the same name is forbidden. ... { ... "pipelines": [ ... { - ... "name": "build_website", + ... "pipeline": "build_website", ... "actions": [ ... { "shell": "git clone git://repo src" }, ... { "shell": "mkdir html" }, @@ -119,7 +119,7 @@ Creating a new pipeline with the same name is forbidden. THEN result has status code 200 AND body matches ... { - ... "name": "build_website", + ... "pipeline": "build_website", ... "actions": [ ... { "shell": "git clone git://repo src" }, ... { "shell": "mkdir html" }, @@ -130,7 +130,7 @@ Creating a new pipeline with the same name is forbidden. WHEN user makes request PUT /pipelines/build_websitte with a valid token ... and body ... { - ... "name": "build_website", + ... "pipeline": "build_website", ... "actions": [ ... { "shell": "build-it" } ... ] @@ -138,7 +138,7 @@ Creating a new pipeline with the same name is forbidden. THEN result has status code 200 AND body matches ... { - ... "name": "build_website", + ... "pipeline": "build_website", ... "actions": [ ... { "shell": "build-it" } ... ] @@ -148,7 +148,7 @@ Creating a new pipeline with the same name is forbidden. THEN result has status code 200 AND body matches ... { - ... "name": "build_website", + ... "pipeline": "build_website", ... "actions": [ ... { "shell": "build-it" } ... ] @@ -161,7 +161,7 @@ Creating a new pipeline with the same name is forbidden. WHEN user makes request PUT /pipelines/doesnotexist with a valid token and body ... { - ... "name": "doesnotexist" + ... "pipeline": "doesnotexist" ... } THEN result has status code 404 diff --git a/yarns/400-build.yarn b/yarns/400-build.yarn index b18a0e6..f30e942 100644 --- a/yarns/400-build.yarn +++ b/yarns/400-build.yarn @@ -43,7 +43,7 @@ Add up a project with some named pipelines. WHEN user makes request POST /pipelines with a valid token and body ... { - ... "name": "construct", + ... "pipeline": "construct", ... "actions": [ ... { "shell": "day 1" }, ... { "shell": "day 2" } diff --git a/yarns/500-build-fail.yarn b/yarns/500-build-fail.yarn index 433c3e0..64e8333 100644 --- a/yarns/500-build-fail.yarn +++ b/yarns/500-build-fail.yarn @@ -44,7 +44,7 @@ Add up a project and its pipelines. WHEN user makes request POST /pipelines with a valid token and body ... { - ... "name": "construct", + ... "pipeline": "construct", ... "actions": [ ... { "shell": "day 1" }, ... { "shell": "day 2" } diff --git a/yarns/600-unauthz.yarn b/yarns/600-unauthz.yarn index 7eaf902..99700ba 100644 --- a/yarns/600-unauthz.yarn +++ b/yarns/600-unauthz.yarn @@ -44,7 +44,7 @@ Set up the controller. ... "project": "rome", ... "pipelines": [ ... { - ... "name": "construct", + ... "pipeline": "construct", ... "actions": [ ... { "shell": "day 1" }, ... { "shell": "day 2" } -- cgit v1.2.1