summaryrefslogtreecommitdiff
path: root/icktool
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-11-29 20:13:59 +0100
committerLars Wirzenius <liw@liw.fi>2017-11-29 20:22:06 +0100
commit6532045949fe17538e277710f332b3c0727fe4b9 (patch)
tree87c12f13bb47936499ababfe661e21dd82c76d18 /icktool
parent30e1cd48f2fa0618e366a32a89e59c75956b4623 (diff)
downloadick2-6532045949fe17538e277710f332b3c0727fe4b9.tar.gz
Add+Fix: support for named pipelines
Diffstat (limited to 'icktool')
-rwxr-xr-xicktool58
1 files changed, 50 insertions, 8 deletions
diff --git a/icktool b/icktool
index 8b89a84..0090b2b 100755
--- a/icktool
+++ b/icktool
@@ -40,6 +40,22 @@ def scopes(base):
return [x.format(base) for x in patterns]
+def scopes_for_types(types):
+ result = []
+ for type_name in types:
+ result.extend(scopes(type_name))
+ return result
+
+
+types = [
+ 'projects',
+ 'pipelines',
+ 'workers',
+ 'work',
+ 'builds',
+ 'logs',
+]
+
class Icktool(cliapp.Application):
_default_scopes = [
@@ -47,7 +63,7 @@ class Icktool(cliapp.Application):
'uapi_work_post',
'uapi_projects_id_pipelines_id_get',
'uapi_projects_id_pipelines_id_put',
- ] + scopes('projects') + scopes('workers') + scopes('work') + scopes('builds') + scopes('logs')
+ ] + scopes_for_types(types)
def add_settings(self):
self.settings.string(
@@ -110,12 +126,14 @@ class Icktool(cliapp.Application):
pipelines = project['pipelines']
for pipeline in pipelines:
build = self._get_latest_build(
- project['project'], pipeline['name'], builds)
+ project['project'], pipeline, builds)
+ status = self._get_pipeline_status(
+ project['project'], pipeline)
row = {
'project': project['project'],
- 'pipeline': pipeline['name'],
+ 'pipeline': pipeline,
'build_id': build['build_id'],
- 'status': pipeline['status'],
+ 'status': status['status'],
'log': build['log'],
}
rows.append(row)
@@ -160,15 +178,39 @@ class Icktool(cliapp.Application):
name = args[0]
rc.delete(name)
+ def cmd_list_pipelines(self, args):
+ rc = self._new_rc('/pipelines', 'name')
+ self._prettyson(rc.list())
+
+ def cmd_create_pipeline(self, args):
+ rc = self._new_rc('/pipelines', 'name')
+ obj = self._read_object()
+ rc.create(obj)
+
+ def cmd_update_pipeline(self, args):
+ rc = self._new_rc('/pipelines', 'name')
+ obj = self._read_object()
+ rc.update(obj)
+
def cmd_show_pipeline(self, args):
- project = args[0]
- pipeline = args[1]
+ rc = self._new_rc('/pipelines', 'pipeline')
+ name = args[0]
+ self._prettyson(rc.show(name))
+
+ def cmd_delete_pipeline(self, args):
+ rc = self._new_rc('/pipelines', 'pipeline')
+ name = args[0]
+ rc.delete(name)
+
+ def cmd_show_pipeline_status(self, args):
+ self._prettyson(self._get_pipeline_status(args[0], args[1]))
+
+ def _get_pipeline_status(self, project, pipeline):
path = '/projects/{}/pipelines/{}'.format(project, pipeline)
api = self._new_api()
code, text = api.get(path)
self._report(code, 200, text)
- obj = json.loads(text)
- self._prettyson(obj)
+ return json.loads(text)
def _report(self, code, expected, text):
if code != expected: