From ffc0cf5a24800d3ccf259c37f6d880da41a6ffe8 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 9 Apr 2018 19:44:05 +0300 Subject: Change: icktool make-it-so updates existing resources --- icktool | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'icktool') 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() -- cgit v1.2.1