本文整理汇总了Golang中k8s/io/kubernetes/pkg/api.Pod.ResourceVersion方法的典型用法代码示例。如果您正苦于以下问题:Golang Pod.ResourceVersion方法的具体用法?Golang Pod.ResourceVersion怎么用?Golang Pod.ResourceVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/api.Pod
的用法示例。
在下文中一共展示了Pod.ResourceVersion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updatePod
func updatePod(t *testing.T, s storage.Interface, obj, old *api.Pod) *api.Pod {
key := etcdtest.AddPrefix("pods/ns/" + obj.Name)
result := &api.Pod{}
if old == nil {
if err := s.Create(context.TODO(), key, obj, result, 0); err != nil {
t.Errorf("unexpected error: %v", err)
}
} else {
// To force "update" behavior of Set() we need to set ResourceVersion of
// previous version of object.
obj.ResourceVersion = old.ResourceVersion
if err := s.Set(context.TODO(), key, obj, result, 0); err != nil {
t.Errorf("unexpected error: %v", err)
}
obj.ResourceVersion = ""
}
return result
}
示例2: updatePod
func updatePod(t *testing.T, s storage.Interface, obj, old *api.Pod) *api.Pod {
updateFn := func(input runtime.Object, res storage.ResponseMeta) (runtime.Object, *uint64, error) {
newObj, err := api.Scheme.DeepCopy(obj)
if err != nil {
t.Errorf("unexpected error: %v", err)
return nil, nil, err
}
return newObj.(*api.Pod), nil, nil
}
key := etcdtest.AddPrefix("pods/ns/" + obj.Name)
if err := s.GuaranteedUpdate(context.TODO(), key, &api.Pod{}, old == nil, nil, updateFn); err != nil {
t.Errorf("unexpected error: %v", err)
}
obj.ResourceVersion = ""
result := &api.Pod{}
if err := s.Get(context.TODO(), key, result, false); err != nil {
t.Errorf("unexpected error: %v", err)
}
return result
}
示例3: updatePod
func updatePod(c *gin.Context) {
namespace := c.Param("ns")
podname := c.Param("po")
podjson := c.PostForm("json")
var pod api.Pod
err := json.Unmarshal([]byte(podjson), &pod)
if err != nil {
c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
return
}
r, _ := kubeclient.Get().Pods(namespace).Get(pod.Name)
pod.ResourceVersion = r.ResourceVersion
_, err = kubeclient.Get().Pods(namespace).Update(&pod)
if err != nil {
c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
return
}
c.Redirect(http.StatusMovedPermanently, fmt.Sprintf("/namespaces/%s/pods/%s/edit", namespace, podname))
}