gotohelm: fix map indexing and zeroOf #359
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
66671ba gotohelm: correct map indexing for non-nil zero values
Prior to this commit all map indexing operations in helm world would return
nil
thanks toindex
's behavior under the hood. This worked for 70% of allcases as the zero value of most map elements was zero. However, non-nil zero
values would be handled incorrectly:
This commit updates the transpiler to appropriately detect such cases and
injects the zero value of the map's element type.
e6cc8bc gotohelm: improve special case detection in zeroOf
Prior to this commit gotohelm would incorrectly attempt to compute the zero
value of types that implemented
json.{Unm,M}arshaller
. In most cases, thiswould lead to a transpiler crash all together. In some corner cases, it was
possible to silently generate incorrect values.
This commit improves
zeroOf
to detect and reject implementers ofjson.{Unm,M}arshaller
with a helpful error message and adds a special casefor Kubernetes'
resource.Quantity
type.