Skip to content

Commit

Permalink
bugfix: add nil check on label selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
scotwells committed Dec 13, 2024
1 parent edd96f3 commit e5d868c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cmd/datum-authorization-webhook/app/internal/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ func NewAuthorizerWebhook(authzer authorizer.Authorizer) *Webhook {
attrs.Subresource = resourceAttrs.Subresource
attrs.Name = resourceAttrs.Name
attrs.ResourceRequest = true
for _, requirement := range r.Spec.ResourceAttributes.LabelSelector.Requirements {
req, _ := labels.NewRequirement(
requirement.Key,
selection.Operator(requirement.Operator),
requirement.Values,
)
attrs.LabelSelectorRequirements = append(attrs.LabelSelectorRequirements, *req)
if resourceAttrs.LabelSelector != nil {
for _, requirement := range resourceAttrs.LabelSelector.Requirements {
req, _ := labels.NewRequirement(
requirement.Key,
selection.Operator(requirement.Operator),
requirement.Values,
)
attrs.LabelSelectorRequirements = append(attrs.LabelSelectorRequirements, *req)
}
}
}

Expand Down

0 comments on commit e5d868c

Please sign in to comment.