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

Side by Side Diff: environs/dummy/environs.go

Issue 6653050: environs, juju: require admin-secret
Patch Set: environs, juju: require admin-secret Created 12 years, 5 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:
View unified diff | Download patch
« no previous file with comments | « [revision details] ('k') | environs/dummy/environs_test.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 // 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 372
373 func (e *environ) Name() string { 373 func (e *environ) Name() string {
374 return e.state.name 374 return e.state.name
375 } 375 }
376 376
377 func (e *environ) Bootstrap(uploadTools bool) error { 377 func (e *environ) Bootstrap(uploadTools bool) error {
378 defer delay() 378 defer delay()
379 if err := e.checkBroken("Bootstrap"); err != nil { 379 if err := e.checkBroken("Bootstrap"); err != nil {
380 return err 380 return err
381 } 381 }
382 password := e.Config().AdminSecret()
383 if password == "" {
384 return fmt.Errorf("admin-secret is required for bootstrap")
385 }
382 var tools *state.Tools 386 var tools *state.Tools
383 var err error 387 var err error
384 if uploadTools { 388 if uploadTools {
385 tools, err = environs.PutTools(e.Storage(), nil) 389 tools, err = environs.PutTools(e.Storage(), nil)
386 if err != nil { 390 if err != nil {
387 return err 391 return err
388 } 392 }
389 } else { 393 } else {
390 flags := environs.HighestVersion | environs.CompatVersion 394 flags := environs.HighestVersion | environs.CompatVersion
391 tools, err = environs.FindTools(e, version.Current, flags) 395 tools, err = environs.FindTools(e, version.Current, flags)
(...skipping 10 matching lines...) Expand all
402 if e.ecfg().stateServer() { 406 if e.ecfg().stateServer() {
403 info := stateInfo() 407 info := stateInfo()
404 cfg, err := environs.BootstrapConfig(&providerInstance, e.ecfg() .Config, tools) 408 cfg, err := environs.BootstrapConfig(&providerInstance, e.ecfg() .Config, tools)
405 if err != nil { 409 if err != nil {
406 return fmt.Errorf("cannot make bootstrap config: %v", er r) 410 return fmt.Errorf("cannot make bootstrap config: %v", er r)
407 } 411 }
408 st, err := state.Initialize(info, cfg) 412 st, err := state.Initialize(info, cfg)
409 if err != nil { 413 if err != nil {
410 panic(err) 414 panic(err)
411 } 415 }
412 » » if password := e.Config().AdminSecret(); password != "" { 416 » » if err := st.SetAdminPassword(trivial.PasswordHash(password)); e rr != nil {
413 » » » if err := st.SetAdminPassword(trivial.PasswordHash(passw ord)); err != nil { 417 » » » return err
414 » » » » return err
415 » » » }
416 } 418 }
417 if err := st.Close(); err != nil { 419 if err := st.Close(); err != nil {
418 panic(err) 420 panic(err)
419 } 421 }
420 } 422 }
421 e.state.bootstrapped = true 423 e.state.bootstrapped = true
422 return nil 424 return nil
423 } 425 }
424 426
425 func (e *environ) StateInfo() (*state.Info, error) { 427 func (e *environ) StateInfo() (*state.Info, error) {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 // time.Durations into this value. 674 // time.Durations into this value.
673 var providerDelay time.Duration 675 var providerDelay time.Duration
674 676
675 // pause execution to simulate the latency of a real provider 677 // pause execution to simulate the latency of a real provider
676 func delay() { 678 func delay() {
677 if providerDelay > 0 { 679 if providerDelay > 0 {
678 log.Printf("dummy: pausing for %v", providerDelay) 680 log.Printf("dummy: pausing for %v", providerDelay)
679 <-time.After(providerDelay) 681 <-time.After(providerDelay)
680 } 682 }
681 } 683 }
OLDNEW
« no previous file with comments | « [revision details] ('k') | environs/dummy/environs_test.go » ('j') | no next file with comments »

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