本文整理汇总了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
}