Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(752)

Side by Side Diff: instance/container.go

Issue 70770043: all: use errgo instead of fmt.Errorf
Patch Set: all: use errgo instead of fmt.Errorf Created 11 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « instance/address_test.go ('k') | instance/instance.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « instance/address_test.go ('k') | instance/instance.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b