mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
Clients should not check conditions, UpdateStatus() is inconsistent
Corrects some of the cargo culting that has crept into the API.
This commit is contained in:
@@ -17,9 +17,6 @@ limitations under the License.
|
||||
package client
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
@@ -40,7 +37,7 @@ type PodInterface interface {
|
||||
Update(pod *api.Pod) (*api.Pod, error)
|
||||
Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||
Bind(binding *api.Binding) error
|
||||
UpdateStatus(name string, status *api.PodStatus) (*api.Pod, error)
|
||||
UpdateStatus(pod *api.Pod) (*api.Pod, error)
|
||||
}
|
||||
|
||||
// pods implements PodsNamespacer interface
|
||||
@@ -66,10 +63,6 @@ func (c *pods) List(selector labels.Selector) (result *api.PodList, err error) {
|
||||
|
||||
// Get takes the name of the pod, and returns the corresponding Pod object, and an error if it occurs
|
||||
func (c *pods) Get(name string) (result *api.Pod, err error) {
|
||||
if len(name) == 0 {
|
||||
return nil, errors.New("name is required parameter to Get")
|
||||
}
|
||||
|
||||
result = &api.Pod{}
|
||||
err = c.r.Get().Namespace(c.ns).Resource("pods").Name(name).Do().Into(result)
|
||||
return
|
||||
@@ -90,10 +83,6 @@ func (c *pods) Create(pod *api.Pod) (result *api.Pod, err error) {
|
||||
// Update takes the representation of a pod to update. Returns the server's representation of the pod, and an error, if it occurs.
|
||||
func (c *pods) Update(pod *api.Pod) (result *api.Pod, err error) {
|
||||
result = &api.Pod{}
|
||||
if len(pod.ResourceVersion) == 0 {
|
||||
err = fmt.Errorf("invalid update object, missing resource version: %v", pod)
|
||||
return
|
||||
}
|
||||
err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).Body(pod).Do().Into(result)
|
||||
return
|
||||
}
|
||||
@@ -116,13 +105,8 @@ func (c *pods) Bind(binding *api.Binding) error {
|
||||
}
|
||||
|
||||
// UpdateStatus takes the name of the pod and the new status. Returns the server's representation of the pod, and an error, if it occurs.
|
||||
func (c *pods) UpdateStatus(name string, newStatus *api.PodStatus) (result *api.Pod, err error) {
|
||||
func (c *pods) UpdateStatus(pod *api.Pod) (result *api.Pod, err error) {
|
||||
result = &api.Pod{}
|
||||
pod, err := c.Get(name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
pod.Status = *newStatus
|
||||
err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).SubResource("status").Body(pod).Do().Into(result)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user