Repository navigation
New subcommand: image-builder prefetch [HMS-11467] - #2792
Conversation
The 'cache' option maps directly to osbuild's 'cache' / 'store' option. Use the same description in image-builder that we have in osbuild, only prefix it with 'osbuild' to make it clear this is an option that's passed through to osbuild itself.
8854334 to
ab3410a
Compare
|
I'm still not entirely happy with the way we define our subcommands and their flags. There's some non-trivial interactions between arguments that we haven't fully mapped out yet and are difficult to trace the way they're written now. Ideally, we would centralise argument handling so we can clearly define, for example, how the progress, verbose, and format options interact. |
ab3410a to
e18386a
Compare
Add dedicated functions for specific flagsets and flags that are shared
among subcommands. The new function takes any cobra.Command and adds a
set of flags to it.
Flag sharing becomes more explicit here. For the 'build' subcommand,
instead of directly inheriting the flags from 'manifest' and 'upload',
it reuses the same functions those two subcommands use to define their
flag set. For flagsets, the benefits are small: It allows us to add a
flag to 'manifest' or 'upload' without it being immediately inherited by
'build' if we need to. For single flags that are shared between
subcommands ('rpmmd-cache' and, soon, 'cache') it makes it easier to
share the definition and help text.
e18386a to
e6fafd9
Compare
Add new subcommand for pre-fetching sources defined in a manifest, preparing the osbuild source cache for a fully offline, hermetic build.
e6fafd9 to
09cd115
Compare
Test the new command using only a mocked osbuild binary that saves the command line args for verification.
The flag isn't moved to its own function like we did with the other ones because the description differs for each subcommand (valid values).
09cd115 to
369bfe9
Compare
|
I'm open to suggestions for a better name for the command, btw. |
brlane-rht
left a comment
There was a problem hiding this comment.
Looks ok, although I'm not sure of the use case. When would you have a manifest you wanted to prefetch without actually running the build?
Hermetic build systems (like Konflux) want to do the networking separately from the build. As for the name (because the code seems mostly fine anyhow); This kinda depends on how many steps we'll have and how the 'use prefetch' is going to be codified; if it's just going to be an argument on Correct me if I'm wrong but we're going to have something like:
Or such? I think knowing the other steps is probably a good way to figure out if |
Or maybe |
This is what I was thinking, yes, though But maybe we should examine all possibilities before merging here. There are a lot of other options here. For example, we could avoid new subcommands entirely:
or as Brian suggested, the prefetch can be part of the manifest subcommand. The other extreme is adding new subcommands for everything (I don't like this):
My plan when writing this was what you suggested. The next step would be to add a |
I think it's important that we use the manifest to connect all three operations, otherwise there will always be a risk, however small, that the build call will produce a manifest with slightly different packages (for example, if a repository update happens between prefetch and build). |
So then a new question is, do we even need to add this to image-builder? We're basically passing it through to osbuild already so instead add a fetch-only command to osbuild and pass it the manifest, and document that for users. |
Normally I would agree but the main reason for this is integrating with Konflux and giving that tool the ability to break down the steps so it can control the environment for each (generate manifest with network access, fetch sources with network access, do the build without). We want to provide a nice interface for that build system to do all these through image-builder directly, even if those things are pretty much straight passthrough to osbuild itself. It lets use control the flow better, like reusing default paths or command line options. It also means that users (human or otherwise) get the same control of output, whether that's a progress bar, direct output from osbuild, or a json response. |
|
While |
Add new subcommand for pre-fetching sources defined in a manifest, preparing the osbuild source cache for a fully offline, hermetic build.
Tests mock the osbuild binary by overwriting the
$PATHenv, instead of modifying the command itself like we do in other places. The tests check that the arguments passed toosbuildare the expected ones for the subcommand.I opened #2791 because I think we have too much code for mocking such things in slightly different ways.