From 2e3a9385a39861f646bf80cad9a1ecb5fa9335d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 25 Aug 2017 10:07:33 +0200 Subject: [PATCH] config: Allow setting default compose type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The config can change the default compose type. This can still be overwritten by a CLI argument. A `--production` option is now added to CLI (because that was the default before). Fixes: https://pagure.io/pungi/issue/694 Signed-off-by: Lubomír Sedlář --- bin/pungi-koji | 15 +++++++++++---- doc/configuration.rst | 3 +++ pungi/checks.py | 6 ++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bin/pungi-koji b/bin/pungi-koji index 03eb2093..07137dd5 100755 --- a/bin/pungi-koji +++ b/bin/pungi-koji @@ -114,6 +114,13 @@ def main(): dest="compose_type", help="make a CI compose", ) + parser.add_argument( + "--production", + action="store_const", + const="production", + dest="compose_type", + help="make production compose (default unless config specifies otherwise)", + ) parser.add_argument( "--koji-event", metavar="ID", @@ -178,10 +185,6 @@ def main(): if not os.path.isdir(opts.compose_dir): abort("The compose directory does not exist or is not a directory: %s" % opts.compose_dir) - compose_type = opts.compose_type or "production" - if compose_type == "production" and not opts.label and not opts.no_label: - abort("must specify label for a production compose") - opts.config = os.path.abspath(opts.config) create_latest_link = not opts.no_latest_link @@ -207,6 +210,10 @@ def main(): conf = kobo.conf.PyConfigParser() conf.load_from_file(opts.config) + compose_type = opts.compose_type or conf.get('compose_type', 'production') + if compose_type == "production" and not opts.label and not opts.no_label: + abort("must specify label for a production compose") + # check if all requirements are met import pungi.checks if not pungi.checks.check(conf): diff --git a/doc/configuration.rst b/doc/configuration.rst index fc74b067..97bbe146 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -172,6 +172,9 @@ Options Please note that when ``dnf`` is used, the build dependencies check is skipped. +**compose_type** + (*str*) -- Allows to set default compose type. Type set via a command-line + option overwrites this. Example ------- diff --git a/pungi/checks.py b/pungi/checks.py index d75929f0..9563f171 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -43,6 +43,7 @@ import platform import jsonschema import re from kobo.shortcuts import force_list +from productmd.composeinfo import COMPOSE_TYPES from . import util @@ -523,6 +524,11 @@ def make_schema(): "release_internal": {"type": "boolean", "default": False}, "release_discinfo_description": {"type": "string"}, + "compose_type": { + "type": "string", + "enum": COMPOSE_TYPES, + }, + "base_product_name": {"type": "string"}, "base_product_short": {"type": "string"}, "base_product_version": {"type": "string"},