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

Changed log.info to tidy up using fmt.sprintf #2246

Merged
merged 19 commits into from
Dec 9, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pkg/ansible/watches/watches.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ func getMaxWorkers(gvk schema.GroupVersionKind, defValue int) int {
maxWorkers, err := strconv.Atoi(os.Getenv(envVar))
if err != nil {
// we don't care why we couldn't parse it just use default
log.Info("Failed to parse %v from environment. Using default %v", envVar, defValue)
//log.Info("Failed to parse %v from environment. Using default %v", envVar, defValue)
Copy link
Member

Choose a reason for hiding this comment

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

No need to keep this line around anymore.

Ditto for ansibleVerbosity.

log.Info(fmt.Sprintf("Using default value for workers %d", defValue))
return defValue
}

Expand All @@ -297,7 +298,9 @@ func getAnsibleVerbosity(gvk schema.GroupVersionKind, defValue int) int {
))
ansibleVerbosity, err := strconv.Atoi(os.Getenv(envVar))
Copy link
Member

Choose a reason for hiding this comment

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

I think we should use the same logic for the ansible verbosity operator.

Since the logic is identical, I think it would make sense to define a new function with this signature:

func getIntegerEnvWithDefault(envVar string, defValue int) int

The call it for both maxWorkers and ansibleVerbosity.

if err != nil {
log.Info("Failed to parse %v from environment. Using default %v", envVar, defValue)
//log.Info("Failed to parse %v from environment. Using default %v", envVar, defValue)
log.Info(fmt.Sprintf("Using default value for ansible verbosity %d", defValue))

Copy link
Member

Choose a reason for hiding this comment

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

Nit: this extraneous empty line can be removed.

return defValue
}

Expand Down