decode Spec value in command 'ctr c info <containerid>'#2568
decode Spec value in command 'ctr c info <containerid>'#2568lifubang wants to merge 3 commits intocontainerd:masterfrom
Conversation
Signed-off-by: Lifubang <[email protected]>
|
Maybe this should be a CLI option such as --try-decode or just --decode. |
|
|
||
| if (cc.Spec != nil && cc.Spec.Value != nil) { | ||
| type c containers.Container | ||
| type SpecDecode struct { |
There was a problem hiding this comment.
All you have to do is:
v, err := typeurl.UnmarshalAny(cc.Spec)
commands.PrintAsJSON(v)There was a problem hiding this comment.
Thanks, I'll try it.
There was a problem hiding this comment.
Yes, typeurl.UnmarshalAny can work. But we not only print Spec field, there are many others fields to print, I just rewrite the Spec.Value's json print result, and other fields remain the same as before.
63a7c5c to
892df17
Compare
Signed-off-by: Lifubang <[email protected]>
lifubang
left a comment
There was a problem hiding this comment.
I use typeurl.UnmarshalAny. Thanks.
|
|
||
| if (cc.Spec != nil && cc.Spec.Value != nil) { | ||
| type c containers.Container | ||
| type SpecDecode struct { |
There was a problem hiding this comment.
Yes, typeurl.UnmarshalAny can work. But we not only print Spec field, there are many others fields to print, I just rewrite the Spec.Value's json print result, and other fields remain the same as before.
Signed-off-by: Lifubang [email protected]
Before this commit, the Spec.value field are incomprehensible:
After the commit, there are some useful information for us: