The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6181

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 3b6bceb9360f7ef9671ab5b760ce0cf1b28443df Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Fri, 6 Sep 2019 14:29:22 +0100
Subject: [PATCH 1/2] lxd/instance/instance: Changes instance types to own int
 type

 - Adds constants for Any and Container types

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/instance/instance.go | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lxd/instance/instance.go b/lxd/instance/instance.go
index 1dff9a626d..10952e4821 100644
--- a/lxd/instance/instance.go
+++ b/lxd/instance/instance.go
@@ -1,4 +1,11 @@
 package instance
 
-// TypeContainer represents a container instance type.
-const TypeContainer = "container"
+// Type indicates the type of instance.
+type Type int
+
+const (
+       // TypeAny represents any type of instance.
+       TypeAny = Type(-1)
+       // TypeContainer represents a container instance type.
+       TypeContainer = Type(0)
+)

From 3379c6be1d69dbcdb228d0c10000170fb86bca66 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <t...@tomp.uk>
Date: Tue, 10 Sep 2019 09:59:17 +0100
Subject: [PATCH 2/2] lxd: Updates use of string instance.Type to int type

Signed-off-by: Thomas Parrott <t...@tomp.uk>
---
 lxd/container.go                 | 3 ++-
 lxd/container_lxc.go             | 2 +-
 lxd/device/device_instance_id.go | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lxd/container.go b/lxd/container.go
index dba6aea933..666e0a8fe9 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -20,6 +20,7 @@ import (
        "github.com/lxc/lxd/lxd/db"
        "github.com/lxc/lxd/lxd/device"
        "github.com/lxc/lxd/lxd/device/config"
+       "github.com/lxc/lxd/lxd/instance"
        "github.com/lxc/lxd/lxd/state"
        "github.com/lxc/lxd/lxd/sys"
        "github.com/lxc/lxd/lxd/task"
@@ -292,7 +293,7 @@ type container interface {
        Location() string
        Project() string
        Name() string
-       Type() string
+       Type() instance.Type
        Description() string
        Architecture() int
        CreationDate() time.Time
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 425b5e53da..6ab80d9dcc 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -630,7 +630,7 @@ type containerLXC struct {
        expiryDate time.Time
 }
 
-func (c *containerLXC) Type() string {
+func (c *containerLXC) Type() instance.Type {
        return instance.TypeContainer
 }
 
diff --git a/lxd/device/device_instance_id.go b/lxd/device/device_instance_id.go
index f1923aa17e..c92bb6ae95 100644
--- a/lxd/device/device_instance_id.go
+++ b/lxd/device/device_instance_id.go
@@ -2,6 +2,7 @@ package device
 
 import (
        "github.com/lxc/lxd/lxd/device/config"
+       "github.com/lxc/lxd/lxd/instance"
 )
 
 // InstanceIdentifier is an interface that allows us to identify an Instance 
and its properties.
@@ -9,7 +10,7 @@ import (
 // independent of when they're called in the instance lifecycle.
 type InstanceIdentifier interface {
        Name() string
-       Type() string
+       Type() instance.Type
        Project() string
        DevicesPath() string
        RootfsPath() string
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to