本文整理匯總了Golang中github.com/juju/juju/apiserver/facade.Context.State方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.State方法的具體用法?Golang Context.State怎麽用?Golang Context.State使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/apiserver/facade.Context
的用法示例。
在下文中一共展示了Context.State方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewAllWatcher
// NewAllWatcher returns a new API server endpoint for interacting
// with a watcher created by the WatchAll and WatchAllModels API calls.
func NewAllWatcher(context facade.Context) (facade.Facade, error) {
id := context.ID()
auth := context.Auth()
resources := context.Resources()
// HasPermission should not be replaced by auth.AuthClient() even if, at first sight, they seem
// equivalent because this allows us to remove login permission for a user
// (a permission that is given by default).
isAuthorized, err := auth.HasPermission(permission.LoginAccess, context.State().ControllerTag())
if err != nil {
return nil, errors.Trace(err)
}
if !isAuthorized {
return nil, common.ErrPerm
}
watcher, ok := resources.Get(id).(*state.Multiwatcher)
if !ok {
return nil, common.ErrUnknownWatcher
}
return &SrvAllWatcher{
watcher: watcher,
id: id,
resources: resources,
}, nil
}
示例2: newFilesystemAttachmentsWatcher
func newFilesystemAttachmentsWatcher(context facade.Context) (facade.Facade, error) {
id := context.ID()
auth := context.Auth()
resources := context.Resources()
st := context.State()
return newMachineStorageIdsWatcher(
st, resources, auth, id, storagecommon.ParseFilesystemAttachmentIds,
)
}
示例3: newMigrationStatusWatcher
func newMigrationStatusWatcher(context facade.Context) (facade.Facade, error) {
id := context.ID()
auth := context.Auth()
resources := context.Resources()
st := context.State()
if !(auth.AuthMachineAgent() || auth.AuthUnitAgent()) {
return nil, common.ErrPerm
}
w, ok := resources.Get(id).(state.NotifyWatcher)
if !ok {
return nil, common.ErrUnknownWatcher
}
return &srvMigrationStatusWatcher{
watcher: w,
id: id,
resources: resources,
st: getMigrationBackend(st),
}, nil
}