Skip to content

Commit

Permalink
change for API changing
Browse files Browse the repository at this point in the history
  • Loading branch information
takara9 committed Jun 4, 2024
1 parent ca54585 commit ce46f1d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions hooks/mutate_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cybozu-go/pod-security-admission/hooks/mutators"
"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand All @@ -18,13 +17,13 @@ import (
type podMutator struct {
client client.Client
log logr.Logger
decoder *admission.Decoder
decoder admission.Decoder
profileName string
mutators []mutators.Mutator
}

// NewPodMutator creates a webhook handler for Pod.
func NewPodMutator(c client.Client, log logr.Logger, dec *admission.Decoder, prof SecurityProfile) http.Handler {
func NewPodMutator(c client.Client, log logr.Logger, dec admission.Decoder, prof SecurityProfile) http.Handler {
m := &podMutator{
client: c,
log: log,
Expand All @@ -51,8 +50,7 @@ func (m *podMutator) Handle(ctx context.Context, req admission.Request) admissio
m.log.Info("mutating pod,", "name", namespacedName, "profile", m.profileName)

po := &corev1.Pod{}
d := admission.NewDecoder(runtime.NewScheme())
err:= d.Decode(req, po)
err:= m.decoder.Decode(req, po)
if err != nil {
m.log.Error(err, "failed to decode pod", "name", namespacedName, "profile", m.profileName)
return admission.Errored(http.StatusBadRequest, err)
Expand Down

0 comments on commit ce46f1d

Please sign in to comment.