Skip to content

Commit 56ddcaa

Browse files
supakeenachilleas-k
authored andcommitted
main: provide --preview to toggle preview state
Certain image types have the notion of being in a preview state. Also called "final", "supported", or "prerelease". In `images`'s distribution definitions we define this flag per version of a distribution. This means that we need to quickly do releases to update this value before a release candidate is built (release candidates are built as "supported"). When pungi schedules composes it knows the supported state of the compose. Thus it is a good idea to let the preview state of a distro be overridden by the `pungi` -> `koji` -> `image-builder` chain. Let's include a `--preview` argument. When the option is not passed at all we let `images` determine the preview state (based on its distribution definitions). When the option is passed we pass along its value to `images` where it is then used instead of the default. I've kept the option hidden here because it really only should be used by build systems or advanced users (we might document its use) and not confuse normal users; who would usually receive new distribution definitions with the next `image-builder` release which contain the correct preview state, though it will lag a bit in time. Signed-off-by: Simon de Vlieger <cmdr@supakeen.com>
1 parent cf20ed6 commit 56ddcaa

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

cmd/image-builder/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ func cmdManifestWrapper(pbar progress.ProgressBar, cmd *cobra.Command, args []st
197197
if err != nil {
198198
return nil, err
199199
}
200+
var preview *bool
201+
// Verify that the flag was actually passed. If it wasn't passed
202+
// we keep our nil value so that images used the distro-defined
203+
// value for preview. Otherwise use the provided value so the
204+
// distro value gets overridden.
205+
if cmd.Flags().Lookup("preview").Changed {
206+
value, err := cmd.Flags().GetBool("preview")
207+
if err != nil {
208+
return nil, err
209+
}
210+
preview = &value
211+
}
200212
var rpmDownloader osbuild.RpmDownloader
201213
if useLibrepo {
202214
rpmDownloader = osbuild.RpmDownloaderLibrepo
@@ -324,6 +336,7 @@ func cmdManifestWrapper(pbar progress.ProgressBar, cmd *cobra.Command, args []st
324336
WithSBOM: withSBOM,
325337
IgnoreWarnings: ignoreWarnings,
326338
Subscription: subscription,
339+
Preview: preview,
327340

328341
ForceRepos: forceRepos,
329342
}
@@ -588,6 +601,8 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support.
588601
manifestCmd.Flags().Bool("ignore-warnings", false, `ignore warnings during manifest generation`)
589602
manifestCmd.Flags().String("registrations", "", `filename of a registrations file with e.g. subscription details`)
590603
manifestCmd.Flags().String("rpmmd-cache", "", `osbuild directory to cache rpm metadata`)
604+
manifestCmd.Flags().Bool("preview", true, `override distro default preview state if passed`)
605+
manifestCmd.Flags().MarkHidden("preview")
591606
rootCmd.AddCommand(manifestCmd)
592607

593608
uploadCmd := &cobra.Command{

cmd/image-builder/manifest.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type manifestOptions struct {
3434
RpmDownloader osbuild.RpmDownloader
3535
WithSBOM bool
3636
IgnoreWarnings bool
37+
Preview *bool
3738

3839
ForceRepos []string
3940
}
@@ -98,6 +99,7 @@ func generateManifest(repoDir string, extraRepos []string, img *imagefilter.Resu
9899
Bootc: &distro.BootcImageOptions{
99100
InstallerPayloadRef: opts.BootcInstallerPayloadRef,
100101
},
102+
Preview: opts.Preview,
101103
}
102104

103105
mf, err := mg.Generate(bp, img.ImgType, imgOpts)

0 commit comments

Comments
 (0)