Skip to content

Commit

Permalink
Merge pull request #18700 from wojtek-t/fix_client_gen_script
Browse files Browse the repository at this point in the history
Auto commit by PR queue bot
  • Loading branch information
k8s-merge-robot committed Dec 17, 2015
2 parents 5f1ebc3 + 4473abf commit cd59d1e
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions cmd/libs/go2idl/client-gen/generators/generator-for-type.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
"Package": namer.IC(pkg),
"watchInterface": c.Universe.Type(types.Name{Package: "k8s.io/kubernetes/pkg/watch", Name: "Interface"}),
"apiDeleteOptions": c.Universe.Type(types.Name{Package: "k8s.io/kubernetes/pkg/api", Name: "DeleteOptions"}),
"unvListOptions": c.Universe.Type(types.Name{Package: "k8s.io/kubernetes/pkg/api/unversioned", Name: "ListOptions"}),
"apiListOptions": c.Universe.Type(types.Name{Package: "k8s.io/kubernetes/pkg/api", Name: "ListOptions"}),
}
sw.Do(namespacerTemplate, m)
sw.Do(interfaceTemplate, m)
Expand All @@ -65,6 +65,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
sw.Do(createTemplate, m)
sw.Do(updateTemplate, m)
sw.Do(deleteTemplate, m)
sw.Do(deleteCollectionTemplate, m)
sw.Do(getTemplate, m)
sw.Do(listTemplate, m)
sw.Do(watchTemplate, m)
Expand All @@ -87,9 +88,10 @@ type $.type|public$Interface interface {
Create(*$.type|raw$) (*$.type|raw$, error)
Update(*$.type|raw$) (*$.type|raw$, error)
Delete(name string, options *$.apiDeleteOptions|raw$) error
DeleteCollection(options *$.apiDeleteOptions|raw$, listOptions $.apiListOptions|raw$) error
Get(name string) (*$.type|raw$, error)
List(opts $.unvListOptions|raw$) (*$.type|raw$List, error)
Watch(opts $.unvListOptions|raw$) ($.watchInterface|raw$, error)
List(opts $.apiListOptions|raw$) (*$.type|raw$List, error)
Watch(opts $.apiListOptions|raw$) ($.watchInterface|raw$, error)
}
`

Expand All @@ -112,7 +114,7 @@ func new$.type|publicPlural$(c *$.Package$Client, namespace string) *$.type|priv
`
var listTemplate = `
// List takes label and field selectors, and returns the list of $.type|publicPlural$ that match those selectors.
func (c *$.type|privatePlural$) List(opts $.unvListOptions|raw$) (result *$.type|raw$List, err error) {
func (c *$.type|privatePlural$) List(opts $.apiListOptions|raw$) (result *$.type|raw$List, err error) {
result = &$.type|raw$List{}
err = c.client.Get().
Namespace(c.ns).
Expand Down Expand Up @@ -157,6 +159,31 @@ func (c *$.type|privatePlural$) Delete(name string, options *$.apiDeleteOptions|
}
`

var deleteCollectionTemplate = `
// DeleteCollection deletes a collection of objects.
func (c *$.type|privatePlural$) DeleteCollection(options *$.apiDeleteOptions|raw$, listOptions $.apiListOptions|raw$) error {
if options == nil {
return c.Client.Delete().
NamespaceIfScoped(e.namespace, len(e.namespace) > 0).
Resource("$.type|privatePlural$").
VersionedParams(&listOptions, api.Scheme).
Do().
Error()
}
body, err := api.Scheme.EncodeToVersion(options, c.client.APIVersion())
if err != nil {
return err
}
return c.Client.Delete().
NamespaceIfScoped(e.namespace, len(e.namespace) > 0).
Resource("$.type|privatePlural$").
VersionedParams(&listOptions, api.Scheme).
Body(body).
Do().
Error()
}
`

var createTemplate = `
// Create takes the representation of a $.type|private$ and creates it. Returns the server's representation of the $.type|private$, and an error, if there is any.
func (c *$.type|privatePlural$) Create($.type|private$ *$.type|raw$) (result *$.type|raw$, err error) {
Expand Down Expand Up @@ -188,7 +215,7 @@ func (c *$.type|privatePlural$) Update($.type|private$ *$.type|raw$) (result *$.

var watchTemplate = `
// Watch returns a $.watchInterface|raw$ that watches the requested $.type|privatePlural$.
func (c *$.type|privatePlural$) Watch(opts $.unvListOptions|raw$) ($.watchInterface|raw$, error) {
func (c *$.type|privatePlural$) Watch(opts $.apiListOptions|raw$) ($.watchInterface|raw$, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Expand Down

1 comment on commit cd59d1e

@k8s-teamcity-mesosphere

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OSS :: Kubernetes Mesos :: 4 - Smoke Tests Build 9702 outcome was SUCCESS
Summary: Tests passed: 1, ignored: 206 Build time: 00:03:53

Please sign in to comment.