diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-01-13 15:36:05 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-01-14 22:23:49 +0200 |
commit | 4c089769989460b7bb5e255baaa0e2f5f8ed02ce (patch) | |
tree | 890efb42b9ce6aff3b91388edde83b1fea192f12 /icktool | |
parent | eaf8f8bc1957079f5a4009074d8bd81e28638e7c (diff) | |
download | ick2-4c089769989460b7bb5e255baaa0e2f5f8ed02ce.tar.gz |
Add: icktool make-it-so command
Diffstat (limited to 'icktool')
-rwxr-xr-x | icktool | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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) |