Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
4473abf3
Commit
4473abf3
authored
Dec 15, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update client-generator
parent
e309583f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
5 deletions
+32
-5
generator-for-type.go
cmd/libs/go2idl/client-gen/generators/generator-for-type.go
+32
-5
No files found.
cmd/libs/go2idl/client-gen/generators/generator-for-type.go
View file @
4473abf3
...
...
@@ -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
)
...
...
@@ -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
)
...
...
@@ -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 $.
unv
ListOptions|raw$) (*$.type|raw$List, error)
Watch(opts $.
unv
ListOptions|raw$) ($.watchInterface|raw$, error)
List(opts $.
api
ListOptions|raw$) (*$.type|raw$List, error)
Watch(opts $.
api
ListOptions|raw$) ($.watchInterface|raw$, error)
}
`
...
...
@@ -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 $.
unv
ListOptions|raw$) (result *$.type|raw$List, err error) {
func (c *$.type|privatePlural$) List(opts $.
api
ListOptions|raw$) (result *$.type|raw$List, err error) {
result = &$.type|raw$List{}
err = c.client.Get().
Namespace(c.ns).
...
...
@@ -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) {
...
...
@@ -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 $.
unv
ListOptions|raw$) ($.watchInterface|raw$, error) {
func (c *$.type|privatePlural$) Watch(opts $.
api
ListOptions|raw$) ($.watchInterface|raw$, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment