1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/pkg/policy/utils.go
shuting 06a2b246dd
Background mode only apply to running pods (#949)
* background mode process Running pod only

* update debug doc
2020-06-25 09:52:27 -07:00

23 lines
515 B
Go

package policy
import "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
//Contains Check if strint is contained in a list of string
func containString(list []string, element string) bool {
for _, e := range list {
if e == element {
return true
}
}
return false
}
func isRunningPod(obj unstructured.Unstructured) bool {
objMap := obj.UnstructuredContent()
phase, ok, err := unstructured.NestedString(objMap, "status", "phase")
if !ok || err != nil {
return false
}
return phase == "Running"
}