The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2747
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From e102bd2d087a4ba34ac2034853c80883c9503c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Mon, 19 Dec 2016 20:59:03 -0500 Subject: [PATCH 1/2] shared: Move WebsocketUpgrader to network.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <[email protected]> --- shared/network.go | 5 +++++ shared/operation.go | 7 ------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/shared/network.go b/shared/network.go index d04ff96..c60ba74 100644 --- a/shared/network.go +++ b/shared/network.go @@ -8,6 +8,7 @@ import ( "io" "io/ioutil" "net" + "net/http" "time" "github.com/gorilla/websocket" @@ -325,3 +326,7 @@ func WebsocketMirror(conn *websocket.Conn, w io.WriteCloser, r io.ReadCloser, Re return readDone, writeDone } + +var WebsocketUpgrader = websocket.Upgrader{ + CheckOrigin: func(r *http.Request) bool { return true }, +} diff --git a/shared/operation.go b/shared/operation.go index fa955e8..121be2e 100644 --- a/shared/operation.go +++ b/shared/operation.go @@ -1,16 +1,9 @@ package shared import ( - "net/http" "time" - - "github.com/gorilla/websocket" ) -var WebsocketUpgrader = websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { return true }, -} - type Operation struct { Id string `json:"id"` Class string `json:"class"` From 997900dd7412452d387e198817a5be4a6dc516c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Mon, 19 Dec 2016 21:14:57 -0500 Subject: [PATCH 2/2] Move FromLXCState out of shared MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <[email protected]> --- lxd/container_lxc.go | 18 ++++++++++++++++-- shared/status.go | 19 ------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go index 95232bc..3d84d7d 100644 --- a/lxd/container_lxc.go +++ b/lxd/container_lxc.go @@ -163,6 +163,20 @@ func lxcValidConfig(rawLxc string) error { return nil } +func lxcStatusCode(state lxc.State) shared.StatusCode { + return map[int]shared.StatusCode{ + 1: shared.Stopped, + 2: shared.Starting, + 3: shared.Running, + 4: shared.Stopping, + 5: shared.Aborting, + 6: shared.Freezing, + 7: shared.Frozen, + 8: shared.Thawed, + 9: shared.Error, + }[int(state)] +} + // Loader functions func containerLXCCreate(d *Daemon, args containerArgs) (container, error) { // Create the container struct @@ -2406,7 +2420,7 @@ func (c *containerLXC) Render() (interface{}, interface{}, error) { if err != nil { return nil, nil, err } - statusCode := shared.FromLXCState(int(cState)) + statusCode := lxcStatusCode(cState) return &shared.ContainerInfo{ Architecture: architectureName, @@ -2437,7 +2451,7 @@ func (c *containerLXC) RenderState() (*shared.ContainerState, error) { if err != nil { return nil, err } - statusCode := shared.FromLXCState(int(cState)) + statusCode := lxcStatusCode(cState) status := shared.ContainerState{ Status: statusCode.String(), StatusCode: statusCode, diff --git a/shared/status.go b/shared/status.go index 96010c4..7651f5c 100644 --- a/shared/status.go +++ b/shared/status.go @@ -47,22 +47,3 @@ func (o StatusCode) String() string { func (o StatusCode) IsFinal() bool { return int(o) >= 200 } - -/* - * Create a StatusCode from an lxc.State code. N.B.: we accept an int instead - * of a lxc.State so that the shared code doesn't depend on lxc, which depends - * on liblxc, etc. - */ -func FromLXCState(state int) StatusCode { - return map[int]StatusCode{ - 1: Stopped, - 2: Starting, - 3: Running, - 4: Stopping, - 5: Aborting, - 6: Freezing, - 7: Frozen, - 8: Thawed, - 9: Error, - }[state] -}
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
