Skip to content
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

govc: camelCase json output #3247

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
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
20 changes: 10 additions & 10 deletions govc/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ System information including the name, type, version, and build number.

Examples:
govc about
govc about -json | jq -r .About.productLineId
govc about -json | jq -r .about.productLineId

Options:
-c=false Include client info
Expand All @@ -411,7 +411,7 @@ If the '-k' flag is provided, about.cert will return with exit code 0 in this ca
The SHA1 thumbprint can also be used as '-thumbprint' for the 'host.add' and 'cluster.add' commands.

Examples:
govc about.cert -k -json | jq -r .ThumbprintSHA1
govc about.cert -k -json | jq -r .thumbprintSHA1
govc about.cert -k -show | sudo tee /usr/local/share/ca-certificates/host.crt
govc about.cert -k -thumbprint | tee -a ~/.govmomi/known_hosts

Expand Down Expand Up @@ -853,7 +853,7 @@ Cluster resource usage summary.
Examples:
govc cluster.usage ClusterName
govc cluster.usage -S ClusterName # summarize shared storage only
govc cluster.usage -json ClusterName | jq -r .CPU.Summary.Usage
govc cluster.usage -json ClusterName | jq -r .cpu.summary.usage

Options:
-S=false Exclude host local storage
Expand Down Expand Up @@ -1425,9 +1425,9 @@ Device info for VM.
Examples:
govc device.info -vm $name
govc device.info -vm $name disk-*
govc device.info -vm $name -json disk-* | jq -r .Devices[].backing.uuid
govc device.info -vm $name -json 'disk-*' | jq -r .Devices[].backing.fileName # vmdk path
govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].macAddress
govc device.info -vm $name -json disk-* | jq -r .devices[].backing.uuid
govc device.info -vm $name -json 'disk-*' | jq -r .devices[].backing.fileName # vmdk path
govc device.info -vm $name -json ethernet-0 | jq -r .devices[].macAddress

Options:
-net= Network [GOVC_NETWORK]
Expand All @@ -1447,7 +1447,7 @@ List devices for VM.
Examples:
govc device.ls -vm $name
govc device.ls -vm $name disk-*
govc device.ls -vm $name -json | jq '.Devices[].Name'
govc device.ls -vm $name -json | jq '.devices[].name'

Options:
-boot=false List devices configured in the VM's boot options
Expand Down Expand Up @@ -4188,7 +4188,7 @@ Examples:
govc object.collect -s vm/my-vm summary.runtime.host | xargs govc ls -L # inventory path of VM's host
govc object.collect -dump -o "network/VM Network" # output Managed Object structure as Go code
govc object.collect -json $vm config | \ # use -json + jq to search array elements
jq -r '.[] | select(.Val.Hardware.Device[].MacAddress == "00:0c:29:0c:73:c0") | .Val.Name'
jq -r '.[] | select(.val.hardware.device[].macAddress == "00:0c:29:0c:73:c0") | .val.name'

Options:
-O=false Output the CreateFilter request itself
Expand Down Expand Up @@ -6183,7 +6183,7 @@ List IPs for VM.
By default the vm.ip command depends on vmware-tools to report the 'guest.ipAddress' field and will
wait until it has done so. This value can also be obtained using:

govc vm.info -json $vm | jq -r .VirtualMachines[].guest.ipAddress
govc vm.info -json $vm | jq -r .virtualMachines[].guest.ipAddress

When given the '-a' flag, only IP addresses for which there is a corresponding virtual nic are listed.
If there are multiple nics, the listed addresses will be comma delimited. The '-a' flag depends on
Expand All @@ -6193,7 +6193,7 @@ by tools for which there is no virtual nic are not included, for example that of

These values can also be obtained using:

govc vm.info -json $vm | jq -r .VirtualMachines[].guest.net[].ipConfig.ipAddress[].ipAddress
govc vm.info -json $vm | jq -r .virtualMachines[].guest.net[].ipConfig.ipAddress[].ipAddress

When given the '-n' flag, filters '-a' behavior to the nic specified by MAC address or device name.

Expand Down
6 changes: 3 additions & 3 deletions govc/about/cert.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2016-2023 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -62,7 +62,7 @@ If the '-k' flag is provided, about.cert will return with exit code 0 in this ca
The SHA1 thumbprint can also be used as '-thumbprint' for the 'host.add' and 'cluster.add' commands.

