diff options
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) |