securitypolicy

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResultNormal            = common.ResultNormal
	ResultRequeue           = common.ResultRequeue
	ResultRequeueAfter5mins = common.ResultRequeueAfter5mins
	MetricResType           = common.MetricResTypeSecurityPolicy
)
View Source
var PredicateFuncsNs = predicate.Funcs{
	CreateFunc: func(e event.CreateEvent) bool {
		return false
	},
	UpdateFunc: func(e event.UpdateEvent) bool {
		oldObj := e.ObjectOld.(*v1.Namespace)
		newObj := e.ObjectNew.(*v1.Namespace)
		log.V(1).Info("receive namespace update event", "name", oldObj.Name)
		if reflect.DeepEqual(oldObj.ObjectMeta.Labels, newObj.ObjectMeta.Labels) {
			log.Info("label of namespace is not changed, ignore it", "name", oldObj.Name)
			return false
		}
		return true
	},
	DeleteFunc: func(e event.DeleteEvent) bool {
		return false
	},
}
View Source
var PredicateFuncsPod = predicate.Funcs{
	CreateFunc: func(e event.CreateEvent) bool {
		if p, ok := e.Object.(*v1.Pod); ok {
			log.V(1).Info("receive pod create event", "namespace", p.Namespace, "name", p.Name)
			return util.CheckPodHasNamedPort(*p, "create")
		}
		return false
	},
	UpdateFunc: func(e event.UpdateEvent) bool {
		oldObj := e.ObjectOld.(*v1.Pod)
		newObj := e.ObjectNew.(*v1.Pod)
		log.V(1).Info("receive pod update event", "namespace", oldObj.Namespace, "name", oldObj.Name)
		if reflect.DeepEqual(oldObj.ObjectMeta.Labels, newObj.ObjectMeta.Labels) {
			log.V(1).Info("label of pod is not changed, ignore it", "name", oldObj.Name)
			return false
		}
		if util.CheckPodHasNamedPort(*newObj, "update") {
			return true
		}
		return false
	},
	DeleteFunc: func(e event.DeleteEvent) bool {
		if p, ok := e.Object.(*v1.Pod); ok {
			log.V(1).Info("receive pod delete event", "namespace", p.Namespace, "name", p.Name)
			return util.CheckPodHasNamedPort(*p, "delete")
		}
		return false
	},
}

Functions

This section is empty.

Types

type EnqueueRequestForNamespace

type EnqueueRequestForNamespace struct {
	Client client.Client
}

func (*EnqueueRequestForNamespace) Create

func (*EnqueueRequestForNamespace) Delete

func (*EnqueueRequestForNamespace) Generic

func (*EnqueueRequestForNamespace) Update

type EnqueueRequestForPod

type EnqueueRequestForPod struct {
	Client client.Client
}

func (*EnqueueRequestForPod) Create

func (*EnqueueRequestForPod) Delete

func (*EnqueueRequestForPod) Generic

func (*EnqueueRequestForPod) Raw

func (e *EnqueueRequestForPod) Raw(evt interface{}, q workqueue.RateLimitingInterface)

func (*EnqueueRequestForPod) Update

type SecurityPolicyReconciler

type SecurityPolicyReconciler struct {
	Client  client.Client
	Scheme  *apimachineryruntime.Scheme
	Service *securitypolicy.SecurityPolicyService
}

SecurityPolicyReconciler SecurityPolicyReconcile reconciles a SecurityPolicy object

func (*SecurityPolicyReconciler) GarbageCollector

func (r *SecurityPolicyReconciler) GarbageCollector(cancel chan bool, timeout time.Duration)

GarbageCollector collect securitypolicy which has been removed from crd. cancel is used to break the loop during UT

func (*SecurityPolicyReconciler) Reconcile

func (*SecurityPolicyReconciler) Start

Start setup manager and launch GC

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL