AppManager: Recursively monitor dodo resources
Change-Id: I23f3014e416f5b68f8909dbfbcba27db66eaee3f
diff --git a/core/installer/status/helm.go b/core/installer/status/helm.go
index b2db1d4..8b4162c 100644
--- a/core/installer/status/helm.go
+++ b/core/installer/status/helm.go
@@ -3,6 +3,7 @@
import (
"context"
"encoding/json"
+ "fmt"
"github.com/giolekva/pcloud/core/installer/kube"
@@ -12,7 +13,12 @@
"k8s.io/client-go/dynamic"
)
-type helmRelease struct {
+type HelmRelease struct {
+ Metadata struct {
+ Name string `json:"name"`
+ Namespace string `json:"namespace"`
+ Annotations map[string]string `json:"annotations"`
+ } `json:"metadata"`
Status struct {
Conditions []struct {
Type string `json:"type"`
@@ -26,6 +32,7 @@
}
func (m *helmReleaseMonitor) Get(ref ResourceRef) (Status, error) {
+ fmt.Printf("--- %+v\n", ref)
ctx := context.Background()
res, err := m.d.Resource(
schema.GroupVersionResource{
@@ -44,10 +51,17 @@
if err != nil {
return StatusNoStatus, err
}
- var hr helmRelease
+ var hr HelmRelease
if err := json.Unmarshal(b, &hr); err != nil {
return StatusNoStatus, err
}
+ id, ok := hr.Metadata.Annotations["dodo.cloud/id"]
+ if !ok {
+ return StatusNoStatus, fmt.Errorf("missing annotation: dodo.cloud/id")
+ }
+ if id != ref.Id {
+ return StatusNotFound, nil
+ }
// TODO(gio): check more thoroughly
for _, c := range hr.Status.Conditions {
if c.Type == "Ready" && c.Status == "True" {