Commit graph

31 commits

Author SHA1 Message Date
Christian Kellner
e2d0f49610 plugin/builder: remove unused to_json method
Since the switch to requests, with its support for dictionary to
json conversion, this method is no longer necessary.
2020-09-19 22:41:26 +02:00
Christian Kellner
1d9612ca05 plugin: pass repos as arrays
Currently we were passing the repo information as a comma
separated string, which is fragile, since urls can contain
commas. Just transfer them as arrays of strings.
2020-09-17 16:33:14 +01:00
Christian Kellner
bae564a1ab plugin/builder: new helper to parse cert strings
The requests cert argument accepts a tuple with the key and the
cert, or one string as a path to a combination of both. Create
a new helper and use that to parse the "ssl_cert" configuration
option as well as the command line option. Change the latter
into a string.
2020-09-17 10:48:37 +02:00
Christian Kellner
9eeb810e3f plugin/builder: use global constant for cfg files
Use a global constant `DEFAULT_CONFIG_FILES` for the default
plugin configuration files. Besides giving it more visibility
it also makes it easier to test, because in the unit test,
this can easily be overwritten.
2020-09-17 10:48:37 +02:00
Christian Kellner
f2d73f018b plugin/builder: return 0 from sub-commands
In the functions that implement the sub-commands (for stand-alone
use), always explicitly return 0, so that main() will always
return an int.
2020-09-17 10:48:37 +02:00
Christian Kellner
db82105eb0 plugin/builder: TLS/SSL support (client side certs)
Add support for client side certificates via a new configuration
option: "ssl_cert", which should be a path to the certificate or
a comma separated list of paths to certificates.
Additionally, the "ssl_verify" option controls how the server
certificate is validated. This can either be a boolean ("True",
"False") or a path to a CA file.
NB: The url for the composer host must contain "https" for the
ssl/tls engine to kick in.

When used as a stand-alone koji API client, two new command
line options are provided, --cert and --ca. See their help
text for a description.
2020-09-17 10:48:37 +02:00
Christian Kellner
790462e967 plugin/builder: sync status enum with upstream
Align our status enums with the one from upstream, i.e. composer's
koji API openAPI spec as of commit 8ccbde8.
2020-09-17 10:48:37 +02:00
Christian Kellner
d4b5cae604 plugin/builder: global constants for default urls
Use a global constant for the composer and kojib hub URLs instead
of defining them in the source twice.
2020-09-17 10:48:37 +02:00
Christian Kellner
a0c562e5c6 fixup! plugin/builder: use requests python package 2020-09-15 18:59:03 +02:00
Christian Kellner
569d53c2d9 plugin/builder: use requests python package
Use the requests python package, which is more convenient to use,
and also supports sessions, where global options, like TLS certs
can be set.
Adapt the container and the spec file to install and require
the python package.
2020-09-15 18:59:03 +02:00
Christian Kellner
c39f1d6d59 plugin/builder: properly raise exceptions
In two cases the exception was merely instantiated but not
actually thrown.
2020-09-14 10:00:56 +02:00
Christian Kellner
e3ce5f7c7b plugin/builder: silence some pylint warnings
The 'koji' parameter for the compose request is called that way to
follow the OpenAPI spec, so silence the "redefined-outer-name"
warning.

The handler function needs have the actual task arguments and thus
on purpose deviates from the argument list of the base class'
handler method. So silence that.
2020-09-11 23:18:04 +01:00
Christian Kellner
6f1d685d9b plugin/builder: move argparse into main
The argparse import is only needed when the plugin is used as a
stand alone composer koji API client, therefore only include it
in main().
2020-09-11 23:18:04 +01:00
Christian Kellner
f7794daa13 plugin/builder: fix indent in cmd line arguments 2020-09-11 23:18:04 +01:00
Christian Kellner
1715558c8f plugin/builder: add more documentation
Describe the plugin itself and how it can be used as a stand-alone
executable.
2020-09-11 23:18:04 +01:00
Christian Kellner
20831a99bb plugin/builder: fix BuildError msg to include name
Fix the error message string to be a proper f-string in the
OSBuildImage.arches_for_config method, so it actually includes
the name of the tag.
2020-09-11 23:18:04 +01:00
Christian Kellner
dda203419c plugin/osbuild: adapt for composer API changes
The task id can and must now be passed to composer via the `koji`
object in the `ComposeRequest`. Do that.
2020-09-09 14:12:25 +02:00
Christian Kellner
8fb1342631 Make image_type and distro required arguments
Distro, in composer terms "distribution", and "image_type" are
required for composer, so make that explicit everywhere in the
code.
2020-09-08 16:13:48 +02:00
Christian Kellner
c5db26596f plugin/builder: nicer errors on compose fail
When creating the compose requests fails, catch it and transform
it into a koji.GenericError, which will avoid showing the full
backtrace in the UI.
2020-09-07 20:35:32 +02:00
Christian Kellner
cb7e4d76c5 plugins/builder: change location of config file
Make the path reflect the name of the package / project.
2020-09-07 18:39:13 +02:00
Christian Kellner
ccf6d60dac plugin/osbuild: simple whitespace changes
No semantic change.
2020-09-07 18:29:22 +02:00
Christian Kellner
3ef4d5e566 plugin/osbuild: make release optional
If release was not in `opts`, use `session.getNextRelease` to
obtain the next release.
2020-09-07 18:23:28 +02:00
Christian Kellner
dbf2960792 plugins/osbuild: sync with composer's koji API
Send the NVR as part of the compose request. The result now also
contains the koji build id. The distro argument is taken from
the options.
2020-09-07 18:15:30 +02:00
Christian Kellner
d31cadd304 plugins/builder: make urls configurable
Can't really hardcode those.
2020-09-06 20:10:59 +02:00
Christian Kellner
f58ecb97ac plugin/builder: support repo overwrites
Allow the repository information to be overwritten by the user
via opts.
2020-09-05 19:28:17 +02:00
Christian Kellner
b9b3680809 plugin/builder: make use of repo information
Don't hard-code the repo info, but get if via the build tag.
2020-09-05 18:54:52 +02:00
Christian Kellner
7fa31ce349 plugins/builder: check for supported arches
Fetch the supported architectures via the target and detect if
any of the requested are not supported.
2020-09-05 18:21:21 +02:00
Christian Kellner
6cdc3e7177 plugin/builder: ability to use as executable
Turn the plugin into an executable.
2020-09-05 17:28:44 +02:00
Christian Kellner
025d3b1902 plugin/builder: create proper composer client
Make a proper client for the osbuild composer koji API and use it.
2020-09-05 17:27:55 +02:00
Christian Kellner
8f41087797 plugins/builder: proof-of-concept compose
Talk to composer and create a compose via a hand crafted compose
request.
2020-09-05 16:33:45 +02:00
Christian Kellner
aefe1218b5 initial import 2020-09-02 19:15:25 +02:00