-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
GCE: Handle a nil configuration file #1121
Conversation
return bytes.NewReader(allConfig) | ||
} | ||
} else { | ||
glog.V(2).Infoln("Not using cloudprovider config file") |
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 it expected to work without config?
If not, we should return an error here?
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.
It should "work" without config assuming defaults are sane enough for the user.
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.
optional nit: Update the message to say "No config file provided. Continuing with default values".
Config file not provided is different than not using config file.
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.
Done
} | ||
glog.V(2).Infof("Using cloudprovider config file:\n%v ", string(allConfig)) | ||
|
||
getConfigReader = func() io.Reader { |
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.
Instead of redefining getConfigReader, you can just update the variable that it returns.
configReader := nil
getConfigReader := func() io.Reader { return configReader }
if config != nil {
// Update configReader
}
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.
Not quite that simple. If we went this route, configReader
would need to be reset for each loop iteration.
for {
if config != nil {
configReader = bytes.NewReader(allConfig)
}
...
...
}
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.
aah, got it.
Sorry for missing it the first time
thx, lgtm with an optional log message update suggestion |
bc5881b
to
957a900
Compare
957a900
to
df65973
Compare
Fixes #1112