Skip to content

Commit 0197ef5

Browse files
authored
Merge pull request #3247 from dougm/govc-json-camelCase
govc: camelCase json output
2 parents 8f49f6c + db5b3d8 commit 0197ef5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+351
-354
lines changed

govc/USAGE.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ System information including the name, type, version, and build number.
392392
393393
Examples:
394394
govc about
395-
govc about -json | jq -r .About.productLineId
395+
govc about -json | jq -r .about.productLineId
396396
397397
Options:
398398
-c=false Include client info
@@ -411,7 +411,7 @@ If the '-k' flag is provided, about.cert will return with exit code 0 in this ca
411411
The SHA1 thumbprint can also be used as '-thumbprint' for the 'host.add' and 'cluster.add' commands.
412412
413413
Examples:
414-
govc about.cert -k -json | jq -r .ThumbprintSHA1
414+
govc about.cert -k -json | jq -r .thumbprintSHA1
415415
govc about.cert -k -show | sudo tee /usr/local/share/ca-certificates/host.crt
416416
govc about.cert -k -thumbprint | tee -a ~/.govmomi/known_hosts
417417
@@ -853,7 +853,7 @@ Cluster resource usage summary.
853853
Examples:
854854
govc cluster.usage ClusterName
855855
govc cluster.usage -S ClusterName # summarize shared storage only
856-
govc cluster.usage -json ClusterName | jq -r .CPU.Summary.Usage
856+
govc cluster.usage -json ClusterName | jq -r .cpu.summary.usage
857857
858858
Options:
859859
-S=false Exclude host local storage
@@ -1425,9 +1425,9 @@ Device info for VM.
14251425
Examples:
14261426
govc device.info -vm $name
14271427
govc device.info -vm $name disk-*
1428-
govc device.info -vm $name -json disk-* | jq -r .Devices[].backing.uuid
1429-
govc device.info -vm $name -json 'disk-*' | jq -r .Devices[].backing.fileName # vmdk path
1430-
govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].macAddress
1428+
govc device.info -vm $name -json disk-* | jq -r .devices[].backing.uuid
1429+
govc device.info -vm $name -json 'disk-*' | jq -r .devices[].backing.fileName # vmdk path
1430+
govc device.info -vm $name -json ethernet-0 | jq -r .devices[].macAddress
14311431
14321432
Options:
14331433
-net= Network [GOVC_NETWORK]
@@ -1447,7 +1447,7 @@ List devices for VM.
14471447
Examples:
14481448
govc device.ls -vm $name
14491449
govc device.ls -vm $name disk-*
1450-
govc device.ls -vm $name -json | jq '.Devices[].Name'
1450+
govc device.ls -vm $name -json | jq '.devices[].name'
14511451
14521452
Options:
14531453
-boot=false List devices configured in the VM's boot options
@@ -4188,7 +4188,7 @@ Examples:
41884188
govc object.collect -s vm/my-vm summary.runtime.host | xargs govc ls -L # inventory path of VM's host
41894189
govc object.collect -dump -o "network/VM Network" # output Managed Object structure as Go code
41904190
govc object.collect -json $vm config | \ # use -json + jq to search array elements
4191-
jq -r '.[] | select(.Val.Hardware.Device[].MacAddress == "00:0c:29:0c:73:c0") | .Val.Name'
4191+
jq -r '.[] | select(.val.hardware.device[].macAddress == "00:0c:29:0c:73:c0") | .val.name'
41924192
41934193
Options:
41944194
-O=false Output the CreateFilter request itself
@@ -6183,7 +6183,7 @@ List IPs for VM.
61836183
By default the vm.ip command depends on vmware-tools to report the 'guest.ipAddress' field and will
61846184
wait until it has done so. This value can also be obtained using:
61856185
6186-
govc vm.info -json $vm | jq -r .VirtualMachines[].guest.ipAddress
6186+
govc vm.info -json $vm | jq -r .virtualMachines[].guest.ipAddress
61876187
61886188
When given the '-a' flag, only IP addresses for which there is a corresponding virtual nic are listed.
61896189
If there are multiple nics, the listed addresses will be comma delimited. The '-a' flag depends on
@@ -6193,7 +6193,7 @@ by tools for which there is no virtual nic are not included, for example that of
61936193
61946194
These values can also be obtained using:
61956195
6196-
govc vm.info -json $vm | jq -r .VirtualMachines[].guest.net[].ipConfig.ipAddress[].ipAddress
6196+
govc vm.info -json $vm | jq -r .virtualMachines[].guest.net[].ipConfig.ipAddress[].ipAddress
61976197
61986198
When given the '-n' flag, filters '-a' behavior to the nic specified by MAC address or device name.
61996199

