From daefdd2432b6ed5caa3d70daef57546984a265ec Mon Sep 17 00:00:00 2001 From: Michael Tewoldemedhin <98621731+michaelhtm@users.noreply.github.com> Date: Thu, 6 Feb 2025 11:06:53 -0800 Subject: [PATCH] Nil safety check for priority field (#38) By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --- pkg/resource/rule/hooks.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/resource/rule/hooks.go b/pkg/resource/rule/hooks.go index c89128b..c3d7f5f 100644 --- a/pkg/resource/rule/hooks.go +++ b/pkg/resource/rule/hooks.go @@ -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), }, }, @@ -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 +} \ No newline at end of file