config: Allow setting default compose type
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ář <lsedlar@redhat.com>
This commit is contained in:
parent
439a7ce348
commit
2e3a9385a3
@ -114,6 +114,13 @@ def main():
|
|||||||
dest="compose_type",
|
dest="compose_type",
|
||||||
help="make a CI compose",
|
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(
|
parser.add_argument(
|
||||||
"--koji-event",
|
"--koji-event",
|
||||||
metavar="ID",
|
metavar="ID",
|
||||||
@ -178,10 +185,6 @@ def main():
|
|||||||
if not os.path.isdir(opts.compose_dir):
|
if not os.path.isdir(opts.compose_dir):
|
||||||
abort("The compose directory does not exist or is not a directory: %s" % 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)
|
opts.config = os.path.abspath(opts.config)
|
||||||
|
|
||||||
create_latest_link = not opts.no_latest_link
|
create_latest_link = not opts.no_latest_link
|
||||||
@ -207,6 +210,10 @@ def main():
|
|||||||
conf = kobo.conf.PyConfigParser()
|
conf = kobo.conf.PyConfigParser()
|
||||||
conf.load_from_file(opts.config)
|
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
|
# check if all requirements are met
|
||||||
import pungi.checks
|
import pungi.checks
|
||||||
if not pungi.checks.check(conf):
|
if not pungi.checks.check(conf):
|
||||||
|
@ -172,6 +172,9 @@ Options
|
|||||||
Please note that when ``dnf`` is used, the build dependencies check is
|
Please note that when ``dnf`` is used, the build dependencies check is
|
||||||
skipped.
|
skipped.
|
||||||
|
|
||||||
|
**compose_type**
|
||||||
|
(*str*) -- Allows to set default compose type. Type set via a command-line
|
||||||
|
option overwrites this.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
|
@ -43,6 +43,7 @@ import platform
|
|||||||
import jsonschema
|
import jsonschema
|
||||||
import re
|
import re
|
||||||
from kobo.shortcuts import force_list
|
from kobo.shortcuts import force_list
|
||||||
|
from productmd.composeinfo import COMPOSE_TYPES
|
||||||
|
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
@ -523,6 +524,11 @@ def make_schema():
|
|||||||
"release_internal": {"type": "boolean", "default": False},
|
"release_internal": {"type": "boolean", "default": False},
|
||||||
"release_discinfo_description": {"type": "string"},
|
"release_discinfo_description": {"type": "string"},
|
||||||
|
|
||||||
|
"compose_type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": COMPOSE_TYPES,
|
||||||
|
},
|
||||||
|
|
||||||
"base_product_name": {"type": "string"},
|
"base_product_name": {"type": "string"},
|
||||||
"base_product_short": {"type": "string"},
|
"base_product_short": {"type": "string"},
|
||||||
"base_product_version": {"type": "string"},
|
"base_product_version": {"type": "string"},
|
||||||
|
Loading…
Reference in New Issue
Block a user