From 431c533630083c6eb8bae9c796ac04a71599e3db Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Thu, 2 Nov 2023 14:07:51 -0400 Subject: [PATCH] Add annotations to PodInfo --- cluster/info.go | 1 + cluster/kubernetes.go | 5 ++++- cmd/envcheckctl/exec_inspect.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cluster/info.go b/cluster/info.go index 7ef41cd..516bbc0 100644 --- a/cluster/info.go +++ b/cluster/info.go @@ -40,6 +40,7 @@ func (info *Info) Apply(applyable ...Applyable) { // PodInfo is summary details for a pod. type PodInfo struct { + Annotations map[string]string `json:",omitempty"` ChartVersion string Containers []ContainerInfo LinkedConfigMaps []LinkedConfigMap diff --git a/cluster/kubernetes.go b/cluster/kubernetes.go index 3a4698a..6414da8 100644 --- a/cluster/kubernetes.go +++ b/cluster/kubernetes.go @@ -4,9 +4,10 @@ import ( "context" "encoding/json" "fmt" - "k8s.io/apimachinery/pkg/version" "time" + "k8s.io/apimachinery/pkg/version" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -179,7 +180,9 @@ func (q *KubernetesQuery) AllPods() ([]PodInfo, error) { } for _, pod := range pods.Items { + info := PodInfo{ + Annotations: pod.Annotations, ChartVersion: pod.Labels["app.kubernetes.io/version"], Host: pod.Status.HostIP, IsRunning: pod.Status.Phase == v1.PodRunning, diff --git a/cmd/envcheckctl/exec_inspect.go b/cmd/envcheckctl/exec_inspect.go index 0ea7df9..10bb3da 100644 --- a/cmd/envcheckctl/exec_inspect.go +++ b/cmd/envcheckctl/exec_inspect.go @@ -41,7 +41,7 @@ func ExecInspect(config EnvcheckConfig) { log.Fatalln(err) } log.Printf("podfile=%s", filename) - } else if config.Podfile != "" { + } else { r, err := os.Open(config.Podfile) if err != nil { log.Fatalf("open=failed file=%s err='%v'\n", config.Podfile, err)