Skip to content

Commit 7eb782f

Browse files
author
Max Jonas Werner
committed
feat: if a resource has a nil status, print that info
This is better than just skipping that resource.
1 parent 91c27a1 commit 7eb782f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

controllers/kustomization_healthcheck.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,15 @@ func (hc *KustomizeHealthCheck) Assess(pollInterval time.Duration) error {
8989

9090
if ctx.Err() == context.DeadlineExceeded {
9191
errors := []string{}
92-
for _, rs := range coll.ResourceStatuses {
93-
if lastStatus[rs.Identifier].Status != status.CurrentStatus {
94-
id := hc.objMetadataToString(rs.Identifier)
92+
for id, rs := range coll.ResourceStatuses {
93+
if rs == nil {
94+
errors = append(errors, fmt.Sprintf("no status for %s available", id))
95+
continue
96+
}
97+
if lastStatus[id].Status != status.CurrentStatus {
98+
idString := hc.objMetadataToString(rs.Identifier)
9599
var bld strings.Builder
96-
bld.WriteString(fmt.Sprintf("%s (status '%s')", id, lastStatus[rs.Identifier].Status))
100+
bld.WriteString(fmt.Sprintf("%s (status '%s')", idString, lastStatus[id].Status))
97101
if rs.Error != nil {
98102
bld.WriteString(fmt.Sprintf(": %s", rs.Error))
99103
}

0 commit comments

Comments
 (0)