summaryrefslogtreecommitdiff
path: root/icktool
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-01-13 15:36:05 +0200
committerLars Wirzenius <liw@liw.fi>2018-01-14 22:23:49 +0200
commit4c089769989460b7bb5e255baaa0e2f5f8ed02ce (patch)
tree890efb42b9ce6aff3b91388edde83b1fea192f12 /icktool
parenteaf8f8bc1957079f5a4009074d8bd81e28638e7c (diff)
downloadick2-4c089769989460b7bb5e255baaa0e2f5f8ed02ce.tar.gz
Add: icktool make-it-so command
Diffstat (limited to 'icktool')
-rwxr-xr-xicktool20
1 files changed, 20 insertions, 0 deletions
diff --git a/icktool b/icktool
index 9a5976a..b314c58 100755
--- a/icktool
+++ b/icktool
@@ -163,6 +163,22 @@ class Icktool(cliapp.Application):
latest = build
return latest
+ def cmd_make_it_so(self, args):
+ obj = self._read_object()
+
+ projects = self._new_rc('/projects', 'project')
+ self._make_it_so(projects, obj.get('projects', []))
+
+ pipelines = self._new_rc('/pipelines', 'name')
+ self._make_it_so(pipelines, obj.get('pipelines', []))
+
+ def _make_it_so(self, rc, objs):
+ for obj in objs:
+ if projects.exists(obj):
+ projects.update(obj)
+ else:
+ project.create(obj)
+
def cmd_list_projects(self, args):
self._prettyson(self._get_projects())
@@ -506,6 +522,10 @@ class ResourceCommands:
self._report(code, 200, text)
return json.loads(text)
+ def exists(self, obj):
+ code, text = self._api.get(self._id_path(obj[self._name]))
+ return code == 200
+
def delete(self, name):
code, text = self._api.delete(self._id_path(name))
self._report(code, 200, text)