Skip to content

Commit

Permalink
Merge pull request #1570 from saschagrunert/release-1.31-containerd
Browse files Browse the repository at this point in the history
[release-1.31] Fix `crictl` info for containerd
  • Loading branch information
k8s-ci-robot authored Aug 13, 2024
2 parents 30ad370 + e666587 commit ea669ca
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmd/crictl/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,19 @@ func outputStatusData(statuses []statusData, format, tmplStr string) (err error)
}

for _, k := range keys {
var genericVal map[string]any
if err := json.Unmarshal([]byte(status.info[k]), &genericVal); err != nil {
return fmt.Errorf("unmarshal status info JSON: %w", err)
val := status.info[k]

if strings.HasPrefix(val, "{") {
// Assume a JSON object
var genericVal map[string]any
if err := json.Unmarshal([]byte(val), &genericVal); err != nil {
return fmt.Errorf("unmarshal status info JSON: %w", err)
}
infoMap[k] = genericVal
} else {
// Assume a string and remove any double quotes
infoMap[k] = strings.Trim(val, `"`)
}
infoMap[k] = genericVal
}

result = append(result, infoMap)
Expand Down

0 comments on commit ea669ca

Please sign in to comment.