Skip to content

[release-1.31] Fix crictl info for containerd #1570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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