Skip to content

Commit

Permalink
Update references from Path() to the appropriate segment use
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Dec 29, 2014
1 parent afedbba commit e355f54
Show file tree
Hide file tree
Showing 20 changed files with 258 additions and 111 deletions.
15 changes: 7 additions & 8 deletions cmd/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func TestNetwork(c *client.Client) bool {
const maxAttempts = 60
for i := 0; i < maxAttempts; i++ {
time.Sleep(time.Second)
body, err := c.Get().Path("proxy").Path("services").Path(svc.Name).Path("status").Do().Raw()
body, err := c.Get().Prefix("proxy").Resource("services").Name(svc.Name).Suffix("status").Do().Raw()
if err != nil {
glog.Infof("Attempt %v/%v: service/pod still starting. (error: '%v')", i, maxAttempts, err)
continue
Expand All @@ -344,7 +344,7 @@ func TestNetwork(c *client.Client) bool {
case "running":
glog.Infof("Attempt %v/%v: test still running", i, maxAttempts)
case "fail":
if body, err := c.Get().Path("proxy").Path("services").Path(svc.Name).Path("read").Do().Raw(); err != nil {
if body, err := c.Get().Prefix("proxy").Resource("services").Name(svc.Name).Suffix("read").Do().Raw(); err != nil {
glog.Infof("Failed on attempt %v. Cleaning up. Error reading details: %v", i, err)
} else {
glog.Infof("Failed on attempt %v. Cleaning up. Details:\n%v", i, string(body))
Expand All @@ -353,7 +353,7 @@ func TestNetwork(c *client.Client) bool {
}
}

if body, err := c.Get().Path("proxy").Path("services").Path(svc.Name).Path("read").Do().Raw(); err != nil {
if body, err := c.Get().Prefix("proxy").Resource("services").Name(svc.Name).Suffix("read").Do().Raw(); err != nil {
glog.Infof("Timed out. Cleaning up. Error reading details: %v", err)
} else {
glog.Infof("Timed out. Cleaning up. Details:\n%v", string(body))
Expand Down Expand Up @@ -472,12 +472,11 @@ func TestClusterDNS(c *client.Client) bool {
failed = []string{}
for _, name := range namesToResolve {
_, err := c.Get().
Path("proxy").
Prefix("proxy").
Resource("pods").
Namespace("default").
Path("pods").
Path(pod.Name).
Path("results").
Path(name).
Name(pod.Name).
Suffix("results", name).
Do().Raw()
if err != nil {
failed = append(failed, name)
Expand Down
24 changes: 12 additions & 12 deletions cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func runAPIVersionsTest(c *client.Client) {

func runSelfLinkTest(c *client.Client) {
var svc api.Service
err := c.Post().Path("services").Body(
err := c.Post().Resource("services").Body(
&api.Service{
ObjectMeta: api.ObjectMeta{
Name: "selflinktest",
Expand All @@ -305,7 +305,7 @@ func runSelfLinkTest(c *client.Client) {
}

var svcList api.ServiceList
err = c.Get().Path("services").Do().Into(&svcList)
err = c.Get().Resource("services").Do().Into(&svcList)
if err != nil {
glog.Fatalf("Failed listing services: %v", err)
}
Expand Down Expand Up @@ -338,7 +338,7 @@ func runSelfLinkTest(c *client.Client) {

func runAtomicPutTest(c *client.Client) {
var svc api.Service
err := c.Post().Path("services").Body(
err := c.Post().Resource("services").Body(
&api.Service{
TypeMeta: api.TypeMeta{
APIVersion: latest.Version,
Expand Down Expand Up @@ -377,8 +377,8 @@ func runAtomicPutTest(c *client.Client) {
glog.Infof("Starting to update (%s, %s)", l, v)
var tmpSvc api.Service
err := c.Get().
Path("services").
Path(svc.Name).
Resource("services").
Name(svc.Name).
Do().
Into(&tmpSvc)
if err != nil {
Expand All @@ -391,7 +391,7 @@ func runAtomicPutTest(c *client.Client) {
tmpSvc.Spec.Selector[l] = v
}
glog.Infof("Posting update (%s, %s)", l, v)
err = c.Put().Path("services").Path(svc.Name).Body(&tmpSvc).Do().Error()
err = c.Put().Resource("services").Name(svc.Name).Body(&tmpSvc).Do().Error()
if err != nil {
if errors.IsConflict(err) {
glog.Infof("Conflict: (%s, %s)", l, v)
Expand All @@ -408,7 +408,7 @@ func runAtomicPutTest(c *client.Client) {
}(label, value)
}
wg.Wait()
if err := c.Get().Path("services").Path(svc.Name).Do().Into(&svc); err != nil {
if err := c.Get().Resource("services").Name(svc.Name).Do().Into(&svc); err != nil {
glog.Fatalf("Failed getting atomicService after writers are complete: %v", err)
}
if !reflect.DeepEqual(testLabels, labels.Set(svc.Spec.Selector)) {
Expand All @@ -422,7 +422,7 @@ func runMasterServiceTest(client *client.Client) {
var svcList api.ServiceList
err := client.Get().
Namespace("default").
Path("services").
Resource("services").
Do().
Into(&svcList)
if err != nil {
Expand All @@ -443,8 +443,8 @@ func runMasterServiceTest(client *client.Client) {
var ep api.Endpoints
err := client.Get().
Namespace("default").
Path("endpoints").
Path("kubernetes").
Resource("endpoints").
Name("kubernetes").
Do().
Into(&ep)
if err != nil {
Expand All @@ -460,8 +460,8 @@ func runMasterServiceTest(client *client.Client) {
var ep api.Endpoints
err := client.Get().
Namespace("default").
Path("endpoints").
Path("kubernetes-ro").
Resource("endpoints").
Name("kubernetes-ro").
Do().
Into(&ep)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubecfg/kubecfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func executeAPIRequest(ctx api.Context, method string, c *client.Client) bool {
glog.Fatalf("usage: kubecfg [OPTIONS] %s <%s>", method, prettyWireStorage())
}
case "update":
obj, err := c.Verb("GET").Namespace(api.Namespace(ctx)).Path(path).Do().Get()
obj, err := c.Verb("GET").Namespace(api.Namespace(ctx)).Suffix(path).Do().Get()
if err != nil {
glog.Fatalf("error obtaining resource version for update: %v", err)
}
Expand All @@ -404,7 +404,7 @@ func executeAPIRequest(ctx api.Context, method string, c *client.Client) bool {
return false
}

r := c.Verb(verb).Namespace(api.Namespace(ctx)).Path(path)
r := c.Verb(verb).Namespace(api.Namespace(ctx)).Suffix(path)
if len(*selector) > 0 {
r.ParseSelectorParam("labels", *selector)
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/client/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ func newEndpoints(c *Client, namespace string) *endpoints {
// Create creates a new endpoint.
func (c *endpoints) Create(endpoints *api.Endpoints) (*api.Endpoints, error) {
result := &api.Endpoints{}
err := c.r.Post().Namespace(c.ns).Path("endpoints").Body(endpoints).Do().Into(result)
err := c.r.Post().Namespace(c.ns).Resource("endpoints").Body(endpoints).Do().Into(result)
return result, err
}

// List takes a selector, and returns the list of endpoints that match that selector
func (c *endpoints) List(selector labels.Selector) (result *api.EndpointsList, err error) {
result = &api.EndpointsList{}
err = c.r.Get().Namespace(c.ns).Path("endpoints").SelectorParam("labels", selector).Do().Into(result)
err = c.r.Get().Namespace(c.ns).Resource("endpoints").SelectorParam("labels", selector).Do().Into(result)
return
}

Expand All @@ -71,16 +71,16 @@ func (c *endpoints) Get(name string) (result *api.Endpoints, err error) {
}

result = &api.Endpoints{}
err = c.r.Get().Namespace(c.ns).Path("endpoints").Path(name).Do().Into(result)
err = c.r.Get().Namespace(c.ns).Resource("endpoints").Name(name).Do().Into(result)
return
}

// Watch returns a watch.Interface that watches the requested endpoints for a service.
func (c *endpoints) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Path("watch").
Prefix("watch").
Namespace(c.ns).
Path("endpoints").
Resource("endpoints").
Param("resourceVersion", resourceVersion).
SelectorParam("labels", label).
SelectorParam("fields", field).
Expand All @@ -94,8 +94,8 @@ func (c *endpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error) {
}
err := c.r.Put().
Namespace(c.ns).
Path("endpoints").
Path(endpoints.Name).
Resource("endpoints").
Name(endpoints.Name).
Body(endpoints).
Do().
Into(result)
Expand Down
12 changes: 6 additions & 6 deletions pkg/client/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (e *events) Create(event *api.Event) (*api.Event, error) {
result := &api.Event{}
err := e.client.Post().
Namespace(event.Namespace).
Path("events").
Resource("events").
Body(event).
Do().
Into(result)
Expand All @@ -78,7 +78,7 @@ func (e *events) List(label, field labels.Selector) (*api.EventList, error) {
result := &api.EventList{}
err := e.client.Get().
Namespace(e.namespace).
Path("events").
Resource("events").
SelectorParam("labels", label).
SelectorParam("fields", field).
Do().
Expand All @@ -95,8 +95,8 @@ func (e *events) Get(name string) (*api.Event, error) {
result := &api.Event{}
err := e.client.Get().
Namespace(e.namespace).
Path("events").
Path(name).
Resource("events").
Name(name).
Do().
Into(result)
return result, err
Expand All @@ -105,9 +105,9 @@ func (e *events) Get(name string) (*api.Event, error) {
// Watch starts watching for events matching the given selectors.
func (e *events) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
return e.client.Get().
Path("watch").
Prefix("watch").
Namespace(e.namespace).
Path("events").
Resource("events").
Param("resourceVersion", resourceVersion).
SelectorParam("labels", label).
SelectorParam("fields", field).
Expand Down
8 changes: 4 additions & 4 deletions pkg/client/minions.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ func (c *nodes) resourceName() string {
// Create creates a new minion.
func (c *nodes) Create(minion *api.Node) (*api.Node, error) {
result := &api.Node{}
err := c.r.Post().Path(c.resourceName()).Body(minion).Do().Into(result)
err := c.r.Post().Resource(c.resourceName()).Body(minion).Do().Into(result)
return result, err
}

// List lists all the nodes in the cluster.
func (c *nodes) List() (*api.NodeList, error) {
result := &api.NodeList{}
err := c.r.Get().Path(c.resourceName()).Do().Into(result)
err := c.r.Get().Resource(c.resourceName()).Do().Into(result)
return result, err
}

Expand All @@ -73,11 +73,11 @@ func (c *nodes) Get(name string) (*api.Node, error) {
}

result := &api.Node{}
err := c.r.Get().Path(c.resourceName()).Path(name).Do().Into(result)
err := c.r.Get().Resource(c.resourceName()).Name(name).Do().Into(result)
return result, err
}

// Delete deletes an existing minion.
func (c *nodes) Delete(name string) error {
return c.r.Delete().Path(c.resourceName()).Path(name).Do().Error()
return c.r.Delete().Resource(c.resourceName()).Name(name).Do().Error()
}
10 changes: 5 additions & 5 deletions pkg/client/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func newPods(c *Client, namespace string) *pods {
// ListPods takes a selector, and returns the list of pods that match that selector.
func (c *pods) List(selector labels.Selector) (result *api.PodList, err error) {
result = &api.PodList{}
err = c.r.Get().Namespace(c.ns).Path("pods").SelectorParam("labels", selector).Do().Into(result)
err = c.r.Get().Namespace(c.ns).Resource("pods").SelectorParam("labels", selector).Do().Into(result)
return
}

Expand All @@ -66,19 +66,19 @@ func (c *pods) Get(name string) (result *api.Pod, err error) {
}

result = &api.Pod{}
err = c.r.Get().Namespace(c.ns).Path("pods").Path(name).Do().Into(result)
err = c.r.Get().Namespace(c.ns).Resource("pods").Name(name).Do().Into(result)
return
}

// DeletePod takes the name of the pod, and returns an error if one occurs
func (c *pods) Delete(name string) error {
return c.r.Delete().Namespace(c.ns).Path("pods").Path(name).Do().Error()
return c.r.Delete().Namespace(c.ns).Resource("pods").Name(name).Do().Error()
}

// CreatePod takes the representation of a pod. Returns the server's representation of the pod, and an error, if it occurs.
func (c *pods) Create(pod *api.Pod) (result *api.Pod, err error) {
result = &api.Pod{}
err = c.r.Post().Namespace(c.ns).Path("pods").Body(pod).Do().Into(result)
err = c.r.Post().Namespace(c.ns).Resource("pods").Body(pod).Do().Into(result)
return
}

Expand All @@ -89,6 +89,6 @@ func (c *pods) Update(pod *api.Pod) (result *api.Pod, err error) {
err = fmt.Errorf("invalid update object, missing resource version: %v", pod)
return
}
err = c.r.Put().Namespace(c.ns).Path("pods").Path(pod.Name).Body(pod).Do().Into(result)
err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).Body(pod).Do().Into(result)
return
}
14 changes: 7 additions & 7 deletions pkg/client/replication_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func newReplicationControllers(c *Client, namespace string) *replicationControll
// List takes a selector, and returns the list of replication controllers that match that selector.
func (c *replicationControllers) List(selector labels.Selector) (result *api.ReplicationControllerList, err error) {
result = &api.ReplicationControllerList{}
err = c.r.Get().Namespace(c.ns).Path("replicationControllers").SelectorParam("labels", selector).Do().Into(result)
err = c.r.Get().Namespace(c.ns).Resource("replicationControllers").SelectorParam("labels", selector).Do().Into(result)
return
}

Expand All @@ -65,14 +65,14 @@ func (c *replicationControllers) Get(name string) (result *api.ReplicationContro
}

result = &api.ReplicationController{}
err = c.r.Get().Namespace(c.ns).Path("replicationControllers").Path(name).Do().Into(result)
err = c.r.Get().Namespace(c.ns).Resource("replicationControllers").Name(name).Do().Into(result)
return
}

// Create creates a new replication controller.
func (c *replicationControllers) Create(controller *api.ReplicationController) (result *api.ReplicationController, err error) {
result = &api.ReplicationController{}
err = c.r.Post().Namespace(c.ns).Path("replicationControllers").Body(controller).Do().Into(result)
err = c.r.Post().Namespace(c.ns).Resource("replicationControllers").Body(controller).Do().Into(result)
return
}

Expand All @@ -83,21 +83,21 @@ func (c *replicationControllers) Update(controller *api.ReplicationController) (
err = fmt.Errorf("invalid update object, missing resource version: %v", controller)
return
}
err = c.r.Put().Namespace(c.ns).Path("replicationControllers").Path(controller.Name).Body(controller).Do().Into(result)
err = c.r.Put().Namespace(c.ns).Resource("replicationControllers").Name(controller.Name).Body(controller).Do().Into(result)
return
}

// Delete deletes an existing replication controller.
func (c *replicationControllers) Delete(name string) error {
return c.r.Delete().Namespace(c.ns).Path("replicationControllers").Path(name).Do().Error()
return c.r.Delete().Namespace(c.ns).Resource("replicationControllers").Name(name).Do().Error()
}

// Watch returns a watch.Interface that watches the requested controllers.
func (c *replicationControllers) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Path("watch").
Prefix("watch").
Namespace(c.ns).
Path("replicationControllers").
Resource("replicationControllers").
Param("resourceVersion", resourceVersion).
SelectorParam("labels", label).
SelectorParam("fields", field).
Expand Down
Loading

0 comments on commit e355f54

Please sign in to comment.