diff --git a/main.go b/main.go index fd2d16e..ec31faf 100644 --- a/main.go +++ b/main.go @@ -21,12 +21,14 @@ type Deployment struct { Name string `json:"name"` Namespace string `json:"namespace"` Replicas int32 `json:"replicas"` + Status string `json:"status"` } // Cache 缓存 type Cache struct { - Deployments *[]Deployment `json:"deployments"` - LastUpdated time.Time `json:"lastUpdated"` + Deployments *[]Deployment `json:"deployments,omitempty"` + + LastUpdated time.Time `json:"-"` } var cachedData *Cache @@ -130,12 +132,25 @@ func getNS() *[]Deployment { fmt.Printf("Error listing deployments in namespace %s: %v\n", namespace, err) continue } + // 获取状态 progressing for _, deployment := range deployments.Items { + // get type + + var status string + + // 只有达到最低 available replicas 才能进入 available + if deployment.Status.AvailableReplicas >= deployment.Status.Replicas { + status = "Available" + } else { + status = "Progressing" + } + d = append(d, Deployment{ Name: deployment.Name, Namespace: deployment.Namespace, Replicas: *deployment.Spec.Replicas, + Status: status, }) } }