LEFT | RIGHT |
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 "state-server" property with a boolean | 5 // must specify a "state-server" property with a boolean |
6 // value. If this is true, a state server will be started | 6 // value. If this is true, a state server 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 // | 8 // |
9 // The configuration data also accepts a "broken" property | 9 // The configuration data also accepts a "broken" property |
10 // of type boolean. If this is non-empty, any operation | 10 // of type boolean. If this is non-empty, any operation |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 if err != nil { | 453 if err != nil { |
454 return fmt.Errorf("cannot make bootstrap config: %v", er
r) | 454 return fmt.Errorf("cannot make bootstrap config: %v", er
r) |
455 } | 455 } |
456 st, err := state.Initialize(info, cfg) | 456 st, err := state.Initialize(info, cfg) |
457 if err != nil { | 457 if err != nil { |
458 panic(err) | 458 panic(err) |
459 } | 459 } |
460 if err := st.SetAdminMongoPassword(trivial.PasswordHash(password
)); err != nil { | 460 if err := st.SetAdminMongoPassword(trivial.PasswordHash(password
)); err != nil { |
461 panic(err) | 461 panic(err) |
462 } | 462 } |
463 » » // TODO(rog) use hash of password when we can change passwords | 463 » » // TODO(rog) use hash of password when the juju API connection |
464 » » // in the API | 464 » » // logic is done. |
465 _, err = st.AddUser("admin", password) | 465 _, err = st.AddUser("admin", password) |
466 if err != nil { | 466 if err != nil { |
467 panic(err) | 467 panic(err) |
468 } | 468 } |
469 e.state.apiServer, err = api.NewServer(st, "localhost:0", []byte
(testing.ServerCert), []byte(testing.ServerKey)) | 469 e.state.apiServer, err = api.NewServer(st, "localhost:0", []byte
(testing.ServerCert), []byte(testing.ServerKey)) |
470 if err != nil { | 470 if err != nil { |
471 panic(err) | 471 panic(err) |
472 } | 472 } |
473 e.state.apiState = st | 473 e.state.apiState = st |
474 } | 474 } |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 // time.Durations into this value. | 758 // time.Durations into this value. |
759 var providerDelay time.Duration | 759 var providerDelay time.Duration |
760 | 760 |
761 // pause execution to simulate the latency of a real provider | 761 // pause execution to simulate the latency of a real provider |
762 func delay() { | 762 func delay() { |
763 if providerDelay > 0 { | 763 if providerDelay > 0 { |
764 log.Printf("environs/dummy: pausing for %v", providerDelay) | 764 log.Printf("environs/dummy: pausing for %v", providerDelay) |
765 <-time.After(providerDelay) | 765 <-time.After(providerDelay) |
766 } | 766 } |
767 } | 767 } |
LEFT | RIGHT |