本文整理汇总了Golang中k8s/io/kubernetes/pkg/kubectl/resource.Info.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang Info.Get方法的具体用法?Golang Info.Get怎么用?Golang Info.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/kubectl/resource.Info
的用法示例。
在下文中一共展示了Info.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: applyPatch
// applyPatch reads the latest version of the object, writes it to version, then attempts to merge
// the changes onto it without conflict. If a conflict occurs jsonmerge.IsConflicting(err) is
// true. The info object is mutated
func applyPatch(delta *jsonmerge.Delta, info *resource.Info, version string) error {
if err := info.Get(); err != nil {
return patchError{err}
}
obj, err := resource.AsVersionedObject([]*resource.Info{info}, false, version)
if err != nil {
return patchError{err}
}
data, err := info.Mapping.Codec.Encode(obj)
if err != nil {
return patchError{err}
}
merged, err := delta.Apply(data)
if err != nil {
return patchError{err}
}
mergedObj, err := info.Mapping.Codec.Decode(merged)
if err != nil {
return patchError{err}
}
updated, err := resource.NewHelper(info.Client, info.Mapping).Replace(info.Namespace, info.Name, false, mergedObj)
if err != nil {
return err
}
info.Refresh(updated, true)
return nil
}
示例2: waitForObjectDeletion
// waitForObjectDeletion refreshes the object, waiting until it is deleted, a timeout is reached, or
// an error is encountered. It checks once a second.
func waitForObjectDeletion(info *resource.Info, timeout time.Duration) error {
copied := *info
info = &copied
// TODO: refactor Reaper so that we can pass the "wait" option into it, and then check for UID change.
return wait.PollImmediate(objectDeletionWaitInterval, timeout, func() (bool, error) {
switch err := info.Get(); {
case err == nil:
return false, nil
case errors.IsNotFound(err):
return true, nil
default:
return false, err
}
})
}
示例3: DefaultRetriable
// DefaultRetriable adds retry information to the provided error, and will refresh the
// info if the client info is stale. If the refresh fails the error is made fatal.
// All other errors are left in their natural state - they will not be retried unless
// they define a Temporary() method that returns true.
func DefaultRetriable(info *resource.Info, err error) error {
if err == nil {
return nil
}
switch {
case errors.IsMethodNotSupported(err):
return ErrNotRetriable{err}
case errors.IsConflict(err):
if refreshErr := info.Get(); refreshErr != nil {
return ErrNotRetriable{err}
}
return ErrRetriable{err}
case errors.IsServerTimeout(err):
return ErrRetriable{err}
}
return err
}