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
This commit is contained in:
Matthieu Huin 2020-09-11 16:11:29 +02:00
parent 4c4171c54e
commit ab852e407a
9 changed files with 31 additions and 4 deletions

View File

@ -14,3 +14,4 @@ Documentation
installation installation
configuration configuration
commands commands
releasenotes

View File

@ -0,0 +1,5 @@
Release Notes
=============
.. release-notes::
:unreleased-version-title: In Development

View File

@ -0,0 +1,4 @@
---
features:
- |
Repository initialization. The code is imported from zuul.

View File

@ -278,7 +278,7 @@ class TestApi(BaseTestCase):
prom = client.promote('tenant1', 'check', ['1,1', '2,1']) prom = client.promote('tenant1', 'check', ['1,1', '2,1'])
client.session.post.assert_called_with( client.session.post.assert_called_with(
'https://fake.zuul/api/tenant/tenant1/promote', 'https://fake.zuul/api/tenant/tenant1/promote',
json={'change_ids': ['1,1', '2,1'], json={'changes': ['1,1', '2,1'],
'pipeline': 'check'} 'pipeline': 'check'}
) )
self.assertEqual(True, prom) self.assertEqual(True, prom)

View File

@ -299,7 +299,7 @@ class TestCmd(BaseTestCase):
'--changes', '3,3', '4,1', '5,3']) '--changes', '3,3', '4,1', '5,3'])
session.post.assert_called_with( session.post.assert_called_with(
'https://fake.zuul/api/tenant/tenant1/promote', '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'} 'pipeline': 'gate'}
) )
self.assertEqual(0, exit_code) self.assertEqual(0, exit_code)

13
zuulclient/__init__.py Normal file
View File

@ -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.

View File

@ -145,7 +145,7 @@ class ZuulRESTClient(object):
if not self.auth_token: if not self.auth_token:
raise Exception('Auth Token required') raise Exception('Auth Token required')
args = {'pipeline': pipeline, args = {'pipeline': pipeline,
'change_ids': change_ids} 'changes': change_ids}
url = urllib.parse.urljoin( url = urllib.parse.urljoin(
self.base_url, self.base_url,
'tenant/%s/promote' % tenant) 'tenant/%s/promote' % tenant)

View File

@ -24,6 +24,7 @@ class ZuulClient(CLI):
app_name = 'zuul-client' app_name = 'zuul-client'
app_description = 'Zuul User CLI' app_description = 'Zuul User CLI'
log = logging.getLogger("zuul-client") log = logging.getLogger("zuul-client")
default_config_locations = ['~/.zuul.conf']
def createParser(self): def createParser(self):
parser = super(ZuulClient, self).createParser() parser = super(ZuulClient, self).createParser()

View File

@ -29,6 +29,9 @@ import time
class App(object): class App(object):
app_name = None # type: str app_name = None # type: str
app_description = None # type: str app_description = None # type: str
default_config_locations = ['/etc/zuul/zuul.conf',
'~/zuul.conf',
'~/.zuul.conf']
def __init__(self): def __init__(self):
self.args = None self.args = None
@ -63,7 +66,7 @@ class App(object):
if self.args.config: if self.args.config:
locations = [self.args.config] locations = [self.args.config]
else: else:
locations = ['~/.zuul.conf'] locations = self.default_config_locations
for fp in locations: for fp in locations:
if os.path.exists(os.path.expanduser(fp)): if os.path.exists(os.path.expanduser(fp)):
self.config.read(os.path.expanduser(fp)) self.config.read(os.path.expanduser(fp))