Skip to content

Commit

Permalink
Fixup client to map api2 to api
Browse files Browse the repository at this point in the history
  • Loading branch information
derekwaynecarr committed Nov 5, 2014
1 parent c5e20bc commit b930e95
Show file tree
Hide file tree
Showing 22 changed files with 153 additions and 153 deletions.
8 changes: 4 additions & 4 deletions pkg/client2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"encoding/json"
"fmt"

"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
"github.com/openshift/origin/pkg/version2"
)

Expand Down Expand Up @@ -65,10 +65,10 @@ type VersionInterface interface {
ServerAPIVersions() (*version.APIVersions, error)
}

// APIStatus is exposed by errors that can be converted to an api2..Status object
// APIStatus is exposed by errors that can be converted to an api..Status object
// for finer grained details.
type APIStatus interface {
Status() api2.Status
Status() api.Status
}

// Client is the implementation of a Kubernetes client.
Expand All @@ -92,7 +92,7 @@ func (c *Client) ServerVersion() (*version.Info, error) {

// ServerAPIVersions retrieves and parses the list of API versions the server supports.
func (c *Client) ServerAPIVersions() (*version.APIVersions, error) {
body, err := c.Get().AbsPath("/api2.").Do().Raw()
body, err := c.Get().AbsPath("/api.").Do().Raw()
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/client2/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"reflect"
"testing"

"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
"github.com/openshift/origin/pkg/api2/latest"
"github.com/openshift/origin/pkg/labels"
"github.com/openshift/origin/pkg/resources"
Expand Down
4 changes: 2 additions & 2 deletions pkg/client2/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ limitations under the License.
package client2

import (
"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
"github.com/openshift/origin/pkg/labels"
"github.com/openshift/origin/pkg/util/wait"
)

// ControllerHasDesiredReplicas returns a condition that will be true iff the desired replica count
// for a controller's ReplicaSelector equals the Replicas count.
func (c *Client) ControllerHasDesiredReplicas(controller api2.ReplicationController) wait.ConditionFunc {
func (c *Client) ControllerHasDesiredReplicas(controller api.ReplicationController) wait.ConditionFunc {
return func() (bool, error) {
pods, err := c.Pods(controller.Namespace).List(labels.Set(controller.DesiredState.ReplicaSelector).AsSelector())
if err != nil {
Expand Down
26 changes: 13 additions & 13 deletions pkg/client2/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package client2
import (
"fmt"

"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
"github.com/openshift/origin/pkg/labels"
"github.com/openshift/origin/pkg/watch"
)
Expand All @@ -31,10 +31,10 @@ type EndpointsNamespacer interface {

// EndpointsInterface has methods to work with Endpoints resources
type EndpointsInterface interface {
Create(endpoints *api2.Endpoints) (*api2.Endpoints, error)
List(selector labels.Selector) (*api2.EndpointsList, error)
Get(id string) (*api2.Endpoints, error)
Update(endpoints *api2.Endpoints) (*api2.Endpoints, error)
Create(endpoints *api.Endpoints) (*api.Endpoints, error)
List(selector labels.Selector) (*api.EndpointsList, error)
Get(id string) (*api.Endpoints, error)
Update(endpoints *api.Endpoints) (*api.Endpoints, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
}

Expand All @@ -50,22 +50,22 @@ func newEndpoints(c *Client, namespace string) *endpoints {
}

// Create creates a new endpoint.
func (c *endpoints) Create(endpoints *api2.Endpoints) (*api2.Endpoints, error) {
result := &api2.Endpoints{}
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)
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 *api2.EndpointsList, err error) {
result = &api2.EndpointsList{}
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)
return
}

// Get returns information about the endpoints for a particular service.
func (c *endpoints) Get(id string) (result *api2.Endpoints, err error) {
result = &api2.Endpoints{}
func (c *endpoints) Get(id string) (result *api.Endpoints, err error) {
result = &api.Endpoints{}
err = c.r.Get().Namespace(c.ns).Path("endpoints").Path(id).Do().Into(result)
return
}
Expand All @@ -82,8 +82,8 @@ func (c *endpoints) Watch(label, field labels.Selector, resourceVersion string)
Watch()
}

func (c *endpoints) Update(endpoints *api2.Endpoints) (*api2.Endpoints, error) {
result := &api2.Endpoints{}
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)
}
Expand Down
20 changes: 10 additions & 10 deletions pkg/client2/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package client2

import (
"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
"github.com/openshift/origin/pkg/labels"
"github.com/openshift/origin/pkg/watch"
)
Expand All @@ -29,9 +29,9 @@ type EventsInterface interface {

// EventInterface has methods to work with Event resources
type EventInterface interface {
Create(event *api2.Event) (*api2.Event, error)
List(label, field labels.Selector) (*api2.EventList, error)
Get(id string) (*api2.Event, error)
Create(event *api.Event) (*api.Event, error)
List(label, field labels.Selector) (*api.EventList, error)
Get(id string) (*api.Event, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
}

Expand All @@ -48,15 +48,15 @@ func newEvents(c *Client) *events {
}

// Create makes a new event. Returns the copy of the event the server returns, or an error.
func (c *events) Create(event *api2.Event) (*api2.Event, error) {
result := &api2.Event{}
func (c *events) Create(event *api.Event) (*api.Event, error) {
result := &api.Event{}
err := c.r.Post().Path("events").Body(event).Do().Into(result)
return result, err
}

// List returns a list of events matching the selectors.
func (c *events) List(label, field labels.Selector) (*api2.EventList, error) {
result := &api2.EventList{}
func (c *events) List(label, field labels.Selector) (*api.EventList, error) {
result := &api.EventList{}
err := c.r.Get().
Path("events").
SelectorParam("labels", label).
Expand All @@ -67,8 +67,8 @@ func (c *events) List(label, field labels.Selector) (*api2.EventList, error) {
}

// Get returns the given event, or an error.
func (c *events) Get(id string) (*api2.Event, error) {
result := &api2.Event{}
func (c *events) Get(id string) (*api.Event, error) {
result := &api.Event{}
err := c.r.Get().Path("events").Path(id).Do().Into(result)
return result, err
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/client2/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package client2

import (
"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
"github.com/openshift/origin/pkg/version2"
"github.com/openshift/origin/pkg/watch"
)
Expand All @@ -31,12 +31,12 @@ type FakeAction struct {
// implementation. This makes faking out just the method you want to test easier.
type Fake struct {
Actions []FakeAction
PodsList api2.PodList
Ctrl api2.ReplicationController
ServiceList api2.ServiceList
EndpointsList api2.EndpointsList
MinionsList api2.MinionList
EventsList api2.EventList
PodsList api.PodList
Ctrl api.ReplicationController
ServiceList api.ServiceList
EndpointsList api.EndpointsList
MinionsList api.MinionList
EventsList api.EventList
Err error
Watch watch.Interface
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/client2/fake_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package client2

import (
"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
"github.com/openshift/origin/pkg/labels"
"github.com/openshift/origin/pkg/watch"
)
Expand All @@ -29,27 +29,27 @@ type FakeEndpoints struct {
Namespace string
}

func (c *FakeEndpoints) Create(endpoints *api2.Endpoints) (*api2.Endpoints, error) {
func (c *FakeEndpoints) Create(endpoints *api.Endpoints) (*api.Endpoints, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-endpoints"})
return &api2.Endpoints{}, nil
return &api.Endpoints{}, nil
}

func (c *FakeEndpoints) List(selector labels.Selector) (*api2.EndpointsList, error) {
func (c *FakeEndpoints) List(selector labels.Selector) (*api.EndpointsList, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-endpoints"})
return api2.Scheme.CopyOrDie(&c.Fake.EndpointsList).(*api2.EndpointsList), c.Fake.Err
return api.Scheme.CopyOrDie(&c.Fake.EndpointsList).(*api.EndpointsList), c.Fake.Err
}

func (c *FakeEndpoints) Get(name string) (*api2.Endpoints, error) {
func (c *FakeEndpoints) Get(name string) (*api.Endpoints, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-endpoints"})
return &api2.Endpoints{}, nil
return &api.Endpoints{}, nil
}

func (c *FakeEndpoints) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-endpoints", Value: resourceVersion})
return c.Fake.Watch, c.Fake.Err
}

func (c *FakeEndpoints) Update(endpoints *api2.Endpoints) (*api2.Endpoints, error) {
func (c *FakeEndpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "update-endpoints", Value: endpoints.Name})
return &api2.Endpoints{}, nil
return &api.Endpoints{}, nil
}
12 changes: 6 additions & 6 deletions pkg/client2/fake_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package client2

import (
"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
"github.com/openshift/origin/pkg/labels"
"github.com/openshift/origin/pkg/watch"
)
Expand All @@ -29,21 +29,21 @@ type FakeEvents struct {
}

// Create makes a new event. Returns the copy of the event the server returns, or an error.
func (c *FakeEvents) Create(event *api2.Event) (*api2.Event, error) {
func (c *FakeEvents) Create(event *api.Event) (*api.Event, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-event", Value: event.Name})
return &api2.Event{}, nil
return &api.Event{}, nil
}

// List returns a list of events matching the selectors.
func (c *FakeEvents) List(label, field labels.Selector) (*api2.EventList, error) {
func (c *FakeEvents) List(label, field labels.Selector) (*api.EventList, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-events"})
return &c.Fake.EventsList, nil
}

// Get returns the given event, or an error.
func (c *FakeEvents) Get(id string) (*api2.Event, error) {
func (c *FakeEvents) Get(id string) (*api.Event, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-event", Value: id})
return &api2.Event{}, nil
return &api.Event{}, nil
}

// Watch starts watching for events matching the given selectors.
Expand Down
12 changes: 6 additions & 6 deletions pkg/client2/fake_minions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package client2

import (
"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
)

// FakeMinions implements MinionInterface. Meant to be embedded into a struct to get a default
Expand All @@ -26,19 +26,19 @@ type FakeMinions struct {
Fake *Fake
}

func (c *FakeMinions) Get(name string) (*api2.Minion, error) {
func (c *FakeMinions) Get(name string) (*api.Minion, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-minion", Value: name})
return &api2.Minion{}, nil
return &api.Minion{}, nil
}

func (c *FakeMinions) List() (*api2.MinionList, error) {
func (c *FakeMinions) List() (*api.MinionList, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-minions", Value: nil})
return &c.Fake.MinionsList, nil
}

func (c *FakeMinions) Create(minion *api2.Minion) (*api2.Minion, error) {
func (c *FakeMinions) Create(minion *api.Minion) (*api.Minion, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-minion", Value: minion})
return &api2.Minion{}, nil
return &api.Minion{}, nil
}

func (c *FakeMinions) Delete(id string) error {
Expand Down
18 changes: 9 additions & 9 deletions pkg/client2/fake_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package client2

import (
"github.com/openshift/origin/pkg/api2"
api "github.com/openshift/origin/pkg/api2"
"github.com/openshift/origin/pkg/labels"
)

Expand All @@ -28,27 +28,27 @@ type FakePods struct {
Namespace string
}

func (c *FakePods) List(selector labels.Selector) (*api2.PodList, error) {
func (c *FakePods) List(selector labels.Selector) (*api.PodList, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-pods"})
return api2.Scheme.CopyOrDie(&c.Fake.PodsList).(*api2.PodList), nil
return api.Scheme.CopyOrDie(&c.Fake.PodsList).(*api.PodList), nil
}

func (c *FakePods) Get(name string) (*api2.Pod, error) {
func (c *FakePods) Get(name string) (*api.Pod, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-pod", Value: name})
return &api2.Pod{ObjectMeta: api2.ObjectMeta{Name: name, Namespace: c.Namespace}}, nil
return &api.Pod{ObjectMeta: api.ObjectMeta{Name: name, Namespace: c.Namespace}}, nil
}

func (c *FakePods) Delete(name string) error {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-pod", Value: name})
return nil
}

func (c *FakePods) Create(pod *api2.Pod) (*api2.Pod, error) {
func (c *FakePods) Create(pod *api.Pod) (*api.Pod, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-pod"})
return &api2.Pod{}, nil
return &api.Pod{}, nil
}

func (c *FakePods) Update(pod *api2.Pod) (*api2.Pod, error) {
func (c *FakePods) Update(pod *api.Pod) (*api.Pod, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "update-pod", Value: pod.Name})
return &api2.Pod{}, nil
return &api.Pod{}, nil
}
Loading

0 comments on commit b930e95

Please sign in to comment.