Skip to content

Commit

Permalink
refactor: better name variables in pkg/webhook/registry
Browse files Browse the repository at this point in the history
  • Loading branch information
ludusrusso authored and prometherion committed May 4, 2021
1 parent cec8cc0 commit e1b2037
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/webhook/registry/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,24 @@ func (h *handler) OnCreate(c client.Client, decoder *admission.Decoder) capsulew
return admission.Errored(http.StatusBadRequest, err)
}

tl := &capsulev1alpha1.TenantList{}
if err := c.List(ctx, tl, client.MatchingFieldsSelector{
tntList := &capsulev1alpha1.TenantList{}
if err := c.List(ctx, tntList, client.MatchingFieldsSelector{
Selector: fields.OneTermEqualSelector(".status.namespaces", pod.Namespace),
}); err != nil {
return admission.Errored(http.StatusBadRequest, err)
}
if len(tl.Items) == 0 {
if len(tntList.Items) == 0 {
return admission.Allowed("")
}

tnt := tl.Items[0]
tnt := tntList.Items[0]

if tnt.Spec.ContainerRegistries != nil {
var valid, matched bool
for _, container := range pod.Spec.Containers {
r := domain.NewRegistry(container.Image)
valid = tnt.Spec.ContainerRegistries.ExactMatch(r.Registry())
matched = tnt.Spec.ContainerRegistries.RegexMatch(r.Registry())
registry := domain.NewRegistry(container.Image)
valid = tnt.Spec.ContainerRegistries.ExactMatch(registry.Registry())
matched = tnt.Spec.ContainerRegistries.RegexMatch(registry.Registry())
if !valid && !matched {
return admission.Errored(http.StatusBadRequest, NewContainerRegistryForbidden(container.Image, *tnt.Spec.ContainerRegistries))
}
Expand Down

0 comments on commit e1b2037

Please sign in to comment.