Skip to content

Commit

Permalink
Fix webhook server
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Feb 10, 2024
1 parent 4bd38bd commit 8cb8f6f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
kmodules.xyz/offshoot-api v0.29.0
kmodules.xyz/openshift v0.29.0
kmodules.xyz/prober v0.29.0
kmodules.xyz/webhook-runtime v0.29.0
kmodules.xyz/webhook-runtime v0.29.1
sigs.k8s.io/controller-runtime v0.17.0
stash.appscode.dev/apimachinery v0.33.0-rc.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1588,8 +1588,8 @@ kmodules.xyz/resource-metadata v0.18.2-0.20240209092240-01f2d51a9f27 h1:MVAZE8rS
kmodules.xyz/resource-metadata v0.18.2-0.20240209092240-01f2d51a9f27/go.mod h1:I9HeSgkshwzwUy0IDhp4yIfRFbFQJ21syeSf4NsB04o=
kmodules.xyz/resource-metrics v0.29.0 h1:YBSVCbGdAugUqZK4igHu3fPhxvpYar4xejE6njryNM4=
kmodules.xyz/resource-metrics v0.29.0/go.mod h1:OuG/QobZ7o8GFHl/u3lqaUR0fDZDegxtV8Vdh+MNBD4=
kmodules.xyz/webhook-runtime v0.29.0 h1:6W3/MMcaCwLGbEggj6i5+WmOziwV3WwroWpfwe29rTU=
kmodules.xyz/webhook-runtime v0.29.0/go.mod h1:/TBpnSdTISjjUh4euI3XhNlpFU937CfKYoWjDm39pUY=
kmodules.xyz/webhook-runtime v0.29.1 h1:SQ8NvwJpxv5CUuXIubSg9g0Bk8BBnj4dhCWEk6Ou8g8=
kmodules.xyz/webhook-runtime v0.29.1/go.mod h1:WVgNO4NqFdYwYZ82L6QIycN1Ax47y+yXi7XIHekYylo=
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type GenericWebhook struct {
plural schema.GroupVersionResource
singular string

srcGroups sets.String
srcGroups sets.Set[string]
target schema.GroupVersionKind
factory api.GetterFactory
get api.GetFunc
Expand All @@ -65,7 +65,7 @@ func NewGenericWebhook(
return &GenericWebhook{
plural: plural,
singular: singular,
srcGroups: sets.NewString(srcGroups...),
srcGroups: sets.New[string](srcGroups...),
target: target,
factory: factory,
handler: handler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type WorkloadWebhook struct {
singular string
kind string

srcGroups sets.String
srcGroups sets.Set[string]
factory api.GetterFactory
get api.GetFunc
handler admission.ResourceHandler
Expand All @@ -71,7 +71,7 @@ func NewWorkloadWebhook(
plural: plural,
singular: singular,
kind: kind,
srcGroups: sets.NewString(core.GroupName, appsv1.GroupName, extensions.GroupName, batchv1.GroupName),
srcGroups: sets.New[string](core.GroupName, appsv1.GroupName, extensions.GroupName, batchv1.GroupName),
factory: factory,
handler: handler,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
"context"
"strings"

admission "k8s.io/api/admission/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -39,6 +40,7 @@ var (
_ rest.Scoper = &REST{}
_ rest.GroupVersionKindProvider = &REST{}
_ rest.Storage = &REST{}
_ rest.SingularNameProvider = &REST{}
)

func NewREST(hookFn AdmissionHookFunc) *REST {
Expand All @@ -55,6 +57,10 @@ func (r *REST) GroupVersionKind(_ schema.GroupVersion) schema.GroupVersionKind {
return admission.SchemeGroupVersion.WithKind("AdmissionReview")
}

func (r *REST) GetSingularName() string {
return strings.ToLower("AdmissionReview")
}

func (r *REST) NamespaceScoped() bool {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1919,7 +1919,7 @@ kmodules.xyz/resource-metrics/core/v1
kmodules.xyz/resource-metrics/kubedb.com/v1alpha2
kmodules.xyz/resource-metrics/kubevault.com/v1alpha2
kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1
# kmodules.xyz/webhook-runtime v0.29.0
# kmodules.xyz/webhook-runtime v0.29.1
## explicit; go 1.21.5
kmodules.xyz/webhook-runtime/admission
kmodules.xyz/webhook-runtime/admission/v1beta1
Expand Down

0 comments on commit 8cb8f6f

Please sign in to comment.