當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Info.Get方法代碼示例

本文整理匯總了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
}
開發者ID:erinboyd,項目名稱:origin,代碼行數:30,代碼來源:edit.go

示例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
		}
	})
}
開發者ID:alex-mohr,項目名稱:kubernetes,代碼行數:17,代碼來源:delete.go

示例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
}
開發者ID:pweil-,項目名稱:origin,代碼行數:21,代碼來源:migrator.go


注:本文中的k8s/io/kubernetes/pkg/kubectl/resource.Info.Get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。