[lxc-devel] [lxd/master] Extra api annotations
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Jan 4 03:32:08 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170104/694aa3a3/attachment.bin>
-------------- next part --------------
From 04816c6355bdd897b65b0fc4d405768cdd760656 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 3 Jan 2017 22:29:12 -0500
Subject: [PATCH 1/2] api: comment style
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
shared/api/container.go | 8 ++++----
shared/api/response.go | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/shared/api/container.go b/shared/api/container.go
index 7c25ee9..7f7ca11 100644
--- a/shared/api/container.go
+++ b/shared/api/container.go
@@ -64,7 +64,7 @@ type ContainerSource struct {
Type string `json:"type"`
Certificate string `json:"certificate"`
- /* For "image" type */
+ // For "image" type
Alias string `json:"alias,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
@@ -72,15 +72,15 @@ type ContainerSource struct {
Secret string `json:"secret,omitempty"`
Protocol string `json:"protocol,omitempty"`
- /* For "migration" and "copy" types */
+ // For "migration" and "copy" types
BaseImage string `json:"base-image,omitempty"`
- /* For "migration" type */
+ // For "migration" type
Mode string `json:"mode,omitempty"`
Operation string `json:"operation,omitempty"`
Websockets map[string]string `json:"secrets,omitempty"`
Live bool `json:"live,omitempty"`
- /* For "copy" type */
+ // For "copy" type
Source string `json:"source,omitempty"`
}
diff --git a/shared/api/response.go b/shared/api/response.go
index 846343f..a049c4c 100644
--- a/shared/api/response.go
+++ b/shared/api/response.go
@@ -15,18 +15,18 @@ type ResponseRaw struct {
type Response struct {
Type ResponseType `json:"type"`
- /* Valid only for Sync responses */
+ // Valid only for Sync responses
Status string `json:"status"`
StatusCode int `json:"status_code"`
- /* Valid only for Async responses */
+ // Valid only for Async responses
Operation string `json:"operation"`
- /* Valid only for Error responses */
+ // Valid only for Error responses
Code int `json:"error_code"`
Error string `json:"error"`
- /* Valid for Sync and Error responses */
+ // Valid for Sync and Error responses
Metadata json.RawMessage `json:"metadata"`
}
From 9edfcb050a2fa561bf2a4ca01b1bb4fb9c0641c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 3 Jan 2017 22:29:20 -0500
Subject: [PATCH 2/2] api: Record API extensions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
shared/api/certificate.go | 2 ++
shared/api/container.go | 6 +++++-
shared/api/container_exec.go | 4 +++-
shared/api/container_state.go | 4 +++-
shared/api/image.go | 4 +++-
shared/api/network.go | 8 +++++++-
shared/api/profile.go | 2 ++
7 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/shared/api/certificate.go b/shared/api/certificate.go
index e8ec0f3..2dd0c51 100644
--- a/shared/api/certificate.go
+++ b/shared/api/certificate.go
@@ -9,6 +9,8 @@ type CertificatesPost struct {
}
// CertificatePut represents the modifiable fields of a LXD certificate
+//
+// API extension: certificate_update
type CertificatePut struct {
Name string `json:"name"`
Type string `json:"type"`
diff --git a/shared/api/container.go b/shared/api/container.go
index 7f7ca11..2698092 100644
--- a/shared/api/container.go
+++ b/shared/api/container.go
@@ -35,11 +35,13 @@ type Container struct {
CreatedAt time.Time `json:"created_at"`
ExpandedConfig map[string]string `json:"expanded_config"`
ExpandedDevices map[string]map[string]string `json:"expanded_devices"`
- LastUsedAt time.Time `json:"last_used_at"`
Name string `json:"name"`
Stateful bool `json:"stateful"`
Status string `json:"status"`
StatusCode StatusCode `json:"status_code"`
+
+ // API extension: container_last_used_at
+ LastUsedAt time.Time `json:"last_used_at"`
}
// Writable converts a full Container struct into a ContainerPut struct (filters read-only fields)
@@ -79,6 +81,8 @@ type ContainerSource struct {
Mode string `json:"mode,omitempty"`
Operation string `json:"operation,omitempty"`
Websockets map[string]string `json:"secrets,omitempty"`
+
+ // API extension: container_push
Live bool `json:"live,omitempty"`
// For "copy" type
diff --git a/shared/api/container_exec.go b/shared/api/container_exec.go
index ab84972..4013bce 100644
--- a/shared/api/container_exec.go
+++ b/shared/api/container_exec.go
@@ -11,9 +11,11 @@ type ContainerExecControl struct {
type ContainerExecPost struct {
Command []string `json:"command"`
WaitForWS bool `json:"wait-for-websocket"`
- RecordOutput bool `json:"record-output"`
Interactive bool `json:"interactive"`
Environment map[string]string `json:"environment"`
Width int `json:"width"`
Height int `json:"height"`
+
+ // API extension: container_exec_recording
+ RecordOutput bool `json:"record-output"`
}
diff --git a/shared/api/container_state.go b/shared/api/container_state.go
index 43bc621..00c8dd3 100644
--- a/shared/api/container_state.go
+++ b/shared/api/container_state.go
@@ -12,12 +12,14 @@ type ContainerStatePut struct {
type ContainerState struct {
Status string `json:"status"`
StatusCode StatusCode `json:"status_code"`
- CPU ContainerStateCPU `json:"cpu"`
Disk map[string]ContainerStateDisk `json:"disk"`
Memory ContainerStateMemory `json:"memory"`
Network map[string]ContainerStateNetwork `json:"network"`
Pid int64 `json:"pid"`
Processes int64 `json:"processes"`
+
+ // API extension: container_cpu_time
+ CPU ContainerStateCPU `json:"cpu"`
}
// ContainerStateDisk represents the disk information section of a LXD container's state
diff --git a/shared/api/image.go b/shared/api/image.go
index 7b63385..5b7829c 100644
--- a/shared/api/image.go
+++ b/shared/api/image.go
@@ -8,9 +8,11 @@ import (
type ImagesPost struct {
ImagePut `yaml:",inline"`
- CompressionAlgorithm string `json:"compression_algorithm"`
Filename string `json:"filename"`
Source map[string]string `json:"source"`
+
+ // API extension: image_compression_algorithm
+ CompressionAlgorithm string `json:"compression_algorithm"`
}
// ImagePut represents the modifiable fields of a LXD image
diff --git a/shared/api/network.go b/shared/api/network.go
index ef44bef..989214e 100644
--- a/shared/api/network.go
+++ b/shared/api/network.go
@@ -10,11 +10,15 @@ type NetworksPost struct {
}
// NetworkPost represents the fields required to rename a LXD network
+//
+// API extension: network
type NetworkPost struct {
Name string `json:"name"`
}
// NetworkPut represents the modifiable fields of a LXD network
+//
+// API extension: network
type NetworkPut struct {
Config map[string]string `json:"config"`
}
@@ -23,10 +27,12 @@ type NetworkPut struct {
type Network struct {
NetworkPut `yaml:",inline"`
- Managed bool `json:"managed"`
Name string `json:"name"`
Type string `json:"type"`
UsedBy []string `json:"used_by"`
+
+ // API extension: network
+ Managed bool `json:"managed"`
}
// Writable converts a full Network struct into a NetworkPut struct (filters read-only fields)
diff --git a/shared/api/profile.go b/shared/api/profile.go
index fb52957..e4f9cba 100644
--- a/shared/api/profile.go
+++ b/shared/api/profile.go
@@ -24,6 +24,8 @@ type Profile struct {
ProfilePut `yaml:",inline"`
Name string `json:"name"`
+
+ // API extension: profile_usedby
UsedBy []string `json:"used_by"`
}
More information about the lxc-devel
mailing list