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

Only log errors getting credentials to a specific format if all formats fail #140

Merged
merged 1 commit into from
Nov 8, 2021

Conversation

dblanchette
Copy link
Contributor

It's hard to troubleshoot run erros when the log is polluted by errors like:

Error reading as credentials list: yaml: unmarshal errors:\n line 1: cannot unmarshal !!map into []map[string]interface {}"

The way the code is now, these errors are normal: all formats are tried until one works or all fail.

With this change, these errors will only be logged if reading fail for all formats

@dblanchette dblanchette requested review from jocgir and a team November 5, 2021 18:51
@dblanchette dblanchette merged commit 614c45c into master Nov 8, 2021
Copy link
Contributor

@pballandras pballandras left a comment

Choose a reason for hiding this comment

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

:solate: but here's my review

@@ -99,11 +99,23 @@ func getCredentialsFromBytes(byteArray []byte) ([]Credentials, error) {
)

methods := []func(bytes []byte) ([]map[string]interface{}, error){tryReadingList, tryReadingMapOfCredentials, tryReadingSingleCredential}
var success = false
Copy link
Contributor

Choose a reason for hiding this comment

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

The most go-diomatic way to init with a value is the walrus := operator like so

Suggested change
var success = false
success := false

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.

None yet

3 participants