Drop support for specifying more than one image type
While it is technically possible to build more than one image type as part of a Koji compose in osbuild-composer, this option is not used in reality and it also makes very little sense. If the user wants to build more than one image type, they should submit multiple Koji builds. Adjust affected unit tests.
This commit is contained in:
parent
dd8233e8b7
commit
c725265081
6 changed files with 39 additions and 45 deletions
|
|
@ -642,7 +642,7 @@ class OSBuildImage(BaseTaskHandler):
|
||||||
self.upload_json(status.as_dict(), "compose-status")
|
self.upload_json(status.as_dict(), "compose-status")
|
||||||
|
|
||||||
# pylint: disable=arguments-differ
|
# pylint: disable=arguments-differ
|
||||||
def handler(self, name, version, distro, image_types, target, arches, opts):
|
def handler(self, name, version, distro, image_type, target, arches, opts):
|
||||||
"""Main entry point for the task"""
|
"""Main entry point for the task"""
|
||||||
self.logger.debug("Building image via osbuild %s, %s, %s, %s",
|
self.logger.debug("Building image via osbuild %s, %s, %s, %s",
|
||||||
name, str(arches), str(target), str(opts))
|
name, str(arches), str(target), str(opts))
|
||||||
|
|
@ -676,9 +676,9 @@ class OSBuildImage(BaseTaskHandler):
|
||||||
if not nvr.release:
|
if not nvr.release:
|
||||||
nvr.release = self.session.getNextRelease(nvr.as_dict())
|
nvr.release = self.session.getNextRelease(nvr.as_dict())
|
||||||
|
|
||||||
# Arches and image types
|
# Arches and image type
|
||||||
image_types = [self.map_koji_api_image_type(i) for i in image_types]
|
image_type = self.map_koji_api_image_type(image_type)
|
||||||
ireqs = [ImageRequest(a, i, repos) for a in arches for i in image_types]
|
ireqs = [ImageRequest(a, image_type, repos) for a in arches]
|
||||||
|
|
||||||
# OStree specific options
|
# OStree specific options
|
||||||
ostree = opts.get("ostree")
|
ostree = opts.get("ostree")
|
||||||
|
|
@ -757,15 +757,13 @@ def show_compose(cs):
|
||||||
def compose_cmd(client: Client, args):
|
def compose_cmd(client: Client, args):
|
||||||
nvr = NVR(args.name, args.version, args.release)
|
nvr = NVR(args.name, args.version, args.release)
|
||||||
images = []
|
images = []
|
||||||
formats = args.format or ["guest-image"]
|
image_type = args.format
|
||||||
formats = [
|
image_type = KOJIAPI_IMAGE_TYPES.get(image_type, image_type)
|
||||||
KOJIAPI_IMAGE_TYPES.get(f, f) for f in formats
|
|
||||||
]
|
|
||||||
repos = [Repository(url) for url in args.repo]
|
repos = [Repository(url) for url in args.repo]
|
||||||
for fmt in formats:
|
|
||||||
for arch in args.arch:
|
for arch in args.arch:
|
||||||
ireq = ImageRequest(arch, fmt, repos)
|
ireq = ImageRequest(arch, image_type, repos)
|
||||||
images.append(ireq)
|
images.append(ireq)
|
||||||
|
|
||||||
kojidata = ComposeRequest.Koji(args.koji, 0, nvr)
|
kojidata = ComposeRequest.Koji(args.koji, 0, nvr)
|
||||||
request = ComposeRequest(args.distro, images, kojidata)
|
request = ComposeRequest(args.distro, images, kojidata)
|
||||||
|
|
@ -820,7 +818,7 @@ def main():
|
||||||
subpar.add_argument("--repo", metavar="REPO", help='The repository to use',
|
subpar.add_argument("--repo", metavar="REPO", help='The repository to use',
|
||||||
type=str, action="append", default=[])
|
type=str, action="append", default=[])
|
||||||
subpar.add_argument("--format", metavar="FORMAT", help='Request the image format [guest-image]',
|
subpar.add_argument("--format", metavar="FORMAT", help='Request the image format [guest-image]',
|
||||||
action="append", type=str, default=[])
|
type=str, default="guest-image")
|
||||||
subpar.add_argument("--koji", metavar="URL", help='The koji url',
|
subpar.add_argument("--koji", metavar="URL", help='The koji url',
|
||||||
default=DEFAULT_KOJIHUB_URL)
|
default=DEFAULT_KOJIHUB_URL)
|
||||||
subpar.set_defaults(cmd='compose')
|
subpar.set_defaults(cmd='compose')
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ def parse_args(argv):
|
||||||
"Maybe be used multiple times"))
|
"Maybe be used multiple times"))
|
||||||
parser.add_option("--image-type", metavar="TYPE",
|
parser.add_option("--image-type", metavar="TYPE",
|
||||||
help='Request an image-type [default: guest-image]',
|
help='Request an image-type [default: guest-image]',
|
||||||
type=str, action="append", default=[])
|
type=str, default="guest-image")
|
||||||
parser.add_option("--skip-tag", action="store_true",
|
parser.add_option("--skip-tag", action="store_true",
|
||||||
help="Do not attempt to tag package")
|
help="Do not attempt to tag package")
|
||||||
parser.add_option("--wait", action="store_true",
|
parser.add_option("--wait", action="store_true",
|
||||||
|
|
@ -107,10 +107,7 @@ def handle_osbuild_image(options, session, argv):
|
||||||
args = parse_args(argv)
|
args = parse_args(argv)
|
||||||
|
|
||||||
name, version, arch, target = args.name, args.version, args.arch, args.target
|
name, version, arch, target = args.name, args.version, args.arch, args.target
|
||||||
distro, image_types = args.distro, args.image_type
|
distro, image_type = args.distro, args.image_type
|
||||||
|
|
||||||
if not image_types:
|
|
||||||
image_types = ["guest-image"]
|
|
||||||
|
|
||||||
opts = {}
|
opts = {}
|
||||||
|
|
||||||
|
|
@ -152,12 +149,12 @@ def handle_osbuild_image(options, session, argv):
|
||||||
print("distro:", distro)
|
print("distro:", distro)
|
||||||
print("arches:", ", ".join(arch))
|
print("arches:", ", ".join(arch))
|
||||||
print("target:", target)
|
print("target:", target)
|
||||||
print("image types ", str(image_types))
|
print("image type:", image_type)
|
||||||
pprint(opts)
|
pprint(opts)
|
||||||
|
|
||||||
kl.activate_session(session, options)
|
kl.activate_session(session, options)
|
||||||
|
|
||||||
task_id = session.osbuildImage(name, version, distro, image_types, target, arch, opts=opts)
|
task_id = session.osbuildImage(name, version, distro, image_type, target, arch, opts=opts)
|
||||||
|
|
||||||
if not options.quiet:
|
if not options.quiet:
|
||||||
print(f"Created task: {task_id}")
|
print(f"Created task: {task_id}")
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,8 @@ OSBUILD_IMAGE_SCHEMA = {
|
||||||
"description": "Distribution"
|
"description": "Distribution"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "array",
|
"type": "string",
|
||||||
"description": "Image Types",
|
"description": "Image Type",
|
||||||
"minItems": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -120,10 +119,10 @@ OSBUILD_IMAGE_SCHEMA = {
|
||||||
|
|
||||||
|
|
||||||
@koji.plugin.export
|
@koji.plugin.export
|
||||||
def osbuildImage(name, version, distro, image_types, target, arches, opts=None, priority=None):
|
def osbuildImage(name, version, distro, image_type, target, arches, opts=None, priority=None):
|
||||||
"""Create an image via osbuild"""
|
"""Create an image via osbuild"""
|
||||||
context.session.assertPerm("image")
|
context.session.assertPerm("image")
|
||||||
args = [name, version, distro, image_types, target, arches, opts]
|
args = [name, version, distro, image_type, target, arches, opts]
|
||||||
task = {"channel": "image"}
|
task = {"channel": "image"}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -644,7 +644,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
handler = self.make_handler()
|
handler = self.make_handler()
|
||||||
|
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
["x86_64"],
|
["x86_64"],
|
||||||
{}]
|
{}]
|
||||||
|
|
@ -667,7 +667,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
arches = ["x86_64", "s390x"]
|
arches = ["x86_64", "s390x"]
|
||||||
repos = ["http://1.repo", "https://2.repo"]
|
repos = ["http://1.repo", "https://2.repo"]
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
arches,
|
arches,
|
||||||
{"repo": repos}]
|
{"repo": repos}]
|
||||||
|
|
@ -713,7 +713,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
handler = self.make_handler(session=session)
|
handler = self.make_handler(session=session)
|
||||||
|
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
["x86_64"],
|
["x86_64"],
|
||||||
{}]
|
{}]
|
||||||
|
|
@ -745,7 +745,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
composer.httpretty_register()
|
composer.httpretty_register()
|
||||||
|
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
composer.architectures,
|
composer.architectures,
|
||||||
{}]
|
{}]
|
||||||
|
|
@ -773,7 +773,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
composer.httpretty_register()
|
composer.httpretty_register()
|
||||||
|
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
composer.architectures,
|
composer.architectures,
|
||||||
{}]
|
{}]
|
||||||
|
|
@ -802,7 +802,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
|
|
||||||
for it in ("qcow2", "ec2", "ec2-ha", "ec2-sap"):
|
for it in ("qcow2", "ec2", "ec2-ha", "ec2-sap"):
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
[it],
|
it,
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
composer.architectures,
|
composer.architectures,
|
||||||
{"skip_tag": True}]
|
{"skip_tag": True}]
|
||||||
|
|
@ -822,7 +822,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
composer.httpretty_register()
|
composer.httpretty_register()
|
||||||
|
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
composer.architectures,
|
composer.architectures,
|
||||||
{"skip_tag": True}]
|
{"skip_tag": True}]
|
||||||
|
|
@ -889,7 +889,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
composer.oauth_activate(token_url)
|
composer.oauth_activate(token_url)
|
||||||
|
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
["x86_64"],
|
["x86_64"],
|
||||||
{}]
|
{}]
|
||||||
|
|
@ -931,7 +931,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
arches = ["x86_64"]
|
arches = ["x86_64"]
|
||||||
repos = ["http://1.repo", "https://2.repo"]
|
repos = ["http://1.repo", "https://2.repo"]
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
arches,
|
arches,
|
||||||
{"repo": repos}]
|
{"repo": repos}]
|
||||||
|
|
@ -980,7 +980,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
arches = ["x86_64"]
|
arches = ["x86_64"]
|
||||||
repos = ["http://1.repo", "https://2.repo"]
|
repos = ["http://1.repo", "https://2.repo"]
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
arches,
|
arches,
|
||||||
{"repo": repos}]
|
{"repo": repos}]
|
||||||
|
|
@ -1058,7 +1058,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
arches = ["x86_64"]
|
arches = ["x86_64"]
|
||||||
repos = ["http://1.repo", "https://2.repo"]
|
repos = ["http://1.repo", "https://2.repo"]
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
arches,
|
arches,
|
||||||
{"repo": repos}]
|
{"repo": repos}]
|
||||||
|
|
@ -1081,7 +1081,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
arches = ["x86_64", "s390x"]
|
arches = ["x86_64", "s390x"]
|
||||||
repos = ["http://1.repo", "https://2.repo"]
|
repos = ["http://1.repo", "https://2.repo"]
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
arches,
|
arches,
|
||||||
{"repo": repos,
|
{"repo": repos,
|
||||||
|
|
@ -1118,7 +1118,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
arches = ["x86_64", "s390x"]
|
arches = ["x86_64", "s390x"]
|
||||||
repos = ["http://1.repo", "https://2.repo"]
|
repos = ["http://1.repo", "https://2.repo"]
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
arches,
|
arches,
|
||||||
{"repo": repos,
|
{"repo": repos,
|
||||||
|
|
@ -1175,7 +1175,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
|
||||||
{"baseurl": "https://third.repo/$arch"}
|
{"baseurl": "https://third.repo/$arch"}
|
||||||
]
|
]
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"fedora-candidate",
|
"fedora-candidate",
|
||||||
arches,
|
arches,
|
||||||
{"repo": repos}]
|
{"repo": repos}]
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class TestCliPlugin(PluginTest):
|
||||||
]
|
]
|
||||||
|
|
||||||
expected_args = ["name", "version", "distro",
|
expected_args = ["name", "version", "distro",
|
||||||
['guest-image'], # the default image type
|
'guest-image', # the default image type
|
||||||
"target",
|
"target",
|
||||||
['arch1']]
|
['arch1']]
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ class TestCliPlugin(PluginTest):
|
||||||
]
|
]
|
||||||
|
|
||||||
expected_args = ["name", "version", "distro",
|
expected_args = ["name", "version", "distro",
|
||||||
['guest-image'], # the default image type
|
'guest-image', # the default image type
|
||||||
"target",
|
"target",
|
||||||
['arch1']]
|
['arch1']]
|
||||||
|
|
||||||
|
|
@ -207,7 +207,7 @@ class TestCliPlugin(PluginTest):
|
||||||
]
|
]
|
||||||
|
|
||||||
expected_args = ["name", "version", "distro",
|
expected_args = ["name", "version", "distro",
|
||||||
['guest-image'], # the default image type
|
'guest-image', # the default image type
|
||||||
"target",
|
"target",
|
||||||
['arch1']]
|
['arch1']]
|
||||||
|
|
||||||
|
|
@ -265,7 +265,7 @@ class TestCliPlugin(PluginTest):
|
||||||
]
|
]
|
||||||
|
|
||||||
expected_args = ["name", "version", "distro",
|
expected_args = ["name", "version", "distro",
|
||||||
['guest-image'], # the default image type
|
'guest-image', # the default image type
|
||||||
"target",
|
"target",
|
||||||
['arch1']]
|
['arch1']]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class TestHubPlugin(PluginTest):
|
||||||
"release": "1.2.3",
|
"release": "1.2.3",
|
||||||
"skip_tag": True}
|
"skip_tag": True}
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
["image_type"],
|
"image_type",
|
||||||
"target",
|
"target",
|
||||||
["arches"],
|
["arches"],
|
||||||
opts]
|
opts]
|
||||||
|
|
@ -66,7 +66,7 @@ class TestHubPlugin(PluginTest):
|
||||||
|
|
||||||
opts = {}
|
opts = {}
|
||||||
args = ["name", "version", "distro",
|
args = ["name", "version", "distro",
|
||||||
"image_type", # image type not an array
|
["image_type"], # image type not an array
|
||||||
"target",
|
"target",
|
||||||
["arches"],
|
["arches"],
|
||||||
opts]
|
opts]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue