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

Initialize nil maps before setting key #67

Merged
merged 1 commit into from
Aug 31, 2022
Merged

Initialize nil maps before setting key #67

merged 1 commit into from
Aug 31, 2022

Conversation

scothis
Copy link
Collaborator

@scothis scothis commented Aug 31, 2022

Previously, about half of the Add*() methods that set a value in a map
checked if the map was nil before setting a field. Now they all do.

Resolves #66

Signed-off-by: Scott Andrews scott@andrews.me

Previously, about half of the `Add*()` methods that set a value in a map
checked if the map was nil before setting a field. Now they all do.

Signed-off-by: Scott Andrews <scott@andrews.me>
@scothis
Copy link
Collaborator Author

scothis commented Aug 31, 2022

cc @mamachanko

@codecov
Copy link

codecov bot commented Aug 31, 2022

Codecov Report

Merging #67 (cebc5ed) into main (04e5dfa) will decrease coverage by 0.12%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main      #67      +/-   ##
==========================================
- Coverage   10.58%   10.45%   -0.13%     
==========================================
  Files          64       64              
  Lines        3024     3060      +36     
==========================================
  Hits          320      320              
- Misses       2702     2738      +36     
  Partials        2        2              
Impacted Files Coverage Δ
apis/core/v1/container.go 0.00% <0.00%> (ø)
apis/core/v1/limitrange.go 0.00% <0.00%> (ø)
apis/core/v1/node.go 0.00% <0.00%> (ø)
apis/core/v1/persistantvolume.go 0.00% <0.00%> (ø)
apis/core/v1/persistantvolumeclaim.go 0.00% <0.00%> (ø)
apis/core/v1/pod.go 26.77% <0.00%> (-0.30%) ⬇️
apis/core/v1/resourcequota.go 0.00% <0.00%> (ø)
apis/core/v1/service.go 0.00% <0.00%> (ø)
apis/node/v1/runtimeclass.go 0.00% <0.00%> (ø)
... and 8 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Collaborator

@mamachanko mamachanko left a comment

Choose a reason for hiding this comment

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

LGTM! Checks out with our code.

@@ -41,6 +41,9 @@ type _ = corev1.LimitRangeItem

func (d *LimitRangeItemDie) AddMax(name corev1.ResourceName, quantity resource.Quantity) *LimitRangeItemDie {
return d.DieStamp(func(r *corev1.LimitRangeItem) {
if r.Max == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I approve this change in particular.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

All of them !

@scothis scothis merged commit 75655a9 into main Aug 31, 2022
@scothis scothis deleted the nil-map-check branch August 31, 2022 14:56
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.

AddLimit/Request panics with assignment in nil map
2 participants