本文整理匯總了Golang中github.com/juju/names.StorageTag.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang StorageTag.String方法的具體用法?Golang StorageTag.String怎麽用?Golang StorageTag.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/names.StorageTag
的用法示例。
在下文中一共展示了StorageTag.String方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: StorageAttachment
func (st *mockState) StorageAttachment(
storageTag names.StorageTag, unitTag names.UnitTag,
) (params.StorageAttachment, error) {
if unitTag != st.unit.tag {
return params.StorageAttachment{}, ¶ms.Error{Code: params.CodeNotFound}
}
attachment, ok := st.storageAttachment[params.StorageAttachmentId{
UnitTag: unitTag.String(),
StorageTag: storageTag.String(),
}]
if !ok {
return params.StorageAttachment{}, ¶ms.Error{Code: params.CodeNotFound}
}
if attachment.Kind == params.StorageKindUnknown {
return params.StorageAttachment{}, ¶ms.Error{Code: params.CodeNotProvisioned}
}
return attachment, nil
}
示例2: RemoveStorageAttachment
// RemoveStorageAttachment removes the storage attachment with the
// specified unit and storage tags from state. This method is only
// expected to succeed if the storage attachment is Dead.
func (sa *StorageAccessor) RemoveStorageAttachment(storageTag names.StorageTag, unitTag names.UnitTag) error {
var results params.ErrorResults
args := params.StorageAttachmentIds{
Ids: []params.StorageAttachmentId{{
StorageTag: storageTag.String(),
UnitTag: unitTag.String(),
}},
}
err := sa.facade.FacadeCall("RemoveStorageAttachments", args, &results)
if err != nil {
return err
}
if len(results.Results) != 1 {
return errors.Errorf("expected 1 result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return result.Error
}
return nil
}
示例3: WatchStorageAttachment
// WatchStorageAttachments starts a watcher for changes to the info
// of the storage attachment with the specified unit and storage tags.
func (sa *StorageAccessor) WatchStorageAttachment(storageTag names.StorageTag, unitTag names.UnitTag) (watcher.NotifyWatcher, error) {
var results params.NotifyWatchResults
args := params.StorageAttachmentIds{
Ids: []params.StorageAttachmentId{{
StorageTag: storageTag.String(),
UnitTag: unitTag.String(),
}},
}
err := sa.facade.FacadeCall("WatchStorageAttachments", args, &results)
if err != nil {
return nil, err
}
if len(results.Results) != 1 {
return nil, errors.Errorf("expected 1 result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return nil, result.Error
}
w := apiwatcher.NewNotifyWatcher(sa.facade.RawAPICaller(), result)
return w, nil
}
示例4: StorageAttachment
// StorageAttachment returns the storage attachment with the specified
// unit and storage tags.
func (sa *StorageAccessor) StorageAttachment(storageTag names.StorageTag, unitTag names.UnitTag) (params.StorageAttachment, error) {
if sa.facade.BestAPIVersion() < 2 {
return params.StorageAttachment{}, errors.NotImplementedf("StorageAttachment() (need V2+)")
}
args := params.StorageAttachmentIds{
Ids: []params.StorageAttachmentId{{
StorageTag: storageTag.String(),
UnitTag: unitTag.String(),
}},
}
var results params.StorageAttachmentResults
err := sa.facade.FacadeCall("StorageAttachments", args, &results)
if err != nil {
return params.StorageAttachment{}, errors.Trace(err)
}
if len(results.Results) != 1 {
panic(errors.Errorf("expected 1 result, got %d", len(results.Results)))
}
result := results.Results[0]
if result.Error != nil {
return params.StorageAttachment{}, result.Error
}
return result.Result, nil
}