func()

in pkg/authority/k8s/controller.go [118:153]


func (c *Controller) handleEvent(obj interface{}, eventType NotificationType) {
	key, err := cache.MetaNamespaceKeyFunc(obj)
	if err != nil {
		logger.Sugar().Errorf("error getting key for object: %v", err)
		return
	}

	switch o := obj.(type) {
	case *apiV1beta1.AuthenticationPolicy:
		a := CopyToAuthentication(key, c.rootNamespace, o)

		switch eventType {
		case AddNotification:
			c.authenticationHandler.Add(key, a)
		case UpdateNotification:
			c.authenticationHandler.Update(key, a)
		case DeleteNotification:
			c.authenticationHandler.Delete(key)
		}
		return
	case *apiV1beta1.AuthorizationPolicy:
		a := CopyToAuthorization(key, c.rootNamespace, o)

		switch eventType {
		case AddNotification:
			c.authorizationHandler.Add(key, a)
		case UpdateNotification:
			c.authorizationHandler.Update(key, a)
		case DeleteNotification:
			c.authorizationHandler.Delete(key)
		}
	default:
		logger.Sugar().Errorf("unexpected object type: %v", obj)
		return
	}
}