Fix client structs to be package private

This commit is contained in:
derekwaynecarr 2014-10-24 11:45:16 -04:00
parent ce30b2657a
commit b7be298f54
7 changed files with 66 additions and 66 deletions

View File

@ -36,27 +36,27 @@ type Interface interface {
}
func (c *Client) ReplicationControllers(namespace string) ReplicationControllerInterface {
return NewReplicationControllersClient(c, namespace)
return newReplicationControllers(c, namespace)
}
func (c *Client) Minions() MinionInterface {
return NewMinionsClient(c)
return newMinions(c)
}
func (c *Client) Events() EventInterface {
return NewEventsClient(c)
return newEvents(c)
}
func (c *Client) Endpoints(namespace string) EndpointsInterface {
return NewEndpointsClient(c, namespace)
return newEndpoints(c, namespace)
}
func (c *Client) Pods(namespace string) PodInterface {
return NewPodsClient(c, namespace)
return newPods(c, namespace)
}
func (c *Client) Services(namespace string) ServiceInterface {
return NewServicesClient(c, namespace)
return newServices(c, namespace)
}
// VersionInterface has a method to retrieve the server version.

View File

@ -38,40 +38,40 @@ type EndpointsInterface interface {
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
}
// EndpointsClient implements EndpointsNamespacer interface
type EndpointsClient struct {
// endpoints implements EndpointsNamespacer interface
type endpoints struct {
r *Client
ns string
}
// NewEndpointsClient returns a EndpointsClient
func NewEndpointsClient(c *Client, namespace string) *EndpointsClient {
return &EndpointsClient{c, namespace}
// newEndpoints returns a endpoints
func newEndpoints(c *Client, namespace string) *endpoints {
return &endpoints{c, namespace}
}
// Create creates a new endpoint.
func (c *EndpointsClient) Create(endpoints *api.Endpoints) (*api.Endpoints, error) {
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 *EndpointsClient) List(selector labels.Selector) (result *api.EndpointsList, err error) {
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 *EndpointsClient) Get(id string) (result *api.Endpoints, err error) {
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
}
// Watch returns a watch.Interface that watches the requested endpoints for a service.
func (c *EndpointsClient) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
func (c *endpoints) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Namespace(c.ns).
Path("watch").
@ -82,7 +82,7 @@ func (c *EndpointsClient) Watch(label, field labels.Selector, resourceVersion st
Watch()
}
func (c *EndpointsClient) Update(endpoints *api.Endpoints) (*api.Endpoints, 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)

View File

@ -35,27 +35,27 @@ type EventInterface interface {
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
}
// EventsClient implements Events interface
type EventsClient struct {
// events implements Events interface
type events struct {
r *Client
}
// NewEventsClient returns a EventsClient
func NewEventsClient(c *Client) *EventsClient {
return &EventsClient{
// newEvents returns a events
func newEvents(c *Client) *events {
return &events{
r: c,
}
}
// Create makes a new event. Returns the copy of the event the server returns, or an error.
func (c *EventsClient) Create(event *api.Event) (*api.Event, error) {
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 *EventsClient) List(label, field labels.Selector) (*api.EventList, error) {
func (c *events) List(label, field labels.Selector) (*api.EventList, error) {
result := &api.EventList{}
err := c.r.Get().
Path("events").
@ -67,14 +67,14 @@ func (c *EventsClient) List(label, field labels.Selector) (*api.EventList, error
}
// Get returns the given event, or an error.
func (c *EventsClient) Get(id string) (*api.Event, error) {
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
}
// Watch starts watching for events matching the given selectors.
func (c *EventsClient) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
func (c *events) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Path("watch").
Path("events").

View File

@ -31,38 +31,38 @@ type MinionInterface interface {
Delete(id string) error
}
// MinionsClient implements Minions interface
type MinionsClient struct {
// minions implements Minions interface
type minions struct {
r *Client
}
// NewMinionsClient returns a MinionsClient
func NewMinionsClient(c *Client) *MinionsClient {
return &MinionsClient{c}
// newMinions returns a minions
func newMinions(c *Client) *minions {
return &minions{c}
}
// Create creates a new minion.
func (c *MinionsClient) Create(minion *api.Minion) (*api.Minion, error) {
func (c *minions) Create(minion *api.Minion) (*api.Minion, error) {
result := &api.Minion{}
err := c.r.Post().Path("minions").Body(minion).Do().Into(result)
return result, err
}
// List lists all the minions in the cluster.
func (c *MinionsClient) List() (result *api.MinionList, err error) {
func (c *minions) List() (result *api.MinionList, err error) {
result = &api.MinionList{}
err = c.r.Get().Path("minions").Do().Into(result)
return
}
// Get gets an existing minion
func (c *MinionsClient) Get(id string) (result *api.Minion, err error) {
func (c *minions) Get(id string) (result *api.Minion, err error) {
result = &api.Minion{}
err = c.r.Get().Path("minions").Path(id).Do().Into(result)
return
}
// Delete deletes an existing minion.
func (c *MinionsClient) Delete(id string) error {
func (c *minions) Delete(id string) error {
return c.r.Delete().Path("minions").Path(id).Do().Error()
}

View File

@ -37,48 +37,48 @@ type PodInterface interface {
Update(pod *api.Pod) (*api.Pod, error)
}
// PodsClient implements PodsNamespacer interface
type PodsClient struct {
// pods implements PodsNamespacer interface
type pods struct {
r *Client
ns string
}
// NewPodsClient returns a PodsClient
func NewPodsClient(c *Client, namespace string) *PodsClient {
return &PodsClient{
// newPods returns a pods
func newPods(c *Client, namespace string) *pods {
return &pods{
r: c,
ns: namespace,
}
}
// ListPods takes a selector, and returns the list of pods that match that selector.
func (c *PodsClient) List(selector labels.Selector) (result *api.PodList, err error) {
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)
return
}
// GetPod takes the name of the pod, and returns the corresponding Pod object, and an error if it occurs
func (c *PodsClient) Get(name string) (result *api.Pod, err error) {
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)
return
}
// DeletePod takes the name of the pod, and returns an error if one occurs
func (c *PodsClient) Delete(name string) error {
func (c *pods) Delete(name string) error {
return c.r.Delete().Namespace(c.ns).Path("pods").Path(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 *PodsClient) Create(pod *api.Pod) (result *api.Pod, err error) {
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)
return
}
// UpdatePod takes the representation of a pod to update. Returns the server's representation of the pod, and an error, if it occurs.
func (c *PodsClient) Update(pod *api.Pod) (result *api.Pod, err error) {
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)

View File

@ -39,40 +39,40 @@ type ReplicationControllerInterface interface {
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
}
// ReplicationControllersClient implements ReplicationControllersNamespacer interface
type ReplicationControllersClient struct {
// replicationControllers implements ReplicationControllersNamespacer interface
type replicationControllers struct {
r *Client
ns string
}
// NewReplicationControllersClient returns a PodsClient
func NewReplicationControllersClient(c *Client, namespace string) *ReplicationControllersClient {
return &ReplicationControllersClient{c, namespace}
// newReplicationControllers returns a PodsClient
func newReplicationControllers(c *Client, namespace string) *replicationControllers {
return &replicationControllers{c, namespace}
}
// List takes a selector, and returns the list of replication controllers that match that selector.
func (c *ReplicationControllersClient) List(selector labels.Selector) (result *api.ReplicationControllerList, err error) {
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)
return
}
// Get returns information about a particular replication controller.
func (c *ReplicationControllersClient) Get(name string) (result *api.ReplicationController, err error) {
func (c *replicationControllers) Get(name string) (result *api.ReplicationController, err error) {
result = &api.ReplicationController{}
err = c.r.Get().Namespace(c.ns).Path("replicationControllers").Path(name).Do().Into(result)
return
}
// Create creates a new replication controller.
func (c *ReplicationControllersClient) Create(controller *api.ReplicationController) (result *api.ReplicationController, err error) {
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)
return
}
// Update updates an existing replication controller.
func (c *ReplicationControllersClient) Update(controller *api.ReplicationController) (result *api.ReplicationController, err error) {
func (c *replicationControllers) Update(controller *api.ReplicationController) (result *api.ReplicationController, err error) {
result = &api.ReplicationController{}
if len(controller.ResourceVersion) == 0 {
err = fmt.Errorf("invalid update object, missing resource version: %v", controller)
@ -83,12 +83,12 @@ func (c *ReplicationControllersClient) Update(controller *api.ReplicationControl
}
// Delete deletes an existing replication controller.
func (c *ReplicationControllersClient) Delete(name string) error {
func (c *replicationControllers) Delete(name string) error {
return c.r.Delete().Namespace(c.ns).Path("replicationControllers").Path(name).Do().Error()
}
// Watch returns a watch.Interface that watches the requested controllers.
func (c *ReplicationControllersClient) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
func (c *replicationControllers) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Namespace(c.ns).
Path("watch").

View File

@ -39,40 +39,40 @@ type ServiceInterface interface {
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
}
// ServicesClient implements PodsNamespacer interface
type ServicesClient struct {
// services implements PodsNamespacer interface
type services struct {
r *Client
ns string
}
// NewServicesClient returns a PodsClient
func NewServicesClient(c *Client, namespace string) *ServicesClient {
return &ServicesClient{c, namespace}
// newServices returns a PodsClient
func newServices(c *Client, namespace string) *services {
return &services{c, namespace}
}
// List takes a selector, and returns the list of services that match that selector
func (c *ServicesClient) List(selector labels.Selector) (result *api.ServiceList, err error) {
func (c *services) List(selector labels.Selector) (result *api.ServiceList, err error) {
result = &api.ServiceList{}
err = c.r.Get().Namespace(c.ns).Path("services").SelectorParam("labels", selector).Do().Into(result)
return
}
// Get returns information about a particular service.
func (c *ServicesClient) Get(name string) (result *api.Service, err error) {
func (c *services) Get(name string) (result *api.Service, err error) {
result = &api.Service{}
err = c.r.Get().Namespace(c.ns).Path("services").Path(name).Do().Into(result)
return
}
// Create creates a new service.
func (c *ServicesClient) Create(svc *api.Service) (result *api.Service, err error) {
func (c *services) Create(svc *api.Service) (result *api.Service, err error) {
result = &api.Service{}
err = c.r.Post().Namespace(c.ns).Path("services").Body(svc).Do().Into(result)
return
}
// Update updates an existing service.
func (c *ServicesClient) Update(svc *api.Service) (result *api.Service, err error) {
func (c *services) Update(svc *api.Service) (result *api.Service, err error) {
result = &api.Service{}
if len(svc.ResourceVersion) == 0 {
err = fmt.Errorf("invalid update object, missing resource version: %v", svc)
@ -83,12 +83,12 @@ func (c *ServicesClient) Update(svc *api.Service) (result *api.Service, err erro
}
// Delete deletes an existing service.
func (c *ServicesClient) Delete(name string) error {
func (c *services) Delete(name string) error {
return c.r.Delete().Namespace(c.ns).Path("services").Path(name).Do().Error()
}
// Watch returns a watch.Interface that watches the requested services.
func (c *ServicesClient) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
func (c *services) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Namespace(c.ns).
Path("watch").