Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Fix endpoints pluralization #28

Merged
merged 2 commits into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func (r byGroup) Less(i, j int) bool {
// Incorrect but this is basically what Kubernetes does.
func pluralize(s string) string {
switch {
case strings.HasSuffix(s, "points"):
// NOTE: the k8s "endpoints" resource is already pluralized
return s
case strings.HasSuffix(s, "s"):
return s + "es"
case strings.HasSuffix(s, "y"):
Expand Down
24 changes: 12 additions & 12 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (c *CoreV1) CreateEndpoints(ctx context.Context, obj *apiv1.Endpoints) (*ap
}
md.Namespace = &ns
}
url := c.client.urlFor("", "v1", ns, "endpointses", "")
url := c.client.urlFor("", "v1", ns, "endpoints", "")
resp := new(apiv1.Endpoints)
err := c.client.create(ctx, pbCodec, "POST", url, obj, resp)
if err != nil {
Expand Down Expand Up @@ -410,7 +410,7 @@ func (c *CoreV1) UpdateEndpoints(ctx context.Context, obj *apiv1.Endpoints) (*ap
}
md.Namespace = &ns
}
url := c.client.urlFor("", "v1", *md.Namespace, "endpointses", *md.Name)
url := c.client.urlFor("", "v1", *md.Namespace, "endpoints", *md.Name)
resp := new(apiv1.Endpoints)
err := c.client.create(ctx, pbCodec, "PUT", url, obj, resp)
if err != nil {
Expand All @@ -424,8 +424,8 @@ func (c *CoreV1) DeleteEndpoints(ctx context.Context, name string, namespace str
return fmt.Errorf("create: no name for given object")
}
ns := c.client.namespaceFor(namespace)
url := c.client.urlFor("", "v1", ns, "endpointses", name)

url := c.client.urlFor("", "v1", ns, "endpoints", name)
return c.client.delete(ctx, pbCodec, url)
}

Expand All @@ -434,8 +434,8 @@ func (c *CoreV1) GetEndpoints(ctx context.Context, name, namespace string) (*api
return nil, fmt.Errorf("create: no name for given object")
}
ns := c.client.namespaceFor(namespace)
url := c.client.urlFor("", "v1", ns, "endpointses", name)

url := c.client.urlFor("", "v1", ns, "endpoints", name)
resp := new(apiv1.Endpoints)
if err := c.client.get(ctx, pbCodec, url, resp); err != nil {
return nil, err
Expand Down Expand Up @@ -463,21 +463,21 @@ func (w *CoreV1EndpointsWatcher) Close() error {
return w.watcher.Close()
}

func (c *CoreV1) WatchEndpointses(ctx context.Context, namespace string, options ...Option) (*CoreV1EndpointsWatcher, error){
func (c *CoreV1) WatchEndpoints(ctx context.Context, namespace string, options ...Option) (*CoreV1EndpointsWatcher, error) {
ns := c.client.namespaceFor(namespace)
url := c.client.urlFor("", "v1", ns, "endpointses", "", options...)

url := c.client.urlFor("", "v1", ns, "endpoints", "", options...)
watcher, err := c.client.watch(ctx, url)
if err != nil {
return nil, err
}
return &CoreV1EndpointsWatcher{watcher}, nil
}

func (c *CoreV1) ListEndpointses(ctx context.Context, namespace string, options ...Option) (*apiv1.EndpointsList, error) {
func (c *CoreV1) ListEndpoints(ctx context.Context, namespace string, options ...Option) (*apiv1.EndpointsList, error) {
ns := c.client.namespaceFor(namespace)
url := c.client.urlFor("", "v1", ns, "endpointses", "", options...)

url := c.client.urlFor("", "v1", ns, "endpoints", "", options...)
resp := new(apiv1.EndpointsList)
if err := c.client.get(ctx, pbCodec, url, resp); err != nil {
return nil, err
Expand Down