github.com/argoproj/argo-cd@v1.8.7/util/settings/filtered_resource.go (about) 1 package settings 2 3 import "github.com/argoproj/argo-cd/util/glob" 4 5 type FilteredResource struct { 6 APIGroups []string `json:"apiGroups,omitempty"` 7 Kinds []string `json:"kinds,omitempty"` 8 Clusters []string `json:"clusters,omitempty"` 9 } 10 11 func (r FilteredResource) matchGroup(apiGroup string) bool { 12 for _, excludedApiGroup := range r.APIGroups { 13 if glob.Match(excludedApiGroup, apiGroup) { 14 return true 15 } 16 } 17 return len(r.APIGroups) == 0 18 } 19 20 func (r FilteredResource) matchKind(kind string) bool { 21 for _, excludedKind := range r.Kinds { 22 if excludedKind == "*" || excludedKind == kind { 23 return true 24 } 25 } 26 return len(r.Kinds) == 0 27 } 28 29 func (r FilteredResource) MatchCluster(cluster string) bool { 30 for _, excludedCluster := range r.Clusters { 31 if glob.Match(excludedCluster, cluster) { 32 return true 33 } 34 } 35 return len(r.Clusters) == 0 36 } 37 38 func (r FilteredResource) Match(apiGroup, kind, cluster string) bool { 39 return r.matchGroup(apiGroup) && r.matchKind(kind) && r.MatchCluster(cluster) 40 }