INNER CODE UNIT · Go
getPodRestartCount
airwallex/k8s-pod-restart-info-collector · helpers.go:22
func getPodRestartCount(pod *v1.Pod) int {
var restarts int = 0
for i := range pod.Status.ContainerStatuses {
container := pod.Status.ContainerStatuses[i]
restarts += int(container.RestartCount)
}
return restarts
}
func isIgnoredNamespace(namespace string) bool {
ignoredNamespacesEnv := os.Getenv("IGNORED_NAMESPACES")
if ignoredNamespacesEnv == "" {
return false
}
ignoredNamespaces := strings.Split(ignoredNamespacesEnv, ",")
for _, ignoredNamespace := range ignoredNamespaces {
match, _ := regexp.MatchString(ignoredNamespace, namespace)
if match {