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

add nil check of showonly interface value #950

Merged
merged 6 commits into from
Sep 22, 2022
Merged

add nil check of showonly interface value #950

merged 6 commits into from
Sep 22, 2022

Conversation

BBBmau
Copy link
Contributor

@BBBmau BBBmau commented Sep 9, 2022

Description

fix a crash when setting show_only value to an empty string

Fixes #949

Acceptance tests

  • Have you added an acceptance test for the functionality being added?

Release Note

Release note for CHANGELOG:

* Fix show_only crash in helm_template

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Comment on lines 378 to 380
if showFile != nil {
showFiles = append(showFiles, showFile.(string))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Something you could also do here is use the type assertion to test this, as if it's nil then trying to assert it as a string will fail:

if s, ok := showFile.(string); ok {
  showFiles = append(showFiles, s)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This definitely is a much better way to do it. Thanks for the recommendation!

helm/data_template.go Outdated Show resolved Hide resolved
Co-authored-by: Alex Somesan <alex.somesan@gmail.com>
Copy link
Member

@alexsomesan alexsomesan left a comment

Choose a reason for hiding this comment

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

LGTM. Hopefully this does the trick

@github-actions github-actions bot added size/S and removed size/XS labels Sep 22, 2022
@github-actions github-actions bot added size/XS and removed size/S labels Sep 22, 2022
@BBBmau BBBmau merged commit 8eba2e1 into main Sep 22, 2022
@BBBmau BBBmau deleted the fix-showonly-bug branch September 22, 2022 16:43
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when setting show_only to single empty string on helm_template
3 participants