-
Notifications
You must be signed in to change notification settings - Fork 511
[chore] make Config a struct with config fields, but no logic #3958
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: main
Are you sure you want to change the base?
Conversation
4b82974
to
2c00d6a
Compare
…the logic out to autodetect
2c00d6a
to
8f1ac44
Compare
@@ -185,3 +187,45 @@ func (a *autoDetect) TargetAllocatorAvailability() (targetallocator.Availability | |||
func (a *autoDetect) FIPSEnabled(_ context.Context) bool { | |||
return fips.IsFipsEnabled() | |||
} | |||
|
|||
// ApplyAutoDetect attempts to automatically detect relevant information for this operator. | |||
func ApplyAutoDetect(autoDetect AutoDetect, c *config.Config, logger logr.Logger) error { |
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.
Is there any reason not to make this a method on AutoDetect
?
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.
+1
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.
Yes, though this is a more impactful change since we need all mocks to implement it. That might also change the way the interface works.
@@ -185,3 +187,45 @@ func (a *autoDetect) TargetAllocatorAvailability() (targetallocator.Availability | |||
func (a *autoDetect) FIPSEnabled(_ context.Context) bool { | |||
return fips.IsFipsEnabled() | |||
} | |||
|
|||
// ApplyAutoDetect attempts to automatically detect relevant information for this operator. | |||
func ApplyAutoDetect(autoDetect AutoDetect, c *config.Config, logger logr.Logger) error { |
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.
+1
func ApplyAutoDetect(autoDetect AutoDetect, c *config.Config, logger logr.Logger) error { | ||
logger.V(2).Info("auto-detecting the configuration based on the environment") | ||
|
||
ora, err := autoDetect.OpenShiftRoutesAvailability() |
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.
I'm wondering if we should make this use something like the options pattern for when we instantiate the auto detect resource that we can just pass a list of options for the auto detect struct.
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.
I don't quite understand why we use Options, these are internal structs with no external APIs. Do we have to watch for something in particular?
By moving the logic out of Config, we make its lifecycle simple as a struct. We can then start to simplify how it is initialized and load it from a file, CLI flags, env vars and so on.