mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-15 21:59:16 +00:00
* Refactor code to fix lint warning Signed-off-by: Jian Qiu <jqiu@redhat.com> * enable lint for testing files Signed-off-by: Jian Qiu <jqiu@redhat.com> --------- Signed-off-by: Jian Qiu <jqiu@redhat.com>
34 lines
867 B
Go
34 lines
867 B
Go
package v1alpha1
|
|
|
|
import (
|
|
"k8s.io/client-go/kubernetes"
|
|
ctrl "sigs.k8s.io/controller-runtime"
|
|
|
|
"open-cluster-management.io/api/work/v1alpha1"
|
|
)
|
|
|
|
type ManifestWorkReplicaSetWebhook struct {
|
|
kubeClient kubernetes.Interface
|
|
}
|
|
|
|
func (r *ManifestWorkReplicaSetWebhook) 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 admssion
|
|
func (r *ManifestWorkReplicaSetWebhook) SetExternalKubeClientSet(client kubernetes.Interface) {
|
|
r.kubeClient = client
|
|
}
|
|
|
|
func (r *ManifestWorkReplicaSetWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
|
|
return ctrl.NewWebhookManagedBy(mgr).
|
|
WithValidator(r).
|
|
For(&v1alpha1.ManifestWorkReplicaSet{}).
|
|
Complete()
|
|
}
|