ignore the role/clusterrole which don't have "creator" annotation

This commit is contained in:
richardxz
2018-10-24 00:03:43 -04:00
parent 75d8787f64
commit 33dd9fb2dd
3 changed files with 4 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ func (ctl *ClusterRoleCtl) generateObject(item v1.ClusterRole) *ClusterRole {
}
name := item.Name
if strings.HasPrefix(name, systemPrefix) {
if strings.HasPrefix(name, systemPrefix) || item.Annotations == nil || len(item.Annotations[creator]) == 0 {
return nil
}

View File

@@ -30,12 +30,12 @@ import (
func (ctl *RoleCtl) generateObject(item v1.Role) *Role {
var displayName string
if item.Annotations != nil && len(item.Annotations[DisplayName]) > 0 {
if item.Annotations != nil && len(item.Annotations[DisplayName]) == 0 {
displayName = item.Annotations[DisplayName]
}
name := item.Name
if strings.HasPrefix(name, systemPrefix) {
if strings.HasPrefix(name, systemPrefix) || item.Annotations == nil || len(item.Annotations[creator]) == 0 {
return nil
}
namespace := item.Namespace

View File

@@ -49,6 +49,7 @@ const (
Warning = "warning"
Error = "error"
DisplayName = "displayName"
creator = "creator"
Pods = "pods"
Deployments = "deployments"