Examples:
govc about.cert -k -json | jq -r .ThumbprintSHA1
govc about.cert -k -json | jq -r .thumbprintSHA1
govc about.cert -k -show | sudo tee /usr/local/share/ca-certificates/host.crt
govc about.cert -k -thumbprint | tee -a ~/.govmomi/known_hosts`
}
Expand Down
12 changes: 6 additions & 6 deletions govc/about/command.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -59,7 +59,7 @@ System information including the name, type, version, and build number.

Examples:
govc about
govc about -json | jq -r .About.productLineId`
govc about -json | jq -r .about.productLineId`
}

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

type infoResult struct {
Content *types.ServiceContent `json:",omitempty"`
About *types.AboutInfo `json:",omitempty"`
Client *soap.Client `json:",omitempty"`
Content *types.ServiceContent `json:"content,omitempty"`
About *types.AboutInfo `json:"about,omitempty"`
Client *soap.Client `json:"client,omitempty"`
a *types.AboutInfo
}

Expand Down
16 changes: 8 additions & 8 deletions govc/cluster/override/info.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2017-2023 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -58,15 +58,15 @@ func (cmd *info) Process(ctx context.Context) error {

type Override struct {
id types.ManagedObjectReference
Name string
Host string `json:",omitempty"`
DRS *types.ClusterDrsVmConfigInfo `json:",omitempty"`
DAS *types.ClusterDasVmConfigInfo `json:",omitempty"`
Orchestration *types.ClusterVmOrchestrationInfo `json:",omitempty"`
Name string `json:"name"`
Host string `json:"host,omitempty"`
DRS *types.ClusterDrsVmConfigInfo `json:"drs,omitempty"`
DAS *types.ClusterDasVmConfigInfo `json:"das,omitempty"`
Orchestration *types.ClusterVmOrchestrationInfo `json:"orchestration,omitempty"`
}

type infoResult struct {
Overrides map[string]*Override
Overrides map[string]*Override `json:"overrides"`
}

func (r *infoResult) Write(w io.Writer) error {
Expand Down
30 changes: 15 additions & 15 deletions govc/cluster/usage.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2020 VMware, Inc. All Rights Reserved.
Copyright (c) 2020-2023 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -57,7 +57,7 @@ func (cmd *usage) Description() string {
Examples:
govc cluster.usage ClusterName
govc cluster.usage -S ClusterName # summarize shared storage only
govc cluster.usage -json ClusterName | jq -r .CPU.Summary.Usage`
govc cluster.usage -json ClusterName | jq -r .cpu.summary.usage`
}

func (cmd *usage) Run(ctx context.Context, f *flag.FlagSet) error {
Expand Down Expand Up @@ -124,18 +124,18 @@ func (cmd *usage) Run(ctx context.Context, f *flag.FlagSet) error {
}

type ResourceUsageSummary struct {
Used string
Free string
Capacity string
Usage string
Used string `json:"used"`
Free string `json:"free"`
Capacity string `json:"capacity"`
Usage string `json:"usage"`
}

type ResourceUsage struct {
Used int64
Free int64
Capacity int64
Usage float64
Summary ResourceUsageSummary
Used int64 `json:"used"`
Free int64 `json:"free"`
Capacity int64 `json:"capacity"`
Usage float64 `json:"usage"`
Summary ResourceUsageSummary `json:"summary"`
}

func (r *ResourceUsage) summarize(f func(int64) string) {
Expand Down Expand Up @@ -163,9 +163,9 @@ func size(val int64) string {
}

type Usage struct {
Memory ResourceUsage
CPU ResourceUsage
Storage ResourceUsage
Memory ResourceUsage `json:"memory"`
CPU ResourceUsage `json:"cpu"`
Storage ResourceUsage `json:"storage"`
}

func (r *Usage) Write(w io.Writer) error {
Expand Down
6 changes: 3 additions & 3 deletions govc/datacenter/info.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2016-2023 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -132,7 +132,7 @@ func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
}

type infoResult struct {
Datacenters []mo.Datacenter
Datacenters []mo.Datacenter `json:"datacenters"`
objects []*object.Datacenter
finder *find.Finder
ctx context.Context
Expand Down
6 changes: 3 additions & 3 deletions govc/datastore/cluster/info.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2018 VMware, Inc. All Rights Reserved.
Copyright (c) 2018-2023 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -107,7 +107,7 @@ func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
}

type infoResult struct {
Clusters []mo.StoragePod
Clusters []mo.StoragePod `json:"clusters"`
objects []*object.StoragePod
}

Expand Down
6 changes: 3 additions & 3 deletions govc/datastore/info.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2015 VMware, Inc. All Rights Reserved.
Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -180,7 +180,7 @@ func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
}

type infoResult struct {
Datastores []mo.Datastore
Datastores []mo.Datastore `json:"datastores"`
objects []*object.Datastore
}

Expand Down
16 changes: 8 additions & 8 deletions govc/device/info.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -76,9 +76,9 @@ func (cmd *info) Description() string {
Examples:
govc device.info -vm $name
govc device.info -vm $name disk-*
govc device.info -vm $name -json disk-* | jq -r .Devices[].backing.uuid
govc device.info -vm $name -json 'disk-*' | jq -r .Devices[].backing.fileName # vmdk path
govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].macAddress`
govc device.info -vm $name -json disk-* | jq -r .devices[].backing.uuid
govc device.info -vm $name -json 'disk-*' | jq -r .devices[].backing.fileName # vmdk path
govc device.info -vm $name -json ethernet-0 | jq -r .devices[].macAddress`
}

func match(p string, devices object.VirtualDeviceList) object.VirtualDeviceList {
Expand Down Expand Up @@ -166,8 +166,8 @@ func toInfoList(devices object.VirtualDeviceList) []infoDevice {
}

type infoDevice struct {
Name string
Type string
Name string `json:"name"`
Type string `json:"type"`
types.BaseVirtualDevice
}

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

type infoResult struct {
Devices []infoDevice
Devices []infoDevice `json:"devices"`
// need the full list of devices to lookup attached devices and controllers
list object.VirtualDeviceList
}
Expand Down
14 changes: 7 additions & 7 deletions govc/device/ls.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -58,7 +58,7 @@ func (cmd *ls) Description() string {
Examples:
govc device.ls -vm $name
govc device.ls -vm $name disk-*
govc device.ls -vm $name -json | jq '.Devices[].Name'`
govc device.ls -vm $name -json | jq '.devices[].name'`
}

func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error {
Expand Down Expand Up @@ -102,9 +102,9 @@ func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error {
}

type lsDevice struct {
Name string
Type string
Summary string
Name string `json:"name"`
Type string `json:"type"`
Summary string `json:"summary"`
}

func toLsList(devices object.VirtualDeviceList) []lsDevice {
Expand All @@ -122,7 +122,7 @@ func toLsList(devices object.VirtualDeviceList) []lsDevice {
}

type lsResult struct {
Devices []lsDevice
Devices []lsDevice `json:"devices"`
list object.VirtualDeviceList
}

Expand Down
Loading