govc/about/cert.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2016-2023 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -62,7 +62,7 @@ If the '-k' flag is provided, about.cert will return with exit code 0 in this ca
6262
The SHA1 thumbprint can also be used as '-thumbprint' for the 'host.add' and 'cluster.add' commands.
6363
6464
Examples:
65-
govc about.cert -k -json | jq -r .ThumbprintSHA1
65+
govc about.cert -k -json | jq -r .thumbprintSHA1
6666
govc about.cert -k -show | sudo tee /usr/local/share/ca-certificates/host.crt
6767
govc about.cert -k -thumbprint | tee -a ~/.govmomi/known_hosts`
6868
}

govc/about/command.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2014-2016 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -59,7 +59,7 @@ System information including the name, type, version, and build number.
5959
6060
Examples:
6161
govc about
62-
govc about -json | jq -r .About.productLineId`
62+
govc about -json | jq -r .about.productLineId`
6363
}
6464

6565
func (cmd *about) Process(ctx context.Context) error {
@@ -96,9 +96,9 @@ func (cmd *about) Run(ctx context.Context, f *flag.FlagSet) error {
9696
}
9797

9898
type infoResult struct {
99-
Content *types.ServiceContent `json:",omitempty"`
100-
About *types.AboutInfo `json:",omitempty"`
101-
Client *soap.Client `json:",omitempty"`
99+
Content *types.ServiceContent `json:"content,omitempty"`
100+
About *types.AboutInfo `json:"about,omitempty"`
101+
Client *soap.Client `json:"client,omitempty"`
102102
a *types.AboutInfo
103103
}
104104

govc/cluster/override/info.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2017-2023 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -58,15 +58,15 @@ func (cmd *info) Process(ctx context.Context) error {
5858

5959
type Override struct {
6060
id types.ManagedObjectReference
61-
Name string
62-
Host string `json:",omitempty"`
63-
DRS *types.ClusterDrsVmConfigInfo `json:",omitempty"`
64-
DAS *types.ClusterDasVmConfigInfo `json:",omitempty"`
65-
Orchestration *types.ClusterVmOrchestrationInfo `json:",omitempty"`
61+
Name string `json:"name"`
62+
Host string `json:"host,omitempty"`
63+
DRS *types.ClusterDrsVmConfigInfo `json:"drs,omitempty"`
64+
DAS *types.ClusterDasVmConfigInfo `json:"das,omitempty"`
65+
Orchestration *types.ClusterVmOrchestrationInfo `json:"orchestration,omitempty"`
6666
}
6767

6868
type infoResult struct {
69-
Overrides map[string]*Override
69+
Overrides map[string]*Override `json:"overrides"`
7070
}
7171

7272
func (r *infoResult) Write(w io.Writer) error {

govc/cluster/usage.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2020 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2020-2023 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -57,7 +57,7 @@ func (cmd *usage) Description() string {
5757
Examples:
5858
govc cluster.usage ClusterName
5959
govc cluster.usage -S ClusterName # summarize shared storage only
60-
govc cluster.usage -json ClusterName | jq -r .CPU.Summary.Usage`
60+
govc cluster.usage -json ClusterName | jq -r .cpu.summary.usage`
6161
}
6262

6363
func (cmd *usage) Run(ctx context.Context, f *flag.FlagSet) error {
@@ -124,18 +124,18 @@ func (cmd *usage) Run(ctx context.Context, f *flag.FlagSet) error {
124124
}
125125

126126
type ResourceUsageSummary struct {
127-
Used string
128-
Free string
129-
Capacity string
130-
Usage string
127+
Used string `json:"used"`
128+
Free string `json:"free"`
129+
Capacity string `json:"capacity"`
130+
Usage string `json:"usage"`
131131
}
132132

133133
type ResourceUsage struct {
134-
Used int64
135-
Free int64
136-
Capacity int64
137-
Usage float64
138-
Summary ResourceUsageSummary
134+
Used int64 `json:"used"`
135+
Free int64 `json:"free"`
136+
Capacity int64 `json:"capacity"`
137+
Usage float64 `json:"usage"`
138+
Summary ResourceUsageSummary `json:"summary"`
139139
}
140140

141141
func (r *ResourceUsage) summarize(f func(int64) string) {
@@ -163,9 +163,9 @@ func size(val int64) string {
163163
}
164164

165165
type Usage struct {
166-
Memory ResourceUsage
167-
CPU ResourceUsage
168-
Storage ResourceUsage
166+
Memory ResourceUsage `json:"memory"`
167+
CPU ResourceUsage `json:"cpu"`
168+
Storage ResourceUsage `json:"storage"`
169169
}
170170

171171
func (r *Usage) Write(w io.Writer) error {

govc/datacenter/info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2016-2023 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -132,7 +132,7 @@ func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
132132
}
133133

134134
type infoResult struct {
135-
Datacenters []mo.Datacenter
135+
Datacenters []mo.Datacenter `json:"datacenters"`
136136
objects []*object.Datacenter
137137
finder *find.Finder
138138
ctx context.Context

govc/datastore/cluster/info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2018 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2018-2023 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -107,7 +107,7 @@ func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
107107
}
108108

109109
type infoResult struct {
110-
Clusters []mo.StoragePod
110+
Clusters []mo.StoragePod `json:"clusters"`
111111
objects []*object.StoragePod
112112
}
113113

govc/datastore/info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2015 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -180,7 +180,7 @@ func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
180180
}
181181

182182
type infoResult struct {
183-
Datastores []mo.Datastore
183+
Datastores []mo.Datastore `json:"datastores"`
184184
objects []*object.Datastore
185185
}
186186

govc/device/info.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -76,9 +76,9 @@ func (cmd *info) Description() string {
7676
Examples:
7777
govc device.info -vm $name
7878
govc device.info -vm $name disk-*
79-
govc device.info -vm $name -json disk-* | jq -r .Devices[].backing.uuid
80-
govc device.info -vm $name -json 'disk-*' | jq -r .Devices[].backing.fileName # vmdk path
81-
govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].macAddress`
79+
govc device.info -vm $name -json disk-* | jq -r .devices[].backing.uuid
80+
govc device.info -vm $name -json 'disk-*' | jq -r .devices[].backing.fileName # vmdk path
81+
govc device.info -vm $name -json ethernet-0 | jq -r .devices[].macAddress`
8282
}
8383

8484
func match(p string, devices object.VirtualDeviceList) object.VirtualDeviceList {
@@ -166,8 +166,8 @@ func toInfoList(devices object.VirtualDeviceList) []infoDevice {
166166
}
167167

168168
type infoDevice struct {
169-
Name string
170-
Type string
169+
Name string `json:"name"`
170+
Type string `json:"type"`
171171
types.BaseVirtualDevice
172172
}
173173

@@ -183,7 +183,7 @@ func (d *infoDevice) MarshalJSON() ([]byte, error) {
183183
}
184184

185185
type infoResult struct {
186-
Devices []infoDevice
186+
Devices []infoDevice `json:"devices"`
187187
// need the full list of devices to lookup attached devices and controllers
188188
list object.VirtualDeviceList
189189
}

govc/device/ls.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -58,7 +58,7 @@ func (cmd *ls) Description() string {
5858
Examples:
5959
govc device.ls -vm $name
6060
govc device.ls -vm $name disk-*
61-
govc device.ls -vm $name -json | jq '.Devices[].Name'`
61+
govc device.ls -vm $name -json | jq '.devices[].name'`
6262
}
6363

6464
func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error {
@@ -102,9 +102,9 @@ func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error {
102102
}
103103

104104
type lsDevice struct {
105-
Name string
106-
Type string
107-
Summary string
105+
Name string `json:"name"`
106+
Type string `json:"type"`
107+
Summary string `json:"summary"`
108108
}
109109

110110
func toLsList(devices object.VirtualDeviceList) []lsDevice {
@@ -122,7 +122,7 @@ func toLsList(devices object.VirtualDeviceList) []lsDevice {
122122
}
123123

124124
type lsResult struct {
125-
Devices []lsDevice
125+
Devices []lsDevice `json:"devices"`
126126
list object.VirtualDeviceList
127127
}
128128

0 commit comments

Comments
 (0)