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:
Matt Moore 2019-12-13 09:00:00 -08:00 committed by Knative Prow Robot
parent 62f685b3a0
commit a0fe32a10e
3 changed files with 17 additions and 31 deletions

6
Gopkg.lock generated
View File

@ -931,7 +931,7 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:fd0a9998fe007e1d20ea859e93590525147081a9acb498a4445065d514e1fcef" digest = "1:88d6902d81d05b65381231b5b9682afc7fd420a4dc1f196d91fd6e94a7e87d66"
name = "knative.dev/pkg" name = "knative.dev/pkg"
packages = [ packages = [
"apis", "apis",
@ -950,7 +950,7 @@
"metrics/metricskey", "metrics/metricskey",
] ]
pruneopts = "T" pruneopts = "T"
revision = "bebd5557feae665ccf77bb1d8fee2758aa658264" revision = "a55e24e80c91c3187189641c6ad1651283d05db5"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -961,7 +961,7 @@
"tools/dep-collector", "tools/dep-collector",
] ]
pruneopts = "UT" pruneopts = "UT"
revision = "ed220f8d779f0dbbcc60f45f49eb12018af39168" revision = "71df8cbc28daf5dcf8c9b1ff2dfebdc553dc4bee"
[[projects]] [[projects]]
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"

View File

@ -223,8 +223,6 @@ func (ac *reconciler) validate(ctx context.Context, req *admissionv1beta1.Admiss
// Set up the context for defaulting and validation // Set up the context for defaulting and validation
if oldObj != nil { if oldObj != nil {
// TODO(mattmoor): Remove this after 0.11 cuts.
oldObj.SetDefaults(ctx)
if req.SubResource == "" { if req.SubResource == "" {
ctx = apis.WithinUpdate(ctx, oldObj) ctx = apis.WithinUpdate(ctx, oldObj)
} else { } else {
@ -240,9 +238,6 @@ func (ac *reconciler) validate(ctx context.Context, req *admissionv1beta1.Admiss
return errMissingNewObject return errMissingNewObject
} }
// TODO(mattmoor): Remove this after 0.11 cuts.
newObj.SetDefaults(ctx)
if err := validate(ctx, newObj); err != nil { if err := validate(ctx, newObj); err != nil {
logger.Errorw("Failed the resource specific validation", zap.Error(err)) logger.Errorw("Failed the resource specific validation", zap.Error(err))
// Return the error message as-is to give the validation callback // Return the error message as-is to give the validation callback

View File

@ -69,8 +69,6 @@ type AdmissionController interface {
Path() string Path() string
// Admit is the callback which is invoked when an HTTPS request comes in on Path(). // 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 Admit(context.Context, *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse
} }
@ -80,7 +78,7 @@ type Webhook struct {
Client kubernetes.Interface Client kubernetes.Interface
Options Options Options Options
Logger *zap.SugaredLogger Logger *zap.SugaredLogger
admissionControllers map[string][]AdmissionController admissionControllers map[string]AdmissionController
secretlister corelisters.SecretLister secretlister corelisters.SecretLister
} }
@ -114,9 +112,12 @@ func New(
} }
// Build up a map of paths to admission controllers for routing handlers. // 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 { 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{ return &Webhook{
@ -209,31 +210,21 @@ func (ac *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
zap.String(logkey.UserInfo, fmt.Sprint(review.Request.UserInfo))) zap.String(logkey.UserInfo, fmt.Sprint(review.Request.UserInfo)))
ctx := logging.WithLogger(r.Context(), logger) ctx := logging.WithLogger(r.Context(), logger)
cs, ok := ac.admissionControllers[r.URL.Path] c, ok := ac.admissionControllers[r.URL.Path]
if !ok { if !ok {
http.Error(w, fmt.Sprintf("no admission controller registered for: %s", r.URL.Path), http.StatusBadRequest) http.Error(w, fmt.Sprintf("no admission controller registered for: %s", r.URL.Path), http.StatusBadRequest)
return 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 var response admissionv1beta1.AdmissionReview
for _, c := range cs { reviewResponse := c.Admit(ctx, review.Request)
reviewResponse := c.Admit(ctx, review.Request) logger.Infof("AdmissionReview for %#v: %s/%s response=%#v",
logger.Infof("AdmissionReview for %#v: %s/%s response=%#v", review.Request.Kind, review.Request.Namespace, review.Request.Name, reviewResponse)
review.Request.Kind, review.Request.Namespace, review.Request.Name, reviewResponse)
if !reviewResponse.Allowed { if !reviewResponse.Allowed {
response.Response = reviewResponse response.Response = reviewResponse
break } else if reviewResponse.PatchType != nil || response.Response == nil {
} response.Response = reviewResponse
if reviewResponse.PatchType != nil || response.Response == nil {
response.Response = reviewResponse
}
} }
response.Response.UID = review.Request.UID response.Response.UID = review.Request.UID