-
Notifications
You must be signed in to change notification settings - Fork 48
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
Ability to output ls/ps in json format #889
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor yetus complaints and I didn't understand why we want to use string instead of strict type for some parameters when we can marshal those structures in JSON
pkg/eve/applications.go
Outdated
infoTime time.Time | ||
MemoryUsed uint32 | ||
MemoryAvail uint32 | ||
CpuUsage int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some Yetus complaints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified, thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now yetus is finally happy (with several nolint directives unfortunately)
@@ -17,7 +19,7 @@ import ( | |||
type NetInstState struct { | |||
Name string | |||
UUID string | |||
NetworkType config.ZNetworkInstType | |||
NetworkType string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we want to switch to string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experiments I received value of variable here (some number), not a meaningful text (ZnetInstLocal from my sample). It is quite tricky to format it on-fly in marshaller.
d60e982
to
00976ee
Compare
Let's allow to use --format=json option to display lists in machine-readable format. ``` $ ./eden volume ls --format=json [ { "Name": "pedantic_ganguly_0_m_0", "UUID": "77a786a5-fc09-4b3d-946c-fbb4d77a72ce", "Image": "lfedge/eden-eclient:b1c1de6", "VolumeType": "CONTAINER", "Size": "82 MB", "MaxSize": "-", "AdamState": "IN_CONFIG", "EveState": "DELIVERED", "LastError": "", "Ref": "app: pedantic_ganguly", "MountPoint": "/", "OriginType": "VCOT_DOWNLOAD" } ] ``` ``` $ ./eden network ls --format=json [ { "Name": "flamboyant_goldstine", "UUID": "c7b73fe8-f2eb-4304-b07a-9f8adcca8178", "NetworkType": "ZnetInstLocal", "CIDR": "10.11.12.0/24", "Stats": "rx:{totalPackets:570 totalBytes:54758} tx:{totalPackets:2260 totalBytes:2607824}", "AdamState": "IN_CONFIG", "EveState": "ACTIVATED", "Activated": true } ] ``` ``` $ ./eden pod ps --format=json [ { "Name": "pedantic_ganguly", "UUID": "2877759b-5443-4952-b95e-004f244c87ad", "Image": "lfedge/eden-eclient:b1c1de6", "AdamState": "IN_CONFIG", "EVEState": "RUNNING", "InternalIP": [ "10.11.12.2" ], "ExternalIP": "127.0.0.1", "InternalPort": "22", "ExternalPort": "8027", "MemoryUsed": 181, "MemoryAvail": 896, "CPUUsage": 0, "Macs": [ "ce:5b:cd:11:50:0f" ], "Volumes": { "77a786a5-fc09-4b3d-946c-fbb4d77a72ce": 100 } } ] ``` Signed-off-by: Petr Fedchenkov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Let's allow to use --format=json option to display lists in machine-readable format.