runtime: Fix the format of the client code of cloud-hypervisor APIs

Regenerate the client code with the added `go-fmt` step. No functional
changes.

Fixes: #1606

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2021-03-31 14:37:18 -07:00
parent 52cacf8838
commit 0c38d9ecc4
34 changed files with 146 additions and 117 deletions

View File

@ -157,13 +157,12 @@ func parameterToJson(obj interface{}) (string, error) {
return string(jsonBuf), err return string(jsonBuf), err
} }
// callAPI do the request. // callAPI do the request.
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
if c.cfg.Debug { if c.cfg.Debug {
dump, err := httputil.DumpRequestOut(request, true) dump, err := httputil.DumpRequestOut(request, true)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Printf("\n%s\n", string(dump)) log.Printf("\n%s\n", string(dump))
} }

View File

@ -37,7 +37,6 @@ var (
// ContextAPIKey takes an APIKey as authentication for the request // ContextAPIKey takes an APIKey as authentication for the request
ContextAPIKey = contextKey("apikey") ContextAPIKey = contextKey("apikey")
) )
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
@ -52,7 +51,6 @@ type APIKey struct {
Prefix string Prefix string
} }
// ServerVariable stores the information about a server variable // ServerVariable stores the information about a server variable
type ServerVariable struct { type ServerVariable struct {
Description string Description string
@ -62,9 +60,9 @@ type ServerVariable struct {
// ServerConfiguration stores the information about a server // ServerConfiguration stores the information about a server
type ServerConfiguration struct { type ServerConfiguration struct {
Url string Url string
Description string Description string
Variables map[string]ServerVariable Variables map[string]ServerVariable
} }
// Configuration stores the configuration of the API client // Configuration stores the configuration of the API client
@ -86,9 +84,9 @@ func NewConfiguration() *Configuration {
DefaultHeader: make(map[string]string), DefaultHeader: make(map[string]string),
UserAgent: "OpenAPI-Generator/1.0.0/go", UserAgent: "OpenAPI-Generator/1.0.0/go",
Debug: false, Debug: false,
Servers: []ServerConfiguration{ Servers: []ServerConfiguration{
{ {
Url: "http://localhost/api/v1", Url: "http://localhost/api/v1",
Description: "No description provided", Description: "No description provided",
}, },
}, },
@ -104,7 +102,7 @@ func (c *Configuration) AddDefaultHeader(key string, value string) {
// ServerUrl returns URL based on server settings // ServerUrl returns URL based on server settings
func (c *Configuration) ServerUrl(index int, variables map[string]string) (string, error) { func (c *Configuration) ServerUrl(index int, variables map[string]string) (string, error) {
if index < 0 || len(c.Servers) <= index { if index < 0 || len(c.Servers) <= index {
return "", fmt.Errorf("Index %v out of range %v", index, len(c.Servers) - 1) return "", fmt.Errorf("Index %v out of range %v", index, len(c.Servers)-1)
} }
server := c.Servers[index] server := c.Servers[index]
url := server.Url url := server.Url

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// BalloonConfig struct for BalloonConfig // BalloonConfig struct for BalloonConfig
type BalloonConfig struct { type BalloonConfig struct {
Size int64 `json:"size"` Size int64 `json:"size"`

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// CmdLineConfig struct for CmdLineConfig // CmdLineConfig struct for CmdLineConfig
type CmdLineConfig struct { type CmdLineConfig struct {
Args string `json:"args"` Args string `json:"args"`

View File

@ -8,9 +8,10 @@
*/ */
package openapi package openapi
// ConsoleConfig struct for ConsoleConfig // ConsoleConfig struct for ConsoleConfig
type ConsoleConfig struct { type ConsoleConfig struct {
File string `json:"file,omitempty"` File string `json:"file,omitempty"`
Mode string `json:"mode"` Mode string `json:"mode"`
Iommu bool `json:"iommu,omitempty"` Iommu bool `json:"iommu,omitempty"`
} }

View File

@ -8,10 +8,11 @@
*/ */
package openapi package openapi
// CpuTopology struct for CpuTopology // CpuTopology struct for CpuTopology
type CpuTopology struct { type CpuTopology struct {
ThreadsPerCore int32 `json:"threads_per_core,omitempty"` ThreadsPerCore int32 `json:"threads_per_core,omitempty"`
CoresPerDie int32 `json:"cores_per_die,omitempty"` CoresPerDie int32 `json:"cores_per_die,omitempty"`
DiesPerPackage int32 `json:"dies_per_package,omitempty"` DiesPerPackage int32 `json:"dies_per_package,omitempty"`
Packages int32 `json:"packages,omitempty"` Packages int32 `json:"packages,omitempty"`
} }

View File

@ -8,10 +8,11 @@
*/ */
package openapi package openapi
// CpusConfig struct for CpusConfig // CpusConfig struct for CpusConfig
type CpusConfig struct { type CpusConfig struct {
BootVcpus int32 `json:"boot_vcpus"` BootVcpus int32 `json:"boot_vcpus"`
MaxVcpus int32 `json:"max_vcpus"` MaxVcpus int32 `json:"max_vcpus"`
Topology CpuTopology `json:"topology,omitempty"` Topology CpuTopology `json:"topology,omitempty"`
MaxPhysBits int32 `json:"max_phys_bits,omitempty"` MaxPhysBits int32 `json:"max_phys_bits,omitempty"`
} }

View File

@ -8,9 +8,10 @@
*/ */
package openapi package openapi
// DeviceConfig struct for DeviceConfig // DeviceConfig struct for DeviceConfig
type DeviceConfig struct { type DeviceConfig struct {
Path string `json:"path"` Path string `json:"path"`
Iommu bool `json:"iommu,omitempty"` Iommu bool `json:"iommu,omitempty"`
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
} }

View File

@ -8,10 +8,11 @@
*/ */
package openapi package openapi
// DeviceNode struct for DeviceNode // DeviceNode struct for DeviceNode
type DeviceNode struct { type DeviceNode struct {
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
Resources []map[string]interface{} `json:"resources,omitempty"` Resources []map[string]interface{} `json:"resources,omitempty"`
Children []string `json:"children,omitempty"` Children []string `json:"children,omitempty"`
PciBdf int32 `json:"pci_bdf,omitempty"` PciBdf int32 `json:"pci_bdf,omitempty"`
} }

View File

@ -8,17 +8,18 @@
*/ */
package openapi package openapi
// DiskConfig struct for DiskConfig // DiskConfig struct for DiskConfig
type DiskConfig struct { type DiskConfig struct {
Path string `json:"path"` Path string `json:"path"`
Readonly bool `json:"readonly,omitempty"` Readonly bool `json:"readonly,omitempty"`
Direct bool `json:"direct,omitempty"` Direct bool `json:"direct,omitempty"`
Iommu bool `json:"iommu,omitempty"` Iommu bool `json:"iommu,omitempty"`
NumQueues int32 `json:"num_queues,omitempty"` NumQueues int32 `json:"num_queues,omitempty"`
QueueSize int32 `json:"queue_size,omitempty"` QueueSize int32 `json:"queue_size,omitempty"`
VhostUser bool `json:"vhost_user,omitempty"` VhostUser bool `json:"vhost_user,omitempty"`
VhostSocket string `json:"vhost_socket,omitempty"` VhostSocket string `json:"vhost_socket,omitempty"`
PollQueue bool `json:"poll_queue,omitempty"` PollQueue bool `json:"poll_queue,omitempty"`
RateLimiterConfig RateLimiterConfig `json:"rate_limiter_config,omitempty"` RateLimiterConfig RateLimiterConfig `json:"rate_limiter_config,omitempty"`
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
} }

View File

@ -8,13 +8,14 @@
*/ */
package openapi package openapi
// FsConfig struct for FsConfig // FsConfig struct for FsConfig
type FsConfig struct { type FsConfig struct {
Tag string `json:"tag"` Tag string `json:"tag"`
Socket string `json:"socket"` Socket string `json:"socket"`
NumQueues int32 `json:"num_queues"` NumQueues int32 `json:"num_queues"`
QueueSize int32 `json:"queue_size"` QueueSize int32 `json:"queue_size"`
Dax bool `json:"dax"` Dax bool `json:"dax"`
CacheSize int64 `json:"cache_size"` CacheSize int64 `json:"cache_size"`
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
} }

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// InitramfsConfig struct for InitramfsConfig // InitramfsConfig struct for InitramfsConfig
type InitramfsConfig struct { type InitramfsConfig struct {
Path string `json:"path"` Path string `json:"path"`

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// KernelConfig struct for KernelConfig // KernelConfig struct for KernelConfig
type KernelConfig struct { type KernelConfig struct {
Path string `json:"path"` Path string `json:"path"`

View File

@ -8,15 +8,16 @@
*/ */
package openapi package openapi
// MemoryConfig struct for MemoryConfig // MemoryConfig struct for MemoryConfig
type MemoryConfig struct { type MemoryConfig struct {
Size int64 `json:"size"` Size int64 `json:"size"`
HotplugSize int64 `json:"hotplug_size,omitempty"` HotplugSize int64 `json:"hotplug_size,omitempty"`
HotpluggedSize int64 `json:"hotplugged_size,omitempty"` HotpluggedSize int64 `json:"hotplugged_size,omitempty"`
Mergeable bool `json:"mergeable,omitempty"` Mergeable bool `json:"mergeable,omitempty"`
HotplugMethod string `json:"hotplug_method,omitempty"` HotplugMethod string `json:"hotplug_method,omitempty"`
Shared bool `json:"shared,omitempty"` Shared bool `json:"shared,omitempty"`
Hugepages bool `json:"hugepages,omitempty"` Hugepages bool `json:"hugepages,omitempty"`
HugepageSize int64 `json:"hugepage_size,omitempty"` HugepageSize int64 `json:"hugepage_size,omitempty"`
Zones []MemoryZoneConfig `json:"zones,omitempty"` Zones []MemoryZoneConfig `json:"zones,omitempty"`
} }

View File

@ -8,16 +8,17 @@
*/ */
package openapi package openapi
// MemoryZoneConfig struct for MemoryZoneConfig // MemoryZoneConfig struct for MemoryZoneConfig
type MemoryZoneConfig struct { type MemoryZoneConfig struct {
Id string `json:"id"` Id string `json:"id"`
Size int64 `json:"size"` Size int64 `json:"size"`
File string `json:"file,omitempty"` File string `json:"file,omitempty"`
Mergeable bool `json:"mergeable,omitempty"` Mergeable bool `json:"mergeable,omitempty"`
Shared bool `json:"shared,omitempty"` Shared bool `json:"shared,omitempty"`
Hugepages bool `json:"hugepages,omitempty"` Hugepages bool `json:"hugepages,omitempty"`
HugepageSize int64 `json:"hugepage_size,omitempty"` HugepageSize int64 `json:"hugepage_size,omitempty"`
HostNumaNode int32 `json:"host_numa_node,omitempty"` HostNumaNode int32 `json:"host_numa_node,omitempty"`
HotplugSize int64 `json:"hotplug_size,omitempty"` HotplugSize int64 `json:"hotplug_size,omitempty"`
HotpluggedSize int64 `json:"hotplugged_size,omitempty"` HotpluggedSize int64 `json:"hotplugged_size,omitempty"`
} }

View File

@ -8,17 +8,18 @@
*/ */
package openapi package openapi
// NetConfig struct for NetConfig // NetConfig struct for NetConfig
type NetConfig struct { type NetConfig struct {
Tap string `json:"tap,omitempty"` Tap string `json:"tap,omitempty"`
Ip string `json:"ip,omitempty"` Ip string `json:"ip,omitempty"`
Mask string `json:"mask,omitempty"` Mask string `json:"mask,omitempty"`
Mac string `json:"mac,omitempty"` Mac string `json:"mac,omitempty"`
Iommu bool `json:"iommu,omitempty"` Iommu bool `json:"iommu,omitempty"`
NumQueues int32 `json:"num_queues,omitempty"` NumQueues int32 `json:"num_queues,omitempty"`
QueueSize int32 `json:"queue_size,omitempty"` QueueSize int32 `json:"queue_size,omitempty"`
VhostUser bool `json:"vhost_user,omitempty"` VhostUser bool `json:"vhost_user,omitempty"`
VhostSocket string `json:"vhost_socket,omitempty"` VhostSocket string `json:"vhost_socket,omitempty"`
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
Fd []int32 `json:"fd,omitempty"` Fd []int32 `json:"fd,omitempty"`
} }

View File

@ -8,10 +8,11 @@
*/ */
package openapi package openapi
// NumaConfig struct for NumaConfig // NumaConfig struct for NumaConfig
type NumaConfig struct { type NumaConfig struct {
GuestNumaId int32 `json:"guest_numa_id"` GuestNumaId int32 `json:"guest_numa_id"`
Cpus []int32 `json:"cpus,omitempty"` Cpus []int32 `json:"cpus,omitempty"`
Distances []NumaDistance `json:"distances,omitempty"` Distances []NumaDistance `json:"distances,omitempty"`
MemoryZones []string `json:"memory_zones,omitempty"` MemoryZones []string `json:"memory_zones,omitempty"`
} }

View File

@ -8,8 +8,9 @@
*/ */
package openapi package openapi
// NumaDistance struct for NumaDistance // NumaDistance struct for NumaDistance
type NumaDistance struct { type NumaDistance struct {
Destination int32 `json:"destination"` Destination int32 `json:"destination"`
Distance int32 `json:"distance"` Distance int32 `json:"distance"`
} }

View File

@ -8,8 +8,9 @@
*/ */
package openapi package openapi
// PciDeviceInfo Information about a PCI device // PciDeviceInfo Information about a PCI device
type PciDeviceInfo struct { type PciDeviceInfo struct {
Id string `json:"id"` Id string `json:"id"`
Bdf string `json:"bdf"` Bdf string `json:"bdf"`
} }

View File

@ -8,12 +8,13 @@
*/ */
package openapi package openapi
// PmemConfig struct for PmemConfig // PmemConfig struct for PmemConfig
type PmemConfig struct { type PmemConfig struct {
File string `json:"file"` File string `json:"file"`
Size int64 `json:"size,omitempty"` Size int64 `json:"size,omitempty"`
Iommu bool `json:"iommu,omitempty"` Iommu bool `json:"iommu,omitempty"`
Mergeable bool `json:"mergeable,omitempty"` Mergeable bool `json:"mergeable,omitempty"`
DiscardWrites bool `json:"discard_writes,omitempty"` DiscardWrites bool `json:"discard_writes,omitempty"`
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
} }

View File

@ -8,8 +8,9 @@
*/ */
package openapi package openapi
// RateLimiterConfig Defines an IO rate limiter with independent bytes/s and ops/s limits. Limits are defined by configuring each of the _bandwidth_ and _ops_ token buckets. // RateLimiterConfig Defines an IO rate limiter with independent bytes/s and ops/s limits. Limits are defined by configuring each of the _bandwidth_ and _ops_ token buckets.
type RateLimiterConfig struct { type RateLimiterConfig struct {
Bandwidth TokenBucket `json:"bandwidth,omitempty"` Bandwidth TokenBucket `json:"bandwidth,omitempty"`
Ops TokenBucket `json:"ops,omitempty"` Ops TokenBucket `json:"ops,omitempty"`
} }

View File

@ -8,8 +8,9 @@
*/ */
package openapi package openapi
// RestoreConfig struct for RestoreConfig // RestoreConfig struct for RestoreConfig
type RestoreConfig struct { type RestoreConfig struct {
SourceUrl string `json:"source_url"` SourceUrl string `json:"source_url"`
Prefault bool `json:"prefault,omitempty"` Prefault bool `json:"prefault,omitempty"`
} }

View File

@ -8,8 +8,9 @@
*/ */
package openapi package openapi
// RngConfig struct for RngConfig // RngConfig struct for RngConfig
type RngConfig struct { type RngConfig struct {
Src string `json:"src"` Src string `json:"src"`
Iommu bool `json:"iommu,omitempty"` Iommu bool `json:"iommu,omitempty"`
} }

View File

@ -8,8 +8,9 @@
*/ */
package openapi package openapi
// SgxEpcConfig struct for SgxEpcConfig // SgxEpcConfig struct for SgxEpcConfig
type SgxEpcConfig struct { type SgxEpcConfig struct {
Size int64 `json:"size"` Size int64 `json:"size"`
Prefault bool `json:"prefault,omitempty"` Prefault bool `json:"prefault,omitempty"`
} }

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// TokenBucket Defines a token bucket with a maximum capacity (_size_), an initial burst size (_one_time_burst_) and an interval for refilling purposes (_refill_time_). The refill-rate is derived from _size_ and _refill_time_, and it is the constant rate at which the tokens replenish. The refill process only starts happening after the initial burst budget is consumed. Consumption from the token bucket is unbounded in speed which allows for bursts bound in size by the amount of tokens available. Once the token bucket is empty, consumption speed is bound by the refill-rate. // TokenBucket Defines a token bucket with a maximum capacity (_size_), an initial burst size (_one_time_burst_) and an interval for refilling purposes (_refill_time_). The refill-rate is derived from _size_ and _refill_time_, and it is the constant rate at which the tokens replenish. The refill process only starts happening after the initial burst budget is consumed. Consumption from the token bucket is unbounded in speed which allows for bursts bound in size by the amount of tokens available. Once the token bucket is empty, consumption speed is bound by the refill-rate.
type TokenBucket struct { type TokenBucket struct {
// The total number of tokens this bucket can hold. // The total number of tokens this bucket can hold.

View File

@ -8,9 +8,10 @@
*/ */
package openapi package openapi
// VmAddDevice struct for VmAddDevice // VmAddDevice struct for VmAddDevice
type VmAddDevice struct { type VmAddDevice struct {
Path string `json:"path,omitempty"` Path string `json:"path,omitempty"`
Iommu bool `json:"iommu,omitempty"` Iommu bool `json:"iommu,omitempty"`
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
} }

View File

@ -8,25 +8,26 @@
*/ */
package openapi package openapi
// VmConfig Virtual machine configuration // VmConfig Virtual machine configuration
type VmConfig struct { type VmConfig struct {
Cpus CpusConfig `json:"cpus,omitempty"` Cpus CpusConfig `json:"cpus,omitempty"`
Memory MemoryConfig `json:"memory,omitempty"` Memory MemoryConfig `json:"memory,omitempty"`
Kernel KernelConfig `json:"kernel"` Kernel KernelConfig `json:"kernel"`
Initramfs *InitramfsConfig `json:"initramfs,omitempty"` Initramfs *InitramfsConfig `json:"initramfs,omitempty"`
Cmdline CmdLineConfig `json:"cmdline,omitempty"` Cmdline CmdLineConfig `json:"cmdline,omitempty"`
Disks []DiskConfig `json:"disks,omitempty"` Disks []DiskConfig `json:"disks,omitempty"`
Net []NetConfig `json:"net,omitempty"` Net []NetConfig `json:"net,omitempty"`
Rng RngConfig `json:"rng,omitempty"` Rng RngConfig `json:"rng,omitempty"`
Balloon BalloonConfig `json:"balloon,omitempty"` Balloon BalloonConfig `json:"balloon,omitempty"`
Fs []FsConfig `json:"fs,omitempty"` Fs []FsConfig `json:"fs,omitempty"`
Pmem []PmemConfig `json:"pmem,omitempty"` Pmem []PmemConfig `json:"pmem,omitempty"`
Serial ConsoleConfig `json:"serial,omitempty"` Serial ConsoleConfig `json:"serial,omitempty"`
Console ConsoleConfig `json:"console,omitempty"` Console ConsoleConfig `json:"console,omitempty"`
Devices []DeviceConfig `json:"devices,omitempty"` Devices []DeviceConfig `json:"devices,omitempty"`
Vsock VsockConfig `json:"vsock,omitempty"` Vsock VsockConfig `json:"vsock,omitempty"`
SgxEpc []SgxEpcConfig `json:"sgx_epc,omitempty"` SgxEpc []SgxEpcConfig `json:"sgx_epc,omitempty"`
Numa []NumaConfig `json:"numa,omitempty"` Numa []NumaConfig `json:"numa,omitempty"`
Iommu bool `json:"iommu,omitempty"` Iommu bool `json:"iommu,omitempty"`
Watchdog bool `json:"watchdog,omitempty"` Watchdog bool `json:"watchdog,omitempty"`
} }

View File

@ -8,10 +8,11 @@
*/ */
package openapi package openapi
// VmInfo Virtual Machine information // VmInfo Virtual Machine information
type VmInfo struct { type VmInfo struct {
Config VmConfig `json:"config"` Config VmConfig `json:"config"`
State string `json:"state"` State string `json:"state"`
MemoryActualSize int64 `json:"memory_actual_size,omitempty"` MemoryActualSize int64 `json:"memory_actual_size,omitempty"`
DeviceTree map[string]DeviceNode `json:"device_tree,omitempty"` DeviceTree map[string]DeviceNode `json:"device_tree,omitempty"`
} }

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// VmRemoveDevice struct for VmRemoveDevice // VmRemoveDevice struct for VmRemoveDevice
type VmRemoveDevice struct { type VmRemoveDevice struct {
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// VmResize struct for VmResize // VmResize struct for VmResize
type VmResize struct { type VmResize struct {
DesiredVcpus int32 `json:"desired_vcpus,omitempty"` DesiredVcpus int32 `json:"desired_vcpus,omitempty"`

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// VmResizeZone struct for VmResizeZone // VmResizeZone struct for VmResizeZone
type VmResizeZone struct { type VmResizeZone struct {
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// VmSnapshotConfig struct for VmSnapshotConfig // VmSnapshotConfig struct for VmSnapshotConfig
type VmSnapshotConfig struct { type VmSnapshotConfig struct {
DestinationUrl string `json:"destination_url,omitempty"` DestinationUrl string `json:"destination_url,omitempty"`

View File

@ -8,6 +8,7 @@
*/ */
package openapi package openapi
// VmmPingResponse Virtual Machine Monitor information // VmmPingResponse Virtual Machine Monitor information
type VmmPingResponse struct { type VmmPingResponse struct {
Version string `json:"version"` Version string `json:"version"`

View File

@ -8,12 +8,13 @@
*/ */
package openapi package openapi
// VsockConfig struct for VsockConfig // VsockConfig struct for VsockConfig
type VsockConfig struct { type VsockConfig struct {
// Guest Vsock CID // Guest Vsock CID
Cid int64 `json:"cid"` Cid int64 `json:"cid"`
// Path to UNIX domain socket, used to proxy vsock connections. // Path to UNIX domain socket, used to proxy vsock connections.
Socket string `json:"socket"` Socket string `json:"socket"`
Iommu bool `json:"iommu,omitempty"` Iommu bool `json:"iommu,omitempty"`
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
} }