Skip to content

Commit

Permalink
fix: nil pointer error
Browse files Browse the repository at this point in the history
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
  • Loading branch information
zhaohuabing committed Jan 3, 2025
1 parent f71fa99 commit 4bce7b9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/gatewayapi/securitypolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,10 +962,16 @@ func backendRefAuthority(resources *resource.Resources, backendRef *gwapiv1.Back
}
}

return net.JoinHostPort(
fmt.Sprintf("%s.%s", backendRef.Name, backendNamespace),
strconv.Itoa(int(*backendRef.Port)),
)
// Port is mandatory for Kubernetes services
if backendKind == resource.KindService {
return net.JoinHostPort(
fmt.Sprintf("%s.%s", backendRef.Name, backendNamespace),
strconv.Itoa(int(*backendRef.Port)),
)
}

// Fallback to the backendRef name, normally it's a unix domain socket in this case
return fmt.Sprintf("%s.%s", backendRef.Name, backendNamespace)
}

func (t *Translator) buildAuthorization(policy *egv1a1.SecurityPolicy) (*ir.Authorization, error) {
Expand Down

0 comments on commit 4bce7b9

Please sign in to comment.