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 { func (c *Client) ReplicationControllers(namespace string) ReplicationControllerInterface {
return NewReplicationControllersClient(c, namespace) return newReplicationControllers(c, namespace)
} }
func (c *Client) Minions() MinionInterface { func (c *Client) Minions() MinionInterface {
return NewMinionsClient(c) return newMinions(c)
} }
func (c *Client) Events() EventInterface { func (c *Client) Events() EventInterface {
return NewEventsClient(c) return newEvents(c)
} }
func (c *Client) Endpoints(namespace string) EndpointsInterface { func (c *Client) Endpoints(namespace string) EndpointsInterface {
return NewEndpointsClient(c, namespace) return newEndpoints(c, namespace)
} }
func (c *Client) Pods(namespace string) PodInterface { func (c *Client) Pods(namespace string) PodInterface {
return NewPodsClient(c, namespace) return newPods(c, namespace)
} }
func (c *Client) Services(namespace string) ServiceInterface { func (c *Client) Services(namespace string) ServiceInterface {
return NewServicesClient(c, namespace) return newServices(c, namespace)
} }
// VersionInterface has a method to retrieve the server version. // 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) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
} }
// EndpointsClient implements EndpointsNamespacer interface // endpoints implements EndpointsNamespacer interface
type EndpointsClient struct { type endpoints struct {
r *Client r *Client
ns string ns string
} }
// NewEndpointsClient returns a EndpointsClient // newEndpoints returns a endpoints
func NewEndpointsClient(c *Client, namespace string) *EndpointsClient { func newEndpoints(c *Client, namespace string) *endpoints {
return &EndpointsClient{c, namespace} return &endpoints{c, namespace}
} }
// Create creates a new endpoint. // 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{} result := &api.Endpoints{}
err := c.r.Post().Namespace(c.ns).Path("endpoints").Body(endpoints).Do().Into(result) err := c.r.Post().Namespace(c.ns).Path("endpoints").Body(endpoints).Do().Into(result)
return result, err return result, err
} }
// List takes a selector, and returns the list of endpoints that match that selector // 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{} 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).Path("endpoints").SelectorParam("labels", selector).Do().Into(result)
return return
} }
// Get returns information about the endpoints for a particular service. // 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{} result = &api.Endpoints{}
err = c.r.Get().Namespace(c.ns).Path("endpoints").Path(id).Do().Into(result) err = c.r.Get().Namespace(c.ns).Path("endpoints").Path(id).Do().Into(result)
return return
} }
// Watch returns a watch.Interface that watches the requested endpoints for a service. // 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(). return c.r.Get().
Namespace(c.ns). Namespace(c.ns).
Path("watch"). Path("watch").
@ -82,7 +82,7 @@ func (c *EndpointsClient) Watch(label, field labels.Selector, resourceVersion st
Watch() Watch()
} }
func (c *EndpointsClient) Update(endpoints *api.Endpoints) (*api.Endpoints, error) { func (c *endpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error) {
result := &api.Endpoints{} result := &api.Endpoints{}
if len(endpoints.ResourceVersion) == 0 { if len(endpoints.ResourceVersion) == 0 {
return nil, fmt.Errorf("invalid update object, missing resource version: %v", endpoints) 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) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
} }
// EventsClient implements Events interface // events implements Events interface
type EventsClient struct { type events struct {
r *Client r *Client
} }
// NewEventsClient returns a EventsClient // newEvents returns a events
func NewEventsClient(c *Client) *EventsClient { func newEvents(c *Client) *events {
return &EventsClient{ return &events{
r: c, r: c,
} }
} }
// Create makes a new event. Returns the copy of the event the server returns, or an error. // 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{} result := &api.Event{}
err := c.r.Post().Path("events").Body(event).Do().Into(result) err := c.r.Post().Path("events").Body(event).Do().Into(result)
return result, err return result, err
} }
// List returns a list of events matching the selectors. // 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{} result := &api.EventList{}
err := c.r.Get(). err := c.r.Get().
Path("events"). 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. // 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{} result := &api.Event{}
err := c.r.Get().Path("events").Path(id).Do().Into(result) err := c.r.Get().Path("events").Path(id).Do().Into(result)
return result, err return result, err
} }
// Watch starts watching for events matching the given selectors. // 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(). return c.r.Get().
Path("watch"). Path("watch").
Path("events"). Path("events").

View File

