in tools/bug-report/pkg/cluster/cluster.go [51:156]
func shouldSkip(deployment string, config *config2.BugReportConfig, pod *corev1.Pod) bool {
for _, eld := range config.Exclude {
if len(eld.Namespaces) > 0 {
if isIncludeOrExcludeEntriesMatched(eld.Namespaces, pod.Namespace) {
return true
}
}
if len(eld.Deployments) > 0 {
if isIncludeOrExcludeEntriesMatched(eld.Deployments, deployment) {
return true
}
}
if len(eld.Pods) > 0 {
if isIncludeOrExcludeEntriesMatched(eld.Pods, pod.Name) {
return true
}
}
if len(eld.Containers) > 0 {
for _, c := range pod.Spec.Containers {
if isIncludeOrExcludeEntriesMatched(eld.Containers, c.Name) {
return true
}
}
}
if len(eld.Labels) > 0 {
for key, val := range eld.Labels {
if evLablel, exists := pod.Labels[key]; exists {
if isExactMatchedOrPatternMatched(val, evLablel) {
return true
}
}
}
}
if len(eld.Annotations) > 0 {
for key, val := range eld.Annotations {
if evAnnotation, exists := pod.Annotations[key]; exists {
if isExactMatchedOrPatternMatched(val, evAnnotation) {
return true
}
}
}
}
}
for _, ild := range config.Include {
if len(ild.Namespaces) > 0 {
if !isIncludeOrExcludeEntriesMatched(ild.Namespaces, pod.Namespace) {
return true
}
}
if len(ild.Deployments) > 0 {
if !isIncludeOrExcludeEntriesMatched(ild.Deployments, deployment) {
return true
}
}
if len(ild.Pods) > 0 {
if !isIncludeOrExcludeEntriesMatched(ild.Pods, pod.Name) {
return true
}
}
if len(ild.Containers) > 0 {
isContainerMatch := false
for _, c := range pod.Spec.Containers {
if isIncludeOrExcludeEntriesMatched(ild.Containers, c.Name) {
isContainerMatch = true
}
}
if !isContainerMatch {
return true
}
}
if len(ild.Labels) > 0 {
isLabelsMatch := false
for key, val := range ild.Labels {
if evLablel, exists := pod.Labels[key]; exists {
if isExactMatchedOrPatternMatched(val, evLablel) {
isLabelsMatch = true
break
}
}
}
if !isLabelsMatch {
return true
}
}
if len(ild.Annotations) > 0 {
isAnnotationMatch := false
for key, val := range ild.Annotations {
if evAnnotation, exists := pod.Annotations[key]; exists {
if isExactMatchedOrPatternMatched(val, evAnnotation) {
isAnnotationMatch = true
break
}
}
}
if !isAnnotationMatch {
return true
}
}
}
return false
}