Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: expose FlagSet #2959

Merged
merged 3 commits into from
Mar 1, 2024

Conversation

wndhydrnt
Copy link
Contributor

We are using skipper as a library. Configuration for custom code, like filters, gets passed in via command-line flags.

This worked well until #2248 got merged, which switched to a flag.FlagSet to manage configuration. Now, starting Skipper and passing in custom flags fails with the error flag provided but not defined.

This change adds a method that makes the FlagSet accessible from outside. It allows users to add custom flags to the `FlagSet.

Signed-off-by: Markus Meyer <[email protected]>
@wndhydrnt wndhydrnt force-pushed the expose-config-flagset branch from b1d638f to 05ec684 Compare February 27, 2024 14:25
@szuecs szuecs added the bugfix Bug fixes and patches label Feb 27, 2024
config/config.go Outdated Show resolved Hide resolved
Signed-off-by: Markus Meyer <[email protected]>
@wndhydrnt wndhydrnt force-pushed the expose-config-flagset branch from 2bfbcb4 to 4f4ae0c Compare February 28, 2024 06:25
@szuecs
Copy link
Member

szuecs commented Feb 28, 2024

👍

@szuecs
Copy link
Member

szuecs commented Feb 28, 2024

Tests need also a change to set or use the member as far as I see go actions output

Signed-off-by: Markus Meyer <[email protected]>
@@ -336,8 +336,8 @@ func Test_NewConfigWithArgs(t *testing.T) {
}

if !tt.wantErr {
if cmp.Equal(cfg, tt.want, cmp.AllowUnexported(listFlag{}, pluginFlag{}, defaultFiltersFlags{}, mapFlags{}), cmpopts.IgnoreUnexported(Config{})) == false {
t.Errorf("config.NewConfig() got vs. want:\n%v", cmp.Diff(cfg, tt.want, cmp.AllowUnexported(listFlag{}, pluginFlag{}, defaultFiltersFlags{}, mapFlags{}), cmpopts.IgnoreUnexported(Config{})))
if cmp.Equal(cfg, tt.want, cmp.AllowUnexported(listFlag{}, pluginFlag{}, defaultFiltersFlags{}, mapFlags{}), cmpopts.IgnoreUnexported(Config{}), cmpopts.IgnoreFields(Config{}, "Flags")) == false {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szuecs The failing test has been addressed. Before this PR, the value of Config.flags was not considered for comparison during these tests because of cmpopts.IgnoreUnexported(Config{}). Added cmpopts.IgnoreFields(Config{}, "Flags") to re-create the behavior of ignoring the field.

@AlexanderYastrebov
Copy link
Member

👍

@AlexanderYastrebov
Copy link
Member

Thank you!

@MustafaSaber
Copy link
Member

👍

@MustafaSaber MustafaSaber merged commit a8416c4 into zalando:master Mar 1, 2024
10 checks passed
@wndhydrnt wndhydrnt deleted the expose-config-flagset branch March 1, 2024 12:38
@wndhydrnt
Copy link
Contributor Author

Thanks for the reviews and the merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bug fixes and patches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants