Skip to content

Commit f2374cf

Browse files
authored
add involved object to clusterPodStatuses analyzer result (#459)
* cluster pod statuses analyzer involved object
1 parent e7f7e75 commit f2374cf

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

pkg/analyze/analyzer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/pkg/errors"
88
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
99
"github.com/replicatedhq/troubleshoot/pkg/multitype"
10+
corev1 "k8s.io/api/core/v1"
1011
)
1112

1213
type AnalyzeResult struct {
@@ -19,6 +20,8 @@ type AnalyzeResult struct {
1920
URI string
2021
IconKey string
2122
IconURI string
23+
24+
InvolvedObject *corev1.ObjectReference
2225
}
2326

2427
type getCollectedFileContents func(string) ([]byte, error)

pkg/analyze/cluster_pod_statuses.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ func clusterPodStatuses(analyzer *troubleshootv1beta2.ClusterPodStatuses, getChi
9090
continue
9191
}
9292

93+
r.InvolvedObject = &corev1.ObjectReference{
94+
APIVersion: "v1",
95+
Kind: "Pod",
96+
Namespace: pod.Namespace,
97+
Name: pod.Name,
98+
}
99+
93100
r.Title = analyzer.CheckName
94101
if r.Title == "" {
95102
r.Title = "Pod {{ .Namespace }}/{{ .Name }} status"

pkg/convert/supportbundle.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
multierror "github.com/hashicorp/go-multierror"
99
analyze "github.com/replicatedhq/troubleshoot/pkg/analyze"
10+
corev1 "k8s.io/api/core/v1"
1011
)
1112

1213
type Meta struct {
@@ -34,11 +35,12 @@ type Insight struct {
3435
type Result struct {
3536
Meta `json:",inline" yaml:",inline" hcl:",inline"`
3637

37-
Insight *Insight `json:"insight" yaml:"insight" hcl:"insight"`
38-
Severity Severity `json:"severity" yaml:"severity" hcl:"severity"`
39-
AnalyzerSpec string `json:"analyzerSpec" yaml:"analyzerSpec" hcl:"analyzerSpec"`
40-
Variables map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty" hcl:"variables,omitempty"`
41-
Error string `json:"error,omitempty" yaml:"error,omitempty" hcl:"error,omitempty"`
38+
Insight *Insight `json:"insight" yaml:"insight" hcl:"insight"`
39+
Severity Severity `json:"severity" yaml:"severity" hcl:"severity"`
40+
AnalyzerSpec string `json:"analyzerSpec" yaml:"analyzerSpec" hcl:"analyzerSpec"`
41+
Variables map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty" hcl:"variables,omitempty"`
42+
Error string `json:"error,omitempty" yaml:"error,omitempty" hcl:"error,omitempty"`
43+
InvolvedObject *corev1.ObjectReference `json:"involvedObject,omitempty" yaml:"involvedObject,omitempty" hcl:"involvedObject,omitempty"`
4244
}
4345

4446
func (m *Insight) Render(data interface{}) (*Insight, error) {
@@ -88,8 +90,9 @@ func FromAnalyzerResult(input []*analyze.AnalyzeResult) []*Result {
8890
Primary: i.Title,
8991
Detail: i.Message,
9092
},
91-
AnalyzerSpec: "",
92-
Variables: map[string]interface{}{},
93+
AnalyzerSpec: "",
94+
Variables: map[string]interface{}{},
95+
InvolvedObject: i.InvolvedObject,
9396
}
9497
if i.IsFail {
9598
r.Severity = SeverityError

0 commit comments

Comments
 (0)