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

Delta Between Two Patch Sets: environs/ec2/config.go

Issue 6408049: environs: turn environment configuration into a concrete type
Left Patch Set: Config 3000. Created 12 years, 8 months ago
Right Patch Set: environs: turn environment configuration into a concrete type Created 12 years, 8 months 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « environs/ec2/auth_test.go ('k') | environs/ec2/config_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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
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 }
LEFTRIGHT

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