-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
41 lines (32 loc) · 758 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"io"
"github.com/flanksource/is-healthy/pkg/health"
"github.com/flanksource/is-healthy/pkg/lua"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/yaml"
"os"
)
func main() {
stdin, err := io.ReadAll(os.Stdin)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
obj := make(map[string]interface{})
err = yaml.Unmarshal([]byte(stdin), &obj)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
_health, err := health.GetResourceHealth(&unstructured.Unstructured{Object: obj}, lua.ResourceHealthOverrides{})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("%s: %s\n", _health.Status, _health.Message)
if health.IsWorse(health.HealthStatusHealthy, _health.Status) {
os.Exit(1)
}
}