Repository navigation
Conversation
This commit removes the `DNFConfigStageOptions` from `ImageConfig` in favor of a simpler `DNFConfig` struct. The rational is that `DNFConfigStageOptions` current gets the `osVersion` passed in directly. When we move to a YAML based ImageConfig this will be problematic as we do not have access to variables like this. By making this a declarative option we sidestep the problem.
| func (c *ImageConfig) DNFConfigOptions(osVersion string) []*osbuild.DNFConfigStageOptions { | ||
| if c.DNFConfig == nil { | ||
| return nil | ||
| } | ||
| var res []*osbuild.DNFConfigStageOptions | ||
| if c.DNFConfig.SetReleaseVerVar { | ||
| res = append(res, osbuild.NewDNFConfigStageOptions( | ||
| []osbuild.DNFVariable{ | ||
| { | ||
| Name: "releasever", | ||
| Value: osVersion, | ||
| }, | ||
| }, | ||
| nil, | ||
| )) | ||
| } | ||
| if c.DNFConfig.ForceIPv4 { | ||
| res = append(res, &osbuild.DNFConfigStageOptions{ | ||
| Config: &osbuild.DNFConfig{ | ||
| Main: &osbuild.DNFConfigMain{ | ||
| IPResolve: "4", | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
| return res | ||
| } |
There was a problem hiding this comment.
I'm not sure if I like this approach.
FWIW, I do understand that setting the releasever from the YAML to osVersion would require introducing some magic value that we would need to replace. Which is a can of worms, because then we get into templating the YAML. This solution is simple from that PoV.
What I don't like is that this limits our options in the ImageConfig significantly going forward. My position is that we should keep ImageConfig as powerful as possible, which means keeping the ability to take advantage of the stage options that we have. With this change, we lose the option to define arbitrary variables for DNF easily. Additionally, if we ever add any additional DNF config options, I don't want us to be adding booleans for every possible combination.
I'd like us to use abstracted options only for complex things that would require touching multiple configurations. Or at the minimum, keep our options open and don't reduce what we can define via ImageConfig.
What about a compromise such as:
- Keep the
DNFConfigStageOptionsinImageConfigand expose it in YAML. Set theIPResolvevalue explicitly in the YAML. - Add a
booloption specifically just forSetReleaseVerVarand in such case, set thereleasevertoosVersionin the DNFConfigStageOptions (potentially combining it with values and other variables set in the YAML). I understand that there is still the corner case of someone definingreleaseverin the YAML as well as setting thebooloption, but that could be an error.
There was a problem hiding this comment.
Thanks, I opened #1465 with this alternative approach.
| Variables: []osbuild.DNFVariable{ | ||
| { | ||
| Name: "releasever", | ||
| Value: "centos-9", |
There was a problem hiding this comment.
Nitpick: I know that these are just unit tests, but the releasever is ever set only to X.Y in RHEL images (and for centos it is X-stream). This mechanism allows you to pin the host repositories to a specific Extended Update Support (EUS) version of RHEL. Using centos-9 may give one the wrong impression of its purpose.
There was a problem hiding this comment.
Thanks, fixed in the other PR
| } | ||
| } | ||
|
|
||
| func TestImageConfiDNCConfigNone(t *testing.T) { |
There was a problem hiding this comment.
| func TestImageConfiDNCConfigNone(t *testing.T) { | |
| func TestImageConfigDNFConfigNone(t *testing.T) { |
AI found a double-typo here. :)
|
Closing in favor of #1465 |
This commit removes the
DNFConfigStageOptionsfromImageConfigin favor of a simplerDNFConfigstruct.The rational is that
DNFConfigStageOptionscurrent gets theosVersionpassed in directly. When we move to a YAML based ImageConfig this will be problematic as we do not have access to variables like this. By making this a declarative option we sidestep the problem.This generates no manifest diff.
Needed for #1462