OLD | NEW |
1 // Copyright 2013 Canonical Ltd. | 1 // Copyright 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package instance | 4 package instance |
5 | 5 |
6 import ( | 6 import "github.com/juju/errgo/errors" |
7 » "fmt" | |
8 ) | |
9 | 7 |
10 type ContainerType string | 8 type ContainerType string |
11 | 9 |
12 const ( | 10 const ( |
13 NONE = ContainerType("none") | 11 NONE = ContainerType("none") |
14 LXC = ContainerType("lxc") | 12 LXC = ContainerType("lxc") |
15 KVM = ContainerType("kvm") | 13 KVM = ContainerType("kvm") |
16 ) | 14 ) |
17 | 15 |
18 // ContainerTypes is used to validate add-machine arguments. | 16 // ContainerTypes is used to validate add-machine arguments. |
(...skipping 13 matching lines...) Expand all Loading... |
32 } | 30 } |
33 | 31 |
34 // ParseContainerType converts the specified string into a supported | 32 // ParseContainerType converts the specified string into a supported |
35 // ContainerType instance or returns an error if the container type is invalid. | 33 // ContainerType instance or returns an error if the container type is invalid. |
36 func ParseContainerType(ctype string) (ContainerType, error) { | 34 func ParseContainerType(ctype string) (ContainerType, error) { |
37 for _, supportedType := range ContainerTypes { | 35 for _, supportedType := range ContainerTypes { |
38 if ContainerType(ctype) == supportedType { | 36 if ContainerType(ctype) == supportedType { |
39 return supportedType, nil | 37 return supportedType, nil |
40 } | 38 } |
41 } | 39 } |
42 » return "", fmt.Errorf("invalid container type %q", ctype) | 40 » return "", errors.Newf("invalid container type %q", ctype) |
43 } | 41 } |
OLD | NEW |