@ -31,38 +31,38 @@ type MinionInterface interface {
Delete(id string) error Delete(id string) error
} }
// MinionsClient implements Minions interface // minions implements Minions interface
type MinionsClient struct { type minions struct {
r *Client r *Client
} }
// NewMinionsClient returns a MinionsClient // newMinions returns a minions
func NewMinionsClient(c *Client) *MinionsClient { func newMinions(c *Client) *minions {
return &MinionsClient{c} return &minions{c}
} }
// Create creates a new minion. // 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{} result := &api.Minion{}
err := c.r.Post().Path("minions").Body(minion).Do().Into(result) err := c.r.Post().Path("minions").Body(minion).Do().Into(result)
return result, err return result, err
} }
// List lists all the minions in the cluster. // 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{} result = &api.MinionList{}
err = c.r.Get().Path("minions").Do().Into(result) err = c.r.Get().Path("minions").Do().Into(result)
return return
} }
// Get gets an existing minion // 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{} result = &api.Minion{}
err = c.r.Get().Path("minions").Path(id).Do().Into(result) err = c.r.Get().Path("minions").Path(id).Do().Into(result)
return return
} }
// Delete deletes an existing minion. // 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() 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) Update(pod *api.Pod) (*api.Pod, error)
} }
// PodsClient implements PodsNamespacer interface // pods implements PodsNamespacer interface
type PodsClient struct { type pods struct {
r *Client r *Client
ns string ns string
} }
// NewPodsClient returns a PodsClient // newPods returns a pods
func NewPodsClient(c *Client, namespace string) *PodsClient { func newPods(c *Client, namespace string) *pods {
return &PodsClient{ return &pods{
r: c, r: c,
ns: namespace, ns: namespace,
} }
} }
// ListPods takes a selector, and returns the list of pods that match that selector. // 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{} 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).Path("pods").SelectorParam("labels", selector).Do().Into(result)
return return
} }
// GetPod takes the name of the pod, and returns the corresponding Pod object, and an error if it occurs // 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{} result = &api.Pod{}
err = c.r.Get().Namespace(c.ns).Path("pods").Path(name).Do().Into(result) err = c.r.Get().Namespace(c.ns).Path("pods").Path(name).Do().Into(result)
return return
} }
// DeletePod takes the name of the pod, and returns an error if one occurs // 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() 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. // 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{} result = &api.Pod{}
err = c.r.Post().Namespace(c.ns).Path("pods").Body(pod).Do().Into(result) err = c.r.Post().Namespace(c.ns).Path("pods").Body(pod).Do().Into(result)
return return
} }
// UpdatePod takes the representation of a pod to update. Returns the server's representation of the pod, and an error, if it occurs. // 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{} result = &api.Pod{}
if len(pod.ResourceVersion) == 0 { if len(pod.ResourceVersion) == 0 {
err = fmt.Errorf("invalid update object, missing resource version: %v", pod) 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) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
} }
// ReplicationControllersClient implements ReplicationControllersNamespacer interface // replicationControllers implements ReplicationControllersNamespacer interface
type ReplicationControllersClient struct { type replicationControllers struct {
r *Client r *Client
ns string ns string
} }
// NewReplicationControllersClient returns a PodsClient // newReplicationControllers returns a PodsClient
func NewReplicationControllersClient(c *Client, namespace string) *ReplicationControllersClient { func newReplicationControllers(c *Client, namespace string) *replicationControllers {
return &ReplicationControllersClient{c, namespace} return &replicationControllers{c, namespace}
} }
// List takes a selector, and returns the list of replication controllers that match that selector. // 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{} 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).Path("replicationControllers").SelectorParam("labels", selector).Do().Into(result)
return return
} }
// Get returns information about a particular replication controller. // 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{} result = &api.ReplicationController{}
err = c.r.Get().Namespace(c.ns).Path("replicationControllers").Path(name).Do().Into(result) err = c.r.Get().Namespace(c.ns).Path("replicationControllers").Path(name).Do().Into(result)
return return
} }
// Create creates a new replication controller. // 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{} result = &api.ReplicationController{}
err = c.r.Post().Namespace(c.ns).Path("replicationControllers").Body(controller).Do().Into(result) err = c.r.Post().Namespace(c.ns).Path("replicationControllers").Body(controller).Do().Into(result)
return return
} }
// Update updates an existing replication controller. // 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{} result = &api.ReplicationController{}
if len(controller.ResourceVersion) == 0 { if len(controller.ResourceVersion) == 0 {
err = fmt.Errorf("invalid update object, missing resource version: %v", controller) 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. // 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() return c.r.Delete().Namespace(c.ns).Path("replicationControllers").Path(name).Do().Error()
} }
// Watch returns a watch.Interface that watches the requested controllers. // 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(). return c.r.Get().
Namespace(c.ns). Namespace(c.ns).
Path("watch"). Path("watch").

View File

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