LEFT | RIGHT |
1 package ec2 | 1 package ec2 |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 "launchpad.net/goamz/aws" | 5 "launchpad.net/goamz/aws" |
6 "launchpad.net/juju-core/environs/config" | 6 "launchpad.net/juju-core/environs/config" |
7 "launchpad.net/juju-core/schema" | 7 "launchpad.net/juju-core/schema" |
8 ) | 8 ) |
9 | 9 |
10 // providerConfig is a placeholder for any config information | 10 // providerConfig is a placeholder for any config information |
(...skipping 16 matching lines...) Expand all Loading... |
27 "public-bucket": schema.String(), | 27 "public-bucket": schema.String(), |
28 }, []string{ | 28 }, []string{ |
29 "access-key", | 29 "access-key", |
30 "secret-key", | 30 "secret-key", |
31 "region", | 31 "region", |
32 "public-bucket", | 32 "public-bucket", |
33 }, | 33 }, |
34 ) | 34 ) |
35 | 35 |
36 func newConfig(config *config.Config) (*providerConfig, error) { | 36 func newConfig(config *config.Config) (*providerConfig, error) { |
37 » v, err := configChecker.Coerce(config.TypeMap(), nil) | 37 » v, err := configChecker.Coerce(config.UnknownAttrs(), nil) |
38 if err != nil { | 38 if err != nil { |
39 return nil, err | 39 return nil, err |
40 } | 40 } |
41 m := v.(schema.MapType) | 41 m := v.(schema.MapType) |
42 c := &providerConfig{Config: config} | 42 c := &providerConfig{Config: config} |
43 c.bucket = m["control-bucket"].(string) | 43 c.bucket = m["control-bucket"].(string) |
44 c.publicBucket = maybeString(m["public-bucket"], "") | 44 c.publicBucket = maybeString(m["public-bucket"], "") |
45 c.auth.AccessKey = maybeString(m["access-key"], "") | 45 c.auth.AccessKey = maybeString(m["access-key"], "") |
46 c.auth.SecretKey = maybeString(m["secret-key"], "") | 46 c.auth.SecretKey = maybeString(m["secret-key"], "") |
47 if c.auth.AccessKey == "" || c.auth.SecretKey == "" { | 47 if c.auth.AccessKey == "" || c.auth.SecretKey == "" { |
(...skipping 16 matching lines...) Expand all Loading... |
64 c.region = regionName | 64 c.region = regionName |
65 return c, nil | 65 return c, nil |
66 } | 66 } |
67 | 67 |
68 func maybeString(x interface{}, dflt string) string { | 68 func maybeString(x interface{}, dflt string) string { |
69 if x == nil { | 69 if x == nil { |
70 return dflt | 70 return dflt |
71 } | 71 } |
72 return x.(string) | 72 return x.(string) |
73 } | 73 } |
LEFT | RIGHT |