diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-04-09 19:44:05 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-04-09 19:44:05 +0300 |
commit | ffc0cf5a24800d3ccf259c37f6d880da41a6ffe8 (patch) | |
tree | dabc9458c496eaf9dc9a47f4dbd83337a1616986 /icktool | |
parent | e9fa2085be5a6fa7a56cea506680041aea6ceb07 (diff) | |
download | ick2-ffc0cf5a24800d3ccf259c37f6d880da41a6ffe8.tar.gz |
Change: icktool make-it-so updates existing resources
Diffstat (limited to 'icktool')
-rwxr-xr-x | icktool | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -142,15 +142,22 @@ class Icktool(cliapp.Application): api = self._new_api() api.set_token(token) - self._create_resources(api, '/projects', obj.get('projects', [])) - self._create_resources(api, '/pipelines', obj.get('pipelines', [])) + self._create_resources( + api, '/projects', 'project', obj.get('projects', [])) + self._create_resources( + api, '/pipelines', 'pipeline', obj.get('pipelines', [])) def _read_object(self): return yaml.load(sys.stdin) - def _create_resources(self, api, path, objs): + def _create_resources(self, api, path, field, objs): for obj in objs: - api.create(path, obj) + try: + api.create(path, obj) + except ick2.HttpError: + if field in obj: + obj_path = '{}/{}'.format(path, obj[field]) + api.update(path, obj) def cmd_show(self, args): token = self._new_token() |