func (spi *SecurityProfileInformer) Init(nsp model.NSPInterface) error {
	spi.Nsp = nsp
	var err error
	// Init stopper
	spi.Stopper = make(chan struct{})
	// Create custom CRD in k8s if it doesn't exist yet
	if err = v1.CreateSecurityProfileCRD(nsp.GetKubeConfig()); err != nil {
		return err
	}
	informerLogger.Debug("SecurityProfile CRD registered")
	// Create k8s client
	spi.SecurityProbeClientSet, err = spclientset.NewForConfig(nsp.GetKubeConfig())
	if err != nil {
		return err
	}
	// Create Informer
	factory := externalversions.NewSharedInformerFactory(spi.SecurityProbeClientSet, time.Minute)
	spi.Informer = factory.Securityprobe().V1().SecurityProfiles()
	// Setup event handlers
	spi.Informer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		// When a new pod gets created
		AddFunc: func(obj interface{}) {
			spi.onAdd(obj.(*v1.SecurityProfile))
		},
		// When a pod gets updated
		UpdateFunc: func(old interface{}, new interface{}) {
			spi.onUpdate(old.(*v1.SecurityProfile), new.(*v1.SecurityProfile))
		},
		// When a pod gets deleted
		DeleteFunc: func(obj interface{}) {
			spi.onDelete(obj.(*v1.SecurityProfile))
		},
	})
	return nil
}
// Init - Initializes the SecurityProfile informer
Initializes the SecurityProfile informer
// Init - Initializes the SecurityProfile informer
func (spi *SecurityProfileInformer) Init(nsp model.NSPInterface) error {
	spi.Nsp = nsp
	var err error
	spi.Stopper = make(chan struct{})
	if err = v1.CreateSecurityProfileCRD(nsp.GetKubeConfig()); err != nil {
		return err
	}
	informerLogger.Debug("SecurityProfile CRD registered")
	spi.SecurityProbeClientSet, err = spclientset.NewForConfig(nsp.GetKubeConfig())
	if err != nil {
		return err
	}
	factory := externalversions.NewSharedInformerFactory(spi.SecurityProbeClientSet, time.Minute)
	spi.Informer = factory.Securityprobe().V1().SecurityProfiles()
	spi.Informer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: func(obj interface{}) {
			spi.onAdd(obj.(*v1.SecurityProfile))
		},
		UpdateFunc: func(old interface{}, new interface{}) {
			spi.onUpdate(old.(*v1.SecurityProfile), new.(*v1.SecurityProfile))
		},
		DeleteFunc: func(obj interface{}) {
			spi.onDelete(obj.(*v1.SecurityProfile))
		},
	})
	return nil
}
func ( spi * SecurityProfileInformer ) Init ( nsp model . NSPInterface ) error { spi . Nsp = nsp var err error spi . Stopper = make ( chan struct { } ) if err = v1 . CreateSecurityProfileCRD ( nsp . GetKubeConfig ( ) ) ; err != nil { return err } informerLogger . Debug ( " " ) spi . SecurityProbeClientSet , err = spclientset . NewForConfig ( nsp . GetKubeConfig ( ) ) if err != nil { return err } factory := externalversions . NewSharedInformerFactory ( spi . SecurityProbeClientSet , time . Minute ) spi . Informer = factory . Securityprobe ( ) . V1 ( ) . SecurityProfiles ( ) spi . Informer . Informer ( ) . AddEventHandler ( cache . ResourceEventHandlerFuncs { AddFunc : func ( obj interface { } ) { spi . onAdd ( obj . ( * v1 . SecurityProfile ) ) } , UpdateFunc : func ( old interface { } , new interface { } ) { spi . onUpdate ( old . ( * v1 . SecurityProfile ) , new . ( * v1 . SecurityProfile ) ) } , DeleteFunc : func ( obj interface { } ) { spi . onDelete ( obj . ( * v1 . SecurityProfile ) ) } , } ) return nil }
Initializes the SecurityProfile informer
Initializes the SecurityProfile informer
// Init stopper // Create custom CRD in k8s if it doesn't exist yet // Create k8s client // Create Informer // Setup event handlers // When a new pod gets created // When a pod gets updated // When a pod gets deleted