From: Aric Gardner Date: Tue, 6 Aug 2019 17:32:42 +0000 (-0400) Subject: Support multiple nexus sections in lftools.ini X-Git-Tag: v0.25.5^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=bfc3096e4d6664739dc47faa7d7a62a8fcf8c0c2;p=releng%2Flftools.git Support multiple nexus sections in lftools.ini [nexus] section is taken from -s "server" passed to release job. The "https://" part of passed url is stripped before match. example: lftools nexus release -s https://nexus.example.com Would require auth section in lftools.ini of [nexus.example.org] username= password= Issue: RELENG-2129 Issue: RELENG-1666 Change-Id: I64ab0a18a4d0e9060f1273f5acc1971fcffe497c Signed-off-by: Aric Gardner Signed-off-by: Anil Belur --- diff --git a/docs/commands/nexus.rst b/docs/commands/nexus.rst index 0df01963..cd8ecf65 100644 --- a/docs/commands/nexus.rst +++ b/docs/commands/nexus.rst @@ -70,3 +70,16 @@ release ------- .. program-output:: lftools nexus release --help + +While a settings.yaml file is still supported for ``nexus release`` commands, +the preferred way to login is to use an lftools.ini file, and provide the +server address using the ``--server`` option. The config file should be at +$HOME/.config/lftools/lftools.ini. +Requires an [nexus.example.com] for each Nexus repositories in +~/.config/lftools/lftools.ini: + +.. code-block:: bash + + [nexus.example.com] + username= + password= diff --git a/docs/conf.py b/docs/conf.py index 6e160e4c..b61dc987 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -32,4 +32,5 @@ release = str(VersionInfo('lftools')) # Linkcheck Options linkcheck_ignore= [ r'https://testing\.googleblog\.com/.*', + r'https://nexus\.example\.com', ] diff --git a/lftools/nexus/cmd.py b/lftools/nexus/cmd.py index 0424ce27..9bc043ba 100644 --- a/lftools/nexus/cmd.py +++ b/lftools/nexus/cmd.py @@ -42,8 +42,9 @@ def get_credentials(settings_file, url=None): return settings elif url: try: - user = config.get_setting("nexus", "username") - password = config.get_setting("nexus", "password") + auth_url = url.replace("https://", "") + user = config.get_setting(auth_url, "username") + password = config.get_setting(auth_url, "password") except (configparser.NoOptionError, configparser.NoSectionError): log.info("Failed to get nexus credentials; using empty username " diff --git a/releasenotes/notes/nexus-release-60333ea8c6deb068.yaml b/releasenotes/notes/nexus-release-60333ea8c6deb068.yaml new file mode 100644 index 00000000..7b076935 --- /dev/null +++ b/releasenotes/notes/nexus-release-60333ea8c6deb068.yaml @@ -0,0 +1,29 @@ +--- +features: + - | + Support multiple nexus sections in lftools.ini + + In the format: + + .. code-block:: none + + [nexus.example.org] + username= + password= + + [nexus.example1.org] + username= + password= + + [nexus] section is taken from -s "server" passed to release job. + https part of passed url is stripped before match. +upgrade: + - | + current [nexus] section of lftools.ini must be changed to + [nexus.example.com] + + where nexus.example.com matches the "server" string passed to + lftools nexus release -s https://nexus.example.com + The https part of passed url is stripped before match. + example provided would require auth section in lftools.ini of + [nexus.example.org]