~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/worker/environ/environ.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
// It's arguable that it should be called TrackerConfig, because of the heavy
30
30
// use of model config in this package.
31
31
type Config struct {
32
 
        Observer ConfigObserver
 
32
        Observer       ConfigObserver
 
33
        NewEnvironFunc NewEnvironFunc
33
34
}
34
35
 
 
36
// NewEnvironFunc is the type of a function that, given a model config,
 
37
// returns an Environ. This will typically be environs.New.
 
38
type NewEnvironFunc func(*config.Config) (environs.Environ, error)
 
39
 
35
40
// Validate returns an error if the config cannot be used to start a Tracker.
36
41
func (config Config) Validate() error {
37
42
        if config.Observer == nil {
38
43
                return errors.NotValidf("nil Observer")
39
44
        }
 
45
        if config.NewEnvironFunc == nil {
 
46
                return errors.NotValidf("nil NewEnvironFunc")
 
47
        }
40
48
        return nil
41
49
}
42
50
 
62
70
        if err != nil {
63
71
                return nil, errors.Annotate(err, "cannot read environ config")
64
72
        }
65
 
        environ, err := environs.New(modelConfig)
 
73
        environ, err := config.NewEnvironFunc(modelConfig)
66
74
        if err != nil {
67
75
                return nil, errors.Annotate(err, "cannot create environ")
68
76
        }