From ab852e407a02d802ae0bf332b62bebad0c6fa46a Mon Sep 17 00:00:00 2001 From: Matthieu Huin Date: Fri, 11 Sep 2020 16:11:29 +0200 Subject: [PATCH] Fix integration with Zuul before release * Make default config files location a class attribute * Add missing __init__.py file * Fix incorrect parameter "change_ids" to "changes" in promote * Add release notes to documentation Change-Id: Ifdb6186e09cbc52cbcb1aea56863c25ddec22203 --- doc/source/index.rst | 1 + doc/source/releasenotes.rst | 5 +++++ .../notes/initialize_repo-17cb89d5bb13132c.yaml | 4 ++++ tests/unit/test_api.py | 2 +- tests/unit/test_cmd.py | 2 +- zuulclient/__init__.py | 13 +++++++++++++ zuulclient/api/__init__.py | 2 +- zuulclient/cmd/__init__.py | 1 + zuulclient/common/client.py | 5 ++++- 9 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 doc/source/releasenotes.rst create mode 100644 releasenotes/notes/initialize_repo-17cb89d5bb13132c.yaml create mode 100644 zuulclient/__init__.py diff --git a/doc/source/index.rst b/doc/source/index.rst index dbe9eea..8ba69bd 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -14,3 +14,4 @@ Documentation installation configuration commands + releasenotes diff --git a/doc/source/releasenotes.rst b/doc/source/releasenotes.rst new file mode 100644 index 0000000..0b2e15b --- /dev/null +++ b/doc/source/releasenotes.rst @@ -0,0 +1,5 @@ +Release Notes +============= + +.. release-notes:: + :unreleased-version-title: In Development diff --git a/releasenotes/notes/initialize_repo-17cb89d5bb13132c.yaml b/releasenotes/notes/initialize_repo-17cb89d5bb13132c.yaml new file mode 100644 index 0000000..cc8318a --- /dev/null +++ b/releasenotes/notes/initialize_repo-17cb89d5bb13132c.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Repository initialization. The code is imported from zuul. diff --git a/tests/unit/test_api.py b/tests/unit/test_api.py index 71e9caf..d37e1a8 100644 --- a/tests/unit/test_api.py +++ b/tests/unit/test_api.py @@ -278,7 +278,7 @@ class TestApi(BaseTestCase): prom = client.promote('tenant1', 'check', ['1,1', '2,1']) client.session.post.assert_called_with( 'https://fake.zuul/api/tenant/tenant1/promote', - json={'change_ids': ['1,1', '2,1'], + json={'changes': ['1,1', '2,1'], 'pipeline': 'check'} ) self.assertEqual(True, prom) diff --git a/tests/unit/test_cmd.py b/tests/unit/test_cmd.py index 798e888..766de06 100644 --- a/tests/unit/test_cmd.py +++ b/tests/unit/test_cmd.py @@ -299,7 +299,7 @@ class TestCmd(BaseTestCase): '--changes', '3,3', '4,1', '5,3']) session.post.assert_called_with( 'https://fake.zuul/api/tenant/tenant1/promote', - json={'change_ids': ['3,3', '4,1', '5,3'], + json={'changes': ['3,3', '4,1', '5,3'], 'pipeline': 'gate'} ) self.assertEqual(0, exit_code) diff --git a/zuulclient/__init__.py b/zuulclient/__init__.py new file mode 100644 index 0000000..280e7ee --- /dev/null +++ b/zuulclient/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2020 Red Hat, inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. diff --git a/zuulclient/api/__init__.py b/zuulclient/api/__init__.py index e43e279..c8f1f8e 100644 --- a/zuulclient/api/__init__.py +++ b/zuulclient/api/__init__.py @@ -145,7 +145,7 @@ class ZuulRESTClient(object): if not self.auth_token: raise Exception('Auth Token required') args = {'pipeline': pipeline, - 'change_ids': change_ids} + 'changes': change_ids} url = urllib.parse.urljoin( self.base_url, 'tenant/%s/promote' % tenant) diff --git a/zuulclient/cmd/__init__.py b/zuulclient/cmd/__init__.py index 214fda5..743c18f 100644 --- a/zuulclient/cmd/__init__.py +++ b/zuulclient/cmd/__init__.py @@ -24,6 +24,7 @@ class ZuulClient(CLI): app_name = 'zuul-client' app_description = 'Zuul User CLI' log = logging.getLogger("zuul-client") + default_config_locations = ['~/.zuul.conf'] def createParser(self): parser = super(ZuulClient, self).createParser() diff --git a/zuulclient/common/client.py b/zuulclient/common/client.py index 65c280e..aaebe0c 100644 --- a/zuulclient/common/client.py +++ b/zuulclient/common/client.py @@ -29,6 +29,9 @@ import time class App(object): app_name = None # type: str app_description = None # type: str + default_config_locations = ['/etc/zuul/zuul.conf', + '~/zuul.conf', + '~/.zuul.conf'] def __init__(self): self.args = None @@ -63,7 +66,7 @@ class App(object): if self.args.config: locations = [self.args.config] else: - locations = ['~/.zuul.conf'] + locations = self.default_config_locations for fp in locations: if os.path.exists(os.path.expanduser(fp)): self.config.read(os.path.expanduser(fp))