예제 #1
0
파일: firewaller.go 프로젝트: kapilt/juju
// 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),
	}
}
예제 #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
}
예제 #3
0
파일: environment.go 프로젝트: imoapps/juju
// 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),
	}
}
예제 #4
0
파일: provisioner.go 프로젝트: kapilt/juju
// 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}
}
예제 #5
0
파일: uniter.go 프로젝트: kapilt/juju
// 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,
	}
}
예제 #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,
	}
}
예제 #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
}