OLD | NEW |
1 // The dummy provider implements an environment provider for testing | 1 // The dummy provider implements an environment provider for testing |
2 // purposes, registered with environs under the name "dummy". | 2 // purposes, registered with environs under the name "dummy". |
3 //· | 3 //· |
4 // The configuration YAML for the testing environment | 4 // The configuration YAML for the testing environment |
5 // must specify a "zookeeper" property with a boolean | 5 // must specify a "zookeeper" property with a boolean |
6 // value. If this is true, a zookeeper instance will be started | 6 // value. If this is true, a zookeeper instance will be started |
7 // the first time StateInfo is called on a newly reset environment. | 7 // the first time StateInfo is called on a newly reset environment. |
8 // NOTE: ZooKeeper isn't actually being started yet. | 8 // NOTE: ZooKeeper isn't actually being started yet. |
9 //· | 9 //· |
10 // The configuration data also accepts a "broken" property | 10 // The configuration data also accepts a "broken" property |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 []string{ | 221 []string{ |
222 "broken", | 222 "broken", |
223 }, | 223 }, |
224 ) | 224 ) |
225 | 225 |
226 func newConfig(cfg *config.Config) (*environConfig, error) { | 226 func newConfig(cfg *config.Config) (*environConfig, error) { |
227 m0, err := checker.Coerce(cfg.UnknownAttrs(), nil) | 227 m0, err := checker.Coerce(cfg.UnknownAttrs(), nil) |
228 if err != nil { | 228 if err != nil { |
229 return nil, err | 229 return nil, err |
230 } | 230 } |
231 » m1 := m0.(schema.MapType) | 231 » m1 := m0.(map[string]interface{}) |
232 ecfg := &environConfig{ | 232 ecfg := &environConfig{ |
233 Config: cfg, | 233 Config: cfg, |
234 zookeeper: m1["zookeeper"].(bool), | 234 zookeeper: m1["zookeeper"].(bool), |
235 } | 235 } |
236 ecfg.broken, _ = m1["broken"].(bool) | 236 ecfg.broken, _ = m1["broken"].(bool) |
237 return ecfg, nil | 237 return ecfg, nil |
238 } | 238 } |
239 | 239 |
240 func (p *environProvider) Open(cfg *config.Config) (environs.Environ, error) { | 240 func (p *environProvider) Open(cfg *config.Config) (environs.Environ, error) { |
241 p.mu.Lock() | 241 p.mu.Lock() |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 panic(fmt.Errorf("Ports with mismatched machine id, expected %d
got %d", inst.machineId, machineId)) | 494 panic(fmt.Errorf("Ports with mismatched machine id, expected %d
got %d", inst.machineId, machineId)) |
495 } | 495 } |
496 inst.state.mu.Lock() | 496 inst.state.mu.Lock() |
497 defer inst.state.mu.Unlock() | 497 defer inst.state.mu.Unlock() |
498 for p := range inst.ports { | 498 for p := range inst.ports { |
499 ports = append(ports, p) | 499 ports = append(ports, p) |
500 } | 500 } |
501 state.SortPorts(ports) | 501 state.SortPorts(ports) |
502 return | 502 return |
503 } | 503 } |
OLD | NEW |