Update NodeStatus use subresources.

This commit is contained in:
gmarek
2015-04-08 11:32:47 +02:00
parent b12d75d0ee
commit ccc56d3c3c
11 changed files with 80 additions and 17 deletions

View File

@@ -35,6 +35,7 @@ type NodeInterface interface {
List(selector labels.Selector) (*api.NodeList, error)
Delete(name string) error
Update(*api.Node) (*api.Node, error)
UpdateStatus(*api.Node) (*api.Node, error)
Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}
@@ -94,6 +95,16 @@ func (c *nodes) Update(node *api.Node) (*api.Node, error) {
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
}
// Watch returns a watch.Interface that watches the requested nodes.
func (c *nodes) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().

View File

@@ -54,6 +54,11 @@ func (c *FakeNodes) Update(minion *api.Node) (*api.Node, error) {
return obj.(*api.Node), err
}
func (c *FakeNodes) UpdateStatus(minion *api.Node) (*api.Node, error) {
obj, err := c.Fake.Invokes(FakeAction{Action: "update-status-node", Value: minion}, &api.Node{})
return obj.(*api.Node), err
}
func (c *FakeNodes) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-nodes", Value: resourceVersion})
return c.Fake.Watch, c.Fake.Err