Ejemplo n.º 1
0
// NewState creates a new client-side Firewaller facade.
func NewState(caller base.APICaller) *State {
	facadeCaller := base.NewFacadeCaller(caller, firewallerFacade)
	return &State{
		facade:         facadeCaller,
		EnvironWatcher: common.NewEnvironWatcher(facadeCaller),
	}
}
Ejemplo n.º 2
0
// newStateForVersion creates a new client-side Uniter facade for the
// given version.
func newStateForVersion(
	caller base.APICaller,
	authTag names.UnitTag,
	version int,
) *State {
	facadeCaller := base.NewFacadeCallerForVersion(
		caller,
		uniterFacade,
		version,
	)
	state := &State{
		EnvironWatcher:  common.NewEnvironWatcher(facadeCaller),
		APIAddresser:    common.NewAPIAddresser(facadeCaller),
		StorageAccessor: NewStorageAccessor(facadeCaller),
		facade:          facadeCaller,
		unitTag:         authTag,
	}

	if version >= 2 {
		newWatcher := func(result params.NotifyWatchResult) watcher.NotifyWatcher {
			return apiwatcher.NewNotifyWatcher(caller, result)
		}
		state.LeadershipSettings = NewLeadershipSettingsAccessor(
			facadeCaller.FacadeCall,
			newWatcher,
			ErrIfNotVersionFn(2, state.BestAPIVersion()),
		)
	}

	return state
}
Ejemplo n.º 3
0
// NewFacade returns a new api client facade instance.
func NewFacade(caller base.APICaller) *Facade {
	facadeCaller := base.NewFacadeCaller(caller, apiName)
	return &Facade{
		EnvironWatcher:      common.NewEnvironWatcher(facadeCaller),
		ToolsVersionUpdater: NewToolsVersionUpdater(facadeCaller),
	}
}
Ejemplo n.º 4
0
// NewState creates a new client-side Machiner facade.
func NewState(caller base.APICaller) *State {
	facadeCaller := base.NewFacadeCaller(caller, provisionerFacade)
	return &State{
		EnvironWatcher: common.NewEnvironWatcher(facadeCaller),
		APIAddresser:   common.NewAPIAddresser(facadeCaller),
		facade:         facadeCaller}
}
Ejemplo n.º 5
0
// NewState creates a new client-side Uniter facade.
func NewState(caller base.APICaller, authTag names.UnitTag) *State {
	facadeCaller := base.NewFacadeCaller(caller, uniterFacade)
	return &State{
		EnvironWatcher: common.NewEnvironWatcher(facadeCaller),
		APIAddresser:   common.NewAPIAddresser(facadeCaller),
		facade:         facadeCaller,
		unitTag:        authTag,
	}
}
Ejemplo n.º 6
0
// NewAPI creates a new client-side InstancePoller facade.
func NewAPI(caller base.APICaller) *API {
	if caller == nil {
		panic("caller is nil")
	}
	facadeCaller := base.NewFacadeCaller(caller, instancePollerFacade)
	return &API{
		EnvironWatcher: common.NewEnvironWatcher(facadeCaller),
		facade:         facadeCaller,
	}
}
Ejemplo n.º 7
0
// NewState creates a new client-side StorageProvisioner facade.
func NewState(caller base.APICaller, scope names.Tag) (*State, error) {
	switch scope.(type) {
	case names.EnvironTag:
	case names.MachineTag:
	default:
		return nil, errors.Errorf("expected EnvironTag or MachineTag, got %T", scope)
	}
	facadeCaller := base.NewFacadeCaller(caller, storageProvisionerFacade)
	return &State{
		facadeCaller,
		scope,
		common.NewEnvironWatcher(facadeCaller),
	}, nil
}