summaryrefslogtreecommitdiff
path: root/icktool
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-11-06 20:56:52 +0100
committerLars Wirzenius <liw@liw.fi>2017-11-06 20:56:52 +0100
commitc9e9a5c9aa8cbd2c1510ee06f7eb2af3628c60b5 (patch)
tree1648c1e76ed0764a3c7245fd6733894551b5ad1b /icktool
parentf3ee9238ded2254b05f77a76e195538b4f18aace (diff)
downloadick2-c9e9a5c9aa8cbd2c1510ee06f7eb2af3628c60b5.tar.gz
Add: new scopes, commands for pipelines, builds, logs
Diffstat (limited to 'icktool')
-rwxr-xr-xicktool43
1 files changed, 42 insertions, 1 deletions
diff --git a/icktool b/icktool
index a9ae655..3c8dec9 100755
--- a/icktool
+++ b/icktool
@@ -41,7 +41,7 @@ class Icktool(cliapp.Application):
_default_scopes = [
'uapi_version_get',
'uapi_work_post',
- ] + scopes('projects') + scopes('work') + scopes('builds')
+ ] + scopes('projects') + scopes('work') + scopes('builds') + scopes('logs')
def add_settings(self):
self.settings.string(
@@ -120,6 +120,35 @@ class Icktool(cliapp.Application):
name = args[0]
rc.delete(name)
+ def cmd_show_pipeline(self, args):
+ project = args[0]
+ pipeline = args[1]
+ 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)
+
+ def _report(self, code, expected, text):
+ if code != expected:
+ sys.stderr.write('HTTP status {}\n'.format(code))
+ sys.stderr.write(text)
+ if not text.endswith('\n'):
+ sys.stderr.write('\n')
+ sys.exit(1)
+
+ def cmd_set_pipeline(self, args):
+ project = args[0]
+ pipeline = args[1]
+ state = args[2]
+ path = '/projects/{}/pipelines/{}'.format(project, pipeline)
+ api = self._new_api()
+ code, text = api.put(path, {'status': state})
+ self._report(code, 200, text)
+ obj = json.loads(text)
+ self._prettyson(obj)
+
def cmd_list_workers(self, args):
rc = self._new_rc('/workers', 'worker')
self._prettyson(rc.list())
@@ -148,6 +177,18 @@ class Icktool(cliapp.Application):
rc = self._new_rc('/builds', 'build')
self._prettyson(rc.list())
+ def cmd_list_logs(self, args):
+ rc = self._new_rc('/logs', 'log')
+ self._prettyson(rc.list())
+
+ def cmd_show_log(self, args):
+ log = args[0]
+ path = '/logs/{}'.format(log)
+ api = self._new_api()
+ code, text = api.get(path)
+ self._report(code, 200, text)
+ self.output.write(text)
+
def _new_token(self):
scopes = self.settings['scope']
cmd = self.settings['token-private-key-cmd']