diff --git a/internal/dao/healthz.go b/internal/dao/healthz.go new file mode 100644 index 00000000..75e18971 --- /dev/null +++ b/internal/dao/healthz.go @@ -0,0 +1,45 @@ +package dao + +import ( + "context" + + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" +) + +type Healthz struct { + Resource string + Count int64 + Errors int64 +} + +type Pulse interface{} +type Pulses []Pulse + + +func ClusterHealth(ctx context.Context, gvr string) (Pulses, error) { + var h Healthz + + oo, err := p.List(ctx, "") + if err != nil { + return nil, err + } + + h.Count = len(oo) + for _, o := range oo { + var pod v1.Pod + err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &pod) + if err != nil { + return nil, err + } + + if !happy(pod) { + h.Errors++ + } + } +} + +func happy(p v1.Pod) bool { + +}