-
Notifications
You must be signed in to change notification settings - Fork 92
Add Config to FlagConfig struct #332
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
base: master
Are you sure you want to change the base?
Add Config to FlagConfig struct #332
Conversation
This allows the Serve-function to be called with out having a config file. This makes the function more easilly callable from other projects. This way configuration is not limited to an existing yaml file but can be specified in the project that is using this package. Signed-off-by: peppi-lotta <[email protected]>
@SuperQ Here's my proposed change to enhance Let me know if this aligns with your vision for the refactor. I'm happy to adjust the implementation in any way if needed. |
@SuperQ can we have some review on this? It would be good to get this one rolling |
return | ||
} | ||
} else { | ||
c = u.config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check that u.config is well-defined? The code later loops over c.HTTPConfig.Header
and accesses c.Users[user]
. getConfig() also sets some defaults here:
exporter-toolkit/web/tls_config.go
Line 117 in 0603156
c := &Config{ |
} | ||
} else { | ||
// Use the provided config. | ||
c = flags.WebConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here,
exporter-toolkit/web/tls_config.go
Line 117 in 0603156
c := &Config{ |
Thanks for the PR! As right now this is either config struct or file based, do we see a use case where an app wants to set certain defaults via the config struct and have the user overwrite it via the file? |
I think the either config or file is fine. We don't need a combo. |
Signed-off-by: peppi-lotta <[email protected]>
@mrueg I have now added a function for validating the config. Could you please take a look and provide a review when you have a chance? |
This refactoring allows the
Serve
function to be called without requiring a YAML configuration file. As a result, the function becomes easier to use from other projects, since configuration is no longer tied to an external YAML file.The change was proposed in PR #7255 to the CoreDNS project. To maintain backward compatibility while enabling this flexibility, I added a
Config
field to theFlagConfig
struct. This approach preserves the existing behavior while allowing external projects to inject configuration directly.