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

Use getters to avoid verbose nil checking #3407

Merged
merged 2 commits into from
Sep 14, 2021

Conversation

antgamdia
Copy link
Contributor

Description of the change

Follow-up PR based on #3376 (comment)

Benefits

Less verbosity for just building a log msg

Possible drawbacks

N/A

Applicable issues

N/A

Additional information

N/A

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
contextMsg = fmt.Sprintf("(cluster=[%s], namespace=[%s])", request.Context.Cluster, request.Context.Namespace)
}

contextMsg := fmt.Sprintf("(cluster=[%s], namespace=[%s])", request.GetContext().GetCluster(), request.GetContext().GetNamespace())
Copy link
Contributor

Choose a reason for hiding this comment

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

+1. I wondered when I initially saw these why we don't instead use the go fmt built in support for quoting things to do something like:

Suggested change
contextMsg := fmt.Sprintf("(cluster=[%s], namespace=[%s])", request.GetContext().GetCluster(), request.GetContext().GetNamespace())
contextMsg := fmt.Sprintf("(cluster=%q, namespace=%q)", request.GetContext().GetCluster(), request.GetContext().GetNamespace())

But not necessary - just if you agree that'd be nicer (main reason for me is that it's clear that cluster and namespace a string values in the log output, as opposed to being arrays/slices of length 1).

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
@antgamdia
Copy link
Contributor Author

I didn't change anything in the Fluxv2 plugin, since it is under heavy development and I don't want to interfere.
It is using different log messages (likelog.Infof("+fluxv2 GetInstalledPackageSummaries [%v]", request)), which isn't sth bad, but opens the discussion for ulterior issues like #3385

@antgamdia antgamdia merged commit 860a1dc into vmware-tanzu:master Sep 14, 2021
@antgamdia antgamdia deleted the useGetters branch September 14, 2021 11: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