Skip to content

Commit

Permalink
add comment for group match
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvindthiru committed Jun 16, 2023
1 parent c2cc3af commit ea6bc2a
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (v *fleetResourceValidator) handleCRD(req admission.Request) admission.Resp
}
}

// This regex works because every CRD name in kubernetes follows this pattern <plural>.<group>.
group := regexp.MustCompile(groupMatch).FindStringSubmatch(crd.Name)[1]
if validation.CheckCRDGroup(group) && !validation.ValidateUserForCRD(req.UserInfo) {
return admission.Denied(fmt.Sprintf("failed to validate user: %s in groups: %v to modify fleet CRD: %s", req.UserInfo.Username, req.UserInfo.Groups, crd.Name))
Expand Down

0 comments on commit ea6bc2a

Please sign in to comment.