-
Notifications
You must be signed in to change notification settings - Fork 0
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
Z dependencies installation #19
Conversation
pkg/yamlmanager/yamlmanager.go
Outdated
// Nothing found. Poll after the period. | ||
return false, nil | ||
}); err != nil { | ||
return |
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.
Please don't mix naked returns with regular returns
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.
Agreed to explicitly return the error, so that the readability is better in this case.
func (y *YAMLManager) InstallYAML(fileName, namespace string) (objs []runtime.Object, err error) { | ||
bb, err := ioutil.ReadFile(fileName) | ||
if err != nil { | ||
return |
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.
Maybe consider using regular returns instead of naked returns
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.
In this function we almost always do return objs, err
. To avoid repetition, naked return is preferred.
main.go
Outdated
setupLog.Error(err, "unable to create a new external YAML manager") | ||
os.Exit(1) | ||
} | ||
objs, err := y.InstallYAML("./external.yaml", "example-partition") |
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.
hard coded strings?
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.
The hard-coded string is changed to a global const partitionID
, but in the run wrong, This approach is my proposal.
https://github.com/metal-stack/v?files=1
pkg/yamlmanager/yamlmanager.go
Outdated
|
||
ctx := context.Background() | ||
|
||
// Make sure the namespace `partitionID` exists. |
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.
Comment outdated?
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.
Agreed
}, nil | ||
} | ||
|
||
func (y *YAMLManager) InstallYAML(fileName, namespace string) (objs []runtime.Object, err 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.
fileName
is camelCase, namespace
is not?
Also, fileName has an implicit type?!?
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.
As we discussed, it should be alright to keep it this way.
No description provided.