Merge pull request #19342 from caesarxuchao/remove-resourceversion-check

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot
2016-01-31 18:11:47 -08:00
10 changed files with 18 additions and 77 deletions

View File

@@ -17,8 +17,6 @@ limitations under the License.
package unversioned
import (
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/watch"
)
@@ -92,9 +90,6 @@ func (c *endpoints) Watch(opts api.ListOptions) (watch.Interface, error) {
func (c *endpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error) {
result := &api.Endpoints{}
if len(endpoints.ResourceVersion) == 0 {
return nil, fmt.Errorf("invalid update object, missing resource version: %v", endpoints)
}
err := c.r.Put().
Namespace(c.ns).
Resource("endpoints").

View File

@@ -86,9 +86,6 @@ func (e *events) Create(event *api.Event) (*api.Event, error) {
// created with the "" namespace. Update also requires the ResourceVersion to be set in the event
// object.
func (e *events) Update(event *api.Event) (*api.Event, error) {
if len(event.ResourceVersion) == 0 {
return nil, fmt.Errorf("invalid event update object, missing resource version: %#v", event)
}
result := &api.Event{}
err := e.client.Put().
Namespace(event.Namespace).

View File

@@ -17,8 +17,6 @@ limitations under the License.
package unversioned
import (
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/watch"
)
@@ -81,10 +79,6 @@ func (c *limitRanges) Create(limitRange *api.LimitRange) (result *api.LimitRange
// Update takes the representation of a limitRange to update. Returns the server's representation of the limitRange, and an error, if it occurs.
func (c *limitRanges) Update(limitRange *api.LimitRange) (result *api.LimitRange, err error) {
result = &api.LimitRange{}
if len(limitRange.ResourceVersion) == 0 {
err = fmt.Errorf("invalid update object, missing resource version: %v", limitRange)
return
}
err = c.r.Put().Namespace(c.ns).Resource("limitRanges").Name(limitRange.Name).Body(limitRange).Do().Into(result)
return
}

View File

@@ -164,39 +164,6 @@ func TestLimitRangeUpdate(t *testing.T) {
c.Validate(t, response, err)
}
func TestInvalidLimitRangeUpdate(t *testing.T) {
ns := api.NamespaceDefault
limitRange := &api.LimitRange{
ObjectMeta: api.ObjectMeta{
Name: "abc",
},
Spec: api.LimitRangeSpec{
Limits: []api.LimitRangeItem{
{
Type: api.LimitTypePod,
Max: api.ResourceList{
api.ResourceCPU: resource.MustParse("100"),
api.ResourceMemory: resource.MustParse("10000"),
},
Min: api.ResourceList{
api.ResourceCPU: resource.MustParse("0"),
api.ResourceMemory: resource.MustParse("100"),
},
},
},
},
}
c := &simple.Client{
Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath(getLimitRangesResourceName(), ns, "abc"), Query: simple.BuildQueryValues(nil)},
Response: simple.Response{StatusCode: 200, Body: limitRange},
}
_, err := c.Setup(t).LimitRanges(ns).Update(limitRange)
defer c.Close()
if err == nil {
t.Errorf("Expected an error due to missing ResourceVersion")
}
}
func TestLimitRangeDelete(t *testing.T) {
ns := api.NamespaceDefault
c := &simple.Client{

View File

@@ -68,10 +68,6 @@ func (c *namespaces) List(opts api.ListOptions) (*api.NamespaceList, error) {
// Update takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs.
func (c *namespaces) Update(namespace *api.Namespace) (result *api.Namespace, err error) {
result = &api.Namespace{}
if len(namespace.ResourceVersion) == 0 {
err = fmt.Errorf("invalid update object, missing resource version: %v", namespace)
return
}
err = c.r.Put().Resource("namespaces").Name(namespace.Name).Body(namespace).Do().Into(result)
return
}

View File

@@ -17,8 +17,6 @@ limitations under the License.
package unversioned
import (
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/watch"
)
@@ -81,20 +79,12 @@ func (c *nodes) Delete(name string) error {
// Update updates an existing node.
func (c *nodes) Update(node *api.Node) (*api.Node, error) {
result := &api.Node{}
if len(node.ResourceVersion) == 0 {
err := fmt.Errorf("invalid update object, missing resource version: %v", node)
return nil, err
}
err := c.r.Put().Resource(c.resourceName()).Name(node.Name).Body(node).Do().Into(result)
return result, err
}
func (c *nodes) UpdateStatus(node *api.Node) (*api.Node, error) {
result := &api.Node{}
if len(node.ResourceVersion) == 0 {
err := fmt.Errorf("invalid update object, missing resource version: %v", node)
return nil, err
}
err := c.r.Put().Resource(c.resourceName()).Name(node.Name).SubResource("status").Body(node).Do().Into(result)
return result, err
}

View File

@@ -17,8 +17,6 @@ limitations under the License.
package unversioned
import (
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/watch"
)
@@ -77,10 +75,6 @@ func (c *persistentVolumeClaims) Create(claim *api.PersistentVolumeClaim) (resul
func (c *persistentVolumeClaims) Update(claim *api.PersistentVolumeClaim) (result *api.PersistentVolumeClaim, err error) {
result = &api.PersistentVolumeClaim{}
if len(claim.ResourceVersion) == 0 {
err = fmt.Errorf("invalid update object, missing resource version: %v", claim)
return
}
err = c.client.Put().Namespace(c.namespace).Resource("persistentVolumeClaims").Name(claim.Name).Body(claim).Do().Into(result)
return
}

View File

@@ -17,8 +17,6 @@ limitations under the License.
package unversioned
import (
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/watch"
)
@@ -72,10 +70,6 @@ func (c *persistentVolumes) Create(volume *api.PersistentVolume) (result *api.Pe
func (c *persistentVolumes) Update(volume *api.PersistentVolume) (result *api.PersistentVolume, err error) {
result = &api.PersistentVolume{}
if len(volume.ResourceVersion) == 0 {
err = fmt.Errorf("invalid update object, missing resource version: %v", volume)
return
}
err = c.client.Put().Resource("persistentVolumes").Name(volume.Name).Body(volume).Do().Into(result)
return
}