Files
open-cluster-management/pkg/work/webhook/v1/webhook.go
Jian Zhu 7332a585c0 🌱 add a verify rule for golang files import order (#177)
* 🌱 add a verify rule for golang files import order

This PR uses the [gci tool](https://github.com/daixiang0/gci) to make all go files' import section with a specific order, it will organize import with group with order:
1. standard library modules
2. 3rd party modules
3. modules in OCM org, like the `open-cluster-management.io/api`
4. current project `open-cluster-management.io/ocm` modules

developers can use the `make fmt-imports` to format the import automatically and the `make verify-fmt-imports` to check for any violation.

Signed-off-by: zhujian <jiazhu@redhat.com>

* 🌱 format the go files import

Signed-off-by: zhujian <jiazhu@redhat.com>

---------

Signed-off-by: zhujian <jiazhu@redhat.com>
2023-06-12 10:23:04 -04:00

34 lines
803 B
Go

package v1
import (
"k8s.io/client-go/kubernetes"
ctrl "sigs.k8s.io/controller-runtime"
v1 "open-cluster-management.io/api/work/v1"
)
type ManifestWorkWebhook struct {
kubeClient kubernetes.Interface
}
func (r *ManifestWorkWebhook) Init(mgr ctrl.Manager) error {
err := r.SetupWebhookWithManager(mgr)
if err != nil {
return err
}
r.kubeClient, err = kubernetes.NewForConfig(mgr.GetConfig())
return err
}
// SetExternalKubeClientSet is function to enable the webhook injecting to kube admission
func (r *ManifestWorkWebhook) SetExternalKubeClientSet(client kubernetes.Interface) {
r.kubeClient = client
}
func (r *ManifestWorkWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
WithValidator(r).
For(&v1.ManifestWork{}).
Complete()
}