Skip to content
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

Merged
merged 17 commits into from
Dec 9, 2020
Merged

Z dependencies installation #19

merged 17 commits into from
Dec 9, 2020

Conversation

LimKianAn
Copy link
Contributor

No description provided.

// Nothing found. Poll after the period.
return false, nil
}); err != nil {
return
Copy link
Collaborator

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

Copy link
Contributor Author

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
Copy link
Collaborator

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

Copy link
Contributor Author

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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard coded strings?

Copy link
Contributor Author

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


ctx := context.Background()

// Make sure the namespace `partitionID` exists.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment outdated?

Copy link
Contributor Author

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) {
Copy link
Collaborator

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?!?

Copy link
Contributor Author

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.

@LimKianAn LimKianAn merged commit b14a55e into main Dec 9, 2020
@majst01 majst01 deleted the z-dependencies-installation branch December 10, 2020 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants