-
Notifications
You must be signed in to change notification settings - Fork 95
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
Take default support instead of rely on existence of config #211
Take default support instead of rely on existence of config #211
Conversation
Endpoint: s.Endpoint, | ||
ReportEndpoint: s.PullReport.Endpoint, | ||
Impersonate: s.Impersonate, | ||
func (s *Serialized) ToController(cfg *Controller) (*Controller, 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.
Do we need to send the cfg
attribute? We can always create a new Controller
as before or not? Otherwise it looks good.
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.
This is called by Load - so the steps are:
Set default to support.Controller (in code)
Try to load config to support.Controller
And unfortunatelly previously loading was resetting whole support.Controller with what was set in config file, so all the defaults had to be set there. That was ignoring what was already set in support.Controller and creating a new one.
Now, there is an option to not to pass existing Controller and create failback to previous behaviour, but we use the way which passes in the existing support.Controller default values set before.
And there is an option to override the defaults from config. For this there are if len(...)>0 blocks below - if it is set in config file, use it.
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.
Ahh I see. Sorry. I should have read the description.
It seems a really straightforward solution, so just looking at the code it seems OK. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: martinkunc, rluders The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
While loading config, serialized.ToController was supposing that all values will be explicitly set in serialized config (config/local.yaml file), instead of using default values from support.Controller.
This change will use default values, unless they are overwritten by serializable config, or later overwritten by from secrets.
Before this change, loading logic required the PullReport.Delay to be set, which leads to crash on serialized.ToController error with
delay must be a non-negative duration