Skip to content

Parse configuration into typed options structs - #373

Open
fwiesel wants to merge 2 commits into
mainfrom
config/go-flagsfiller
Open

fwiesel wants to merge 2 commits into
mainfrom
config/go-flagsfiller

Conversation

@fwiesel

@fwiesel fwiesel commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Parse the operator configuration into module-owned options structs filled by
go-flagsfiller, so introducing a
parameter only touches the options struct and the chart's env values: the
flag and environment binding hook up automatically, --help documents them,
and invalid values fail once at startup. The chart drops the
--flag=$(ENV_VAR) arguments in a separate, revertable commit.

Existing tests are updated for the option wiring; no new tests.

Relates to #13.

@fwiesel
fwiesel force-pushed the config/go-flagsfiller branch 14 times, most recently from ade7f84 to 46838da Compare October 30, 2026 09:36
@fwiesel
fwiesel marked this pull request as ready for review October 30, 2026 09:44
@fwiesel
fwiesel requested a review from notandy October 30, 2026 09:47
@notandy

notandy commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

how emotionally attached are you to itzg/go-flagsfiller? I never heard of it before, hasn't been updated for 3 months and is not used by any other of our SCI projects.
I am fine to overhaul the flag parsing and modulize it, but let's use something all other projects are using, I think spf13/cobra is most common within sci: https://github.com/search?q=org%3Asapcc+spf13%2Fcobra&type=code - it supports modules by default.

@fwiesel

fwiesel commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

I only stumbled over it through the tool. It looked just like the smallest change.
AFAIK; spf13/cobra is just a quite a beast. Let me give it a try.

@notandy

notandy commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

I only stumbled over it through the tool. It looked just like the smallest change. AFAIK; spf13/cobra is just a quite a beast. Let me give it a try.

it is, that's true, but it's widely adopted and regularly updated. Also this is a beast of a PR :)

Fill the operator settings from module-owned options structs via
go-flagsfiller, so introducing a parameter only touches the options
struct and the chart's env values: the flag and the environment
binding hook up automatically. Keep the command-line flags so users
can inspect the options.

Signed-off-by: Fabian Wiesel <[email protected]>
The manager reads its settings from the environment, so drop the
--flag=$(ENV_VAR) container arguments.

Signed-off-by: Fabian Wiesel <[email protected]>
@fwiesel
fwiesel force-pushed the config/go-flagsfiller branch from 46838da to 5195e67 Compare October 31, 2026 09:49
@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/config 0.00% (ø)
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller 74.26% (-0.51%) 👎
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/eviction 65.55% (-2.33%) 👎
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/global 0.00% (-100.00%) 💀 💀 💀 💀 💀
Coverage details

Compared to commit f5172c4 (run #41086905849)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/cmd/main.go 0.00% (ø) 0 0 0
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/config/options.go 0.00% (ø) 10 (+10) 0 10 (+10)
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/eviction/controller.go 67.53% (-0.35%) 194 (+1) 131 63 (+1) 👎
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/eviction/options.go 40.00% (+40.00%) 15 (+15) 6 (+6) 9 (+9) 🌟
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/hypervisor_controller.go 79.34% (-0.66%) 121 (+1) 96 25 (+1) 👎
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/node_certificate_controller.go 80.95% (ø) 42 34 8
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/options.go 0.00% (ø) 5 (+5) 0 5 (+5)
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/global/global.go 0.00% (-100.00%) 0 (-7) 0 (-7) 0 💀 💀 💀 💀 💀

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files:

  • github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/eviction/controller_test.go
  • github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/hypervisor_controller_test.go
  • github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/global/global_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants