summaryrefslogtreecommitdiff
path: root/icktool
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-04-09 19:44:05 +0300
committerLars Wirzenius <liw@liw.fi>2018-04-09 19:44:05 +0300
commitffc0cf5a24800d3ccf259c37f6d880da41a6ffe8 (patch)
treedabc9458c496eaf9dc9a47f4dbd83337a1616986 /icktool
parente9fa2085be5a6fa7a56cea506680041aea6ceb07 (diff)
downloadick2-ffc0cf5a24800d3ccf259c37f6d880da41a6ffe8.tar.gz
Change: icktool make-it-so updates existing resources
Diffstat (limited to 'icktool')
-rwxr-xr-xicktool15
1 files changed, 11 insertions, 4 deletions
diff --git a/icktool b/icktool
index 79fcb48..5b073ac 100755
--- a/icktool
+++ b/icktool
@@ -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()