Skip to content

Commit

Permalink
fix for ci controller
Browse files Browse the repository at this point in the history
Signed-off-by: Aryan-sharma11 <[email protected]>
  • Loading branch information
Aryan-sharma11 committed Feb 7, 2024
1 parent e1aeb7c commit 5d89eb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 2 additions & 8 deletions pkg/KubeArmorController/handlers/pod_mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// PodAnnotator Structure
type PodAnnotator struct {
Client client.Client
decoder *admission.Decoder
Decoder *admission.Decoder
Logger logr.Logger
Enforcer string
}
Expand All @@ -33,7 +33,7 @@ const appArmorAnnotation = "container.apparmor.security.beta.kubernetes.io/"
func (a *PodAnnotator) Handle(ctx context.Context, req admission.Request) admission.Response {
pod := &corev1.Pod{}

if err := a.decoder.Decode(req, pod); err != nil {
if err := a.Decoder.Decode(req, pod); err != nil {
return admission.Errored(http.StatusBadRequest, err)
}

Expand Down Expand Up @@ -103,12 +103,6 @@ func (a *PodAnnotator) Handle(ctx context.Context, req admission.Request) admiss
return admission.PatchResponseFromRaw(req.Object.Raw, marshaledPod)
}

// InjectDecoder gets a decoder injected for us
func (a *PodAnnotator) InjectDecoder(d *admission.Decoder) error {
a.decoder = d
return nil
}

// == Add AppArmor annotations == //
func appArmorAnnotator(pod *corev1.Pod) {
podAnnotations := map[string]string{}
Expand Down
2 changes: 2 additions & 0 deletions pkg/KubeArmorController/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

"github.com/go-logr/logr"
securityv1 "github.com/kubearmor/KubeArmor/pkg/KubeArmorController/api/security.kubearmor.com/v1"
Expand Down Expand Up @@ -97,6 +98,7 @@ func main() {
Client: mgr.GetClient(),
Logger: setupLog,
Enforcer: detectEnforcer(setupLog),
Decoder: admission.NewDecoder(mgr.GetScheme()),
},
})

Expand Down

0 comments on commit 5d89eb4

Please sign in to comment.