代码拉取完成,页面将自动刷新
package podsecuritypolicy
import (
v12 "github.com/rancher/types/apis/core/v1"
"github.com/rancher/types/config"
"github.com/sirupsen/logrus"
"k8s.io/api/core/v1"
)
type namespaceManager struct {
serviceAccountsController v12.ServiceAccountController
serviceAccountLister v12.ServiceAccountLister
}
// RegisterNamespace resyncs the current namespace's service accounts. This is necessary because service accounts
// determine their parent project via an annotation on the namespace, and the namespace is not always present when the
// service account handler is triggered. So we have this handler to retrigger the serviceaccount handler once the
// annotation has been added.
func RegisterNamespace(context *config.UserContext) {
logrus.Infof("registering podsecuritypolicy namespace handler for cluster %v", context.ClusterName)
m := &namespaceManager{
serviceAccountLister: context.Core.ServiceAccounts("").Controller().Lister(),
serviceAccountsController: context.Core.ServiceAccounts("").Controller(),
}
context.Core.Namespaces("").AddHandler("NamespaceSyncHandler", m.sync)
}
func (m *namespaceManager) sync(key string, obj *v1.Namespace) error {
if obj == nil || obj.DeletionTimestamp != nil ||
obj.Status.Phase == v1.NamespaceTerminating {
return nil
}
return resyncServiceAccounts(m.serviceAccountLister, m.serviceAccountsController, obj.Name)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。