Skip to content

Commit

Permalink
Nil safety check for priority field (#38)
Browse files Browse the repository at this point in the history
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
michaelhtm authored Feb 6, 2025
1 parent 0ae8fa3 commit daefdd2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/resource/rule/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (rm *resourceManager) setRulePriority(
input := &svcsdk.SetRulePrioritiesInput{
RulePriorities: []svcsdktypes.RulePriorityPair{
{
Priority: aws.Int32(int32(*res.ko.Spec.Priority)),
Priority: int32OrNil(res.ko.Spec.Priority),
RuleArn: (*string)(res.ko.Status.ACKResourceMetadata.ARN),
},
},
Expand Down Expand Up @@ -74,3 +74,10 @@ func priorityFromSDK(sdkPriority *string) *int64 {
priorityInt64 := int64(priority)
return &priorityInt64
}

func int32OrNil(val *int64) *int32 {
if val != nil {
return aws.Int32(int32(*val))
}
return nil
}

0 comments on commit daefdd2

Please sign in to comment.