mirror of https://github.com/knative/caching.git
Auto-update dependencies (#159)
Produced via: `dep ensure -update knative.dev/test-infra knative.dev/pkg` /assign n3wscott /cc n3wscott
This commit is contained in:
parent
62f685b3a0
commit
a0fe32a10e
|
@ -931,7 +931,7 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:fd0a9998fe007e1d20ea859e93590525147081a9acb498a4445065d514e1fcef"
|
||||
digest = "1:88d6902d81d05b65381231b5b9682afc7fd420a4dc1f196d91fd6e94a7e87d66"
|
||||
name = "knative.dev/pkg"
|
||||
packages = [
|
||||
"apis",
|
||||
|
@ -950,7 +950,7 @@
|
|||
"metrics/metricskey",
|
||||
]
|
||||
pruneopts = "T"
|
||||
revision = "bebd5557feae665ccf77bb1d8fee2758aa658264"
|
||||
revision = "a55e24e80c91c3187189641c6ad1651283d05db5"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -961,7 +961,7 @@
|
|||
"tools/dep-collector",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "ed220f8d779f0dbbcc60f45f49eb12018af39168"
|
||||
revision = "71df8cbc28daf5dcf8c9b1ff2dfebdc553dc4bee"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
||||
|
|
|
@ -223,8 +223,6 @@ func (ac *reconciler) validate(ctx context.Context, req *admissionv1beta1.Admiss
|
|||
|
||||
// Set up the context for defaulting and validation
|
||||
if oldObj != nil {
|
||||
// TODO(mattmoor): Remove this after 0.11 cuts.
|
||||
oldObj.SetDefaults(ctx)
|
||||
if req.SubResource == "" {
|
||||
ctx = apis.WithinUpdate(ctx, oldObj)
|
||||
} else {
|
||||
|
@ -240,9 +238,6 @@ func (ac *reconciler) validate(ctx context.Context, req *admissionv1beta1.Admiss
|
|||
return errMissingNewObject
|
||||
}
|
||||
|
||||
// TODO(mattmoor): Remove this after 0.11 cuts.
|
||||
newObj.SetDefaults(ctx)
|
||||
|
||||
if err := validate(ctx, newObj); err != nil {
|
||||
logger.Errorw("Failed the resource specific validation", zap.Error(err))
|
||||
// Return the error message as-is to give the validation callback
|
||||
|
|
|
@ -69,8 +69,6 @@ type AdmissionController interface {
|
|||
Path() string
|
||||
|
||||
// Admit is the callback which is invoked when an HTTPS request comes in on Path().
|
||||
// TODO(mattmoor): This will need to be different for Conversion webhooks, which is something
|
||||
// to start thinking about.
|
||||
Admit(context.Context, *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse
|
||||
}
|
||||
|
||||
|
@ -80,7 +78,7 @@ type Webhook struct {
|
|||
Client kubernetes.Interface
|
||||
Options Options
|
||||
Logger *zap.SugaredLogger
|
||||
admissionControllers map[string][]AdmissionController
|
||||
admissionControllers map[string]AdmissionController
|
||||
secretlister corelisters.SecretLister
|
||||
}
|
||||
|
||||
|
@ -114,9 +112,12 @@ func New(
|
|||
}
|
||||
|
||||
// Build up a map of paths to admission controllers for routing handlers.
|
||||
acs := map[string][]AdmissionController{}
|
||||
acs := make(map[string]AdmissionController, len(admissionControllers))
|
||||
for _, ac := range admissionControllers {
|
||||
acs[ac.Path()] = append(acs[ac.Path()], ac)
|
||||
if _, ok := acs[ac.Path()]; ok {
|
||||
return nil, fmt.Errorf("duplicate webhook for path: %v", ac.Path())
|
||||
}
|
||||
acs[ac.Path()] = ac
|
||||
}
|
||||
|
||||
return &Webhook{
|
||||
|
@ -209,32 +210,22 @@ func (ac *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
zap.String(logkey.UserInfo, fmt.Sprint(review.Request.UserInfo)))
|
||||
ctx := logging.WithLogger(r.Context(), logger)
|
||||
|
||||
cs, ok := ac.admissionControllers[r.URL.Path]
|
||||
c, ok := ac.admissionControllers[r.URL.Path]
|
||||
if !ok {
|
||||
http.Error(w, fmt.Sprintf("no admission controller registered for: %s", r.URL.Path), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
// TODO(mattmoor): Remove support for multiple AdmissionControllers at
|
||||
// the same path after 0.11 cuts.
|
||||
// We only TEMPORARILY support multiple AdmissionControllers at the same path because of
|
||||
// the issue described here: https://github.com/knative/serving/pull/5947
|
||||
// So we only support a single AdmissionController per path returning Patches.
|
||||
var response admissionv1beta1.AdmissionReview
|
||||
for _, c := range cs {
|
||||
reviewResponse := c.Admit(ctx, review.Request)
|
||||
logger.Infof("AdmissionReview for %#v: %s/%s response=%#v",
|
||||
review.Request.Kind, review.Request.Namespace, review.Request.Name, reviewResponse)
|
||||
|
||||
if !reviewResponse.Allowed {
|
||||
response.Response = reviewResponse
|
||||
break
|
||||
}
|
||||
|
||||
if reviewResponse.PatchType != nil || response.Response == nil {
|
||||
} else if reviewResponse.PatchType != nil || response.Response == nil {
|
||||
response.Response = reviewResponse
|
||||
}
|
||||
}
|
||||
response.Response.UID = review.Request.UID
|
||||
|
||||
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||
|
|
Loading…
Reference in New Issue