in gke-deploy/core/resource/ready.go [227:277]
func podIsReady(ctx context.Context, obj *Object) (bool, error) {
conditions, ok, err := unstructured.NestedSlice(obj.Object, "status", "conditions")
if err != nil {
return false, fmt.Errorf("failed to get status.conditions field: %v", err)
}
if !ok || len(conditions) == 0 {
return false, nil
}
for _, c := range conditions {
cMap, ok := c.(map[string]interface{})
if !ok {
return false, fmt.Errorf("failed to convert conditions to map")
}
cType, ok, err := unstructured.NestedString(cMap, "type")
if err != nil {
return false, fmt.Errorf("failed to get type field: %v", err)
}
if !ok || cType == "" {
return false, nil
}
switch cType {
case "Ready":
status, ok, err := unstructured.NestedString(cMap, "status")
if err != nil {
return false, fmt.Errorf("failed to get status field: %v", err)
}
if !ok {
return false, nil
}
if status == "True" {
return true, nil
}
reason, ok, err := unstructured.NestedString(cMap, "reason")
if err != nil {
return false, fmt.Errorf("failed to get reason field: %v", err)
}
if !ok {
return false, nil
}
if reason == "PodCompleted" {
return true, nil
}
default:
// Skip
}
}
return false, nil
}