10
10
"launchpad.net/juju-core/state/api/watcher"
13
// EnvironWatcher provides common client side api functions
14
// to call into the apiserver.common.EnvironWatcher.
13
// EnvironWatcher provides common client-side API functions
14
// to call into apiserver.common.EnvironWatcher.
15
15
type EnvironWatcher struct {
20
// NewEnvironWatcher creates a EnvironWatcher on the specified façade,
20
// NewEnvironWatcher creates a EnvironWatcher on the specified facade,
21
21
// and uses this name when calling through the caller.
22
func NewEnvironWatcher(façadeName string, caller base.Caller) *EnvironWatcher {
23
return &EnvironWatcher{façadeName, caller}
22
func NewEnvironWatcher(facadeName string, caller base.Caller) *EnvironWatcher {
23
return &EnvironWatcher{facadeName, caller}
26
26
// WatchForEnvironConfigChanges return a NotifyWatcher waiting for the
27
27
// environment configuration to change.
28
28
func (e *EnvironWatcher) WatchForEnvironConfigChanges() (watcher.NotifyWatcher, error) {
29
29
var result params.NotifyWatchResult
30
err := e.caller.Call(e.façadeName, "", "WatchForEnvironConfigChanges", nil, &result)
30
err := e.caller.Call(e.facadeName, "", "WatchForEnvironConfigChanges", nil, &result)
34
if err := result.Error; err != nil {
35
return nil, result.Error
37
w := watcher.NewNotifyWatcher(e.caller, result)
34
return watcher.NewNotifyWatcher(e.caller, result), nil
41
37
// EnvironConfig returns the current environment configuration.
42
38
func (e *EnvironWatcher) EnvironConfig() (*config.Config, error) {
43
39
var result params.EnvironConfigResult
44
err := e.caller.Call(e.façadeName, "", "EnvironConfig", nil, &result)
40
err := e.caller.Call(e.facadeName, "", "EnvironConfig", nil, &result)
48
if err := result.Error; err != nil {
51
44
conf, err := config.New(config.NoDefaults, result.Config)