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
9d23d750
Commit
9d23d750
authored
Jan 15, 2016
by
Chao Xu
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19499 from caesarxuchao/scale-client-gen
client-gen: typed client with only the expansion interface
parents
d4379ef9
b8be5e13
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
17 deletions
+82
-17
generator-for-type.go
cmd/libs/go2idl/client-gen/generators/generator-for-type.go
+31
-17
types.go
pkg/apis/extensions/types.go
+2
-0
extensions_client.go
...ped/generated/extensions/unversioned/extensions_client.go
+5
-0
generated_expansion.go
...d/generated/extensions/unversioned/generated_expansion.go
+2
-0
scale.go
pkg/client/typed/generated/extensions/unversioned/scale.go
+42
-0
No files found.
cmd/libs/go2idl/client-gen/generators/generator-for-type.go
View file @
9d23d750
...
@@ -84,12 +84,19 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
...
@@ -84,12 +84,19 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
}
else
{
}
else
{
sw
.
Do
(
getterNonNamesapced
,
m
)
sw
.
Do
(
getterNonNamesapced
,
m
)
}
}
noMethods
:=
types
.
ExtractCommentTags
(
"+"
,
t
.
SecondClosestCommentLines
)[
"noMethods"
]
==
"true"
sw
.
Do
(
interfaceTemplate1
,
m
)
sw
.
Do
(
interfaceTemplate1
,
m
)
// Include the UpdateStatus method if the type has a status
if
!
noMethods
{
if
hasStatus
(
t
)
{
sw
.
Do
(
interfaceTemplate2
,
m
)
sw
.
Do
(
interfaceUpdateStatusTemplate
,
m
)
// Include the UpdateStatus method if the type has a status
if
hasStatus
(
t
)
{
sw
.
Do
(
interfaceUpdateStatusTemplate
,
m
)
}
sw
.
Do
(
interfaceTemplate3
,
m
)
}
}
sw
.
Do
(
interfaceTemplate2
,
m
)
sw
.
Do
(
interfaceTemplate4
,
m
)
if
namespaced
{
if
namespaced
{
sw
.
Do
(
structNamespaced
,
m
)
sw
.
Do
(
structNamespaced
,
m
)
sw
.
Do
(
newStructNamespaced
,
m
)
sw
.
Do
(
newStructNamespaced
,
m
)
...
@@ -97,17 +104,20 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
...
@@ -97,17 +104,20 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
sw
.
Do
(
structNonNamespaced
,
m
)
sw
.
Do
(
structNonNamespaced
,
m
)
sw
.
Do
(
newStructNonNamespaced
,
m
)
sw
.
Do
(
newStructNonNamespaced
,
m
)
}
}
sw
.
Do
(
createTemplate
,
m
)
sw
.
Do
(
updateTemplate
,
m
)
if
!
noMethods
{
// Generate the UpdateStatus method if the type has a status
sw
.
Do
(
createTemplate
,
m
)
if
hasStatus
(
t
)
{
sw
.
Do
(
updateTemplate
,
m
)
sw
.
Do
(
updateStatusTemplate
,
m
)
// Generate the UpdateStatus method if the type has a status
if
hasStatus
(
t
)
{
sw
.
Do
(
updateStatusTemplate
,
m
)
}
sw
.
Do
(
deleteTemplate
,
m
)
sw
.
Do
(
deleteCollectionTemplate
,
m
)
sw
.
Do
(
getTemplate
,
m
)
sw
.
Do
(
listTemplate
,
m
)
sw
.
Do
(
watchTemplate
,
m
)
}
}
sw
.
Do
(
deleteTemplate
,
m
)
sw
.
Do
(
deleteCollectionTemplate
,
m
)
sw
.
Do
(
getTemplate
,
m
)
sw
.
Do
(
listTemplate
,
m
)
sw
.
Do
(
watchTemplate
,
m
)
return
sw
.
Error
()
return
sw
.
Error
()
}
}
...
@@ -132,7 +142,9 @@ type $.type|publicPlural$Getter interface {
...
@@ -132,7 +142,9 @@ type $.type|publicPlural$Getter interface {
// this type's interface, typed client will implement this interface.
// this type's interface, typed client will implement this interface.
var
interfaceTemplate1
=
`
var
interfaceTemplate1
=
`
// $.type|public$Interface has methods to work with $.type|public$ resources.
// $.type|public$Interface has methods to work with $.type|public$ resources.
type $.type|public$Interface interface {
type $.type|public$Interface interface {`
var
interfaceTemplate2
=
`
Create(*$.type|raw$) (*$.type|raw$, error)
Create(*$.type|raw$) (*$.type|raw$, error)
Update(*$.type|raw$) (*$.type|raw$, error)`
Update(*$.type|raw$) (*$.type|raw$, error)`
...
@@ -140,12 +152,14 @@ var interfaceUpdateStatusTemplate = `
...
@@ -140,12 +152,14 @@ var interfaceUpdateStatusTemplate = `
UpdateStatus(*$.type|raw$) (*$.type|raw$, error)`
UpdateStatus(*$.type|raw$) (*$.type|raw$, error)`
// template for the Interface
// template for the Interface
var
interfaceTemplate
2
=
`
var
interfaceTemplate
3
=
`
Delete(name string, options *$.apiDeleteOptions|raw$) error
Delete(name string, options *$.apiDeleteOptions|raw$) error
DeleteCollection(options *$.apiDeleteOptions|raw$, listOptions $.apiListOptions|raw$) error
DeleteCollection(options *$.apiDeleteOptions|raw$, listOptions $.apiListOptions|raw$) error
Get(name string) (*$.type|raw$, error)
Get(name string) (*$.type|raw$, error)
List(opts $.apiListOptions|raw$) (*$.type|raw$List, error)
List(opts $.apiListOptions|raw$) (*$.type|raw$List, error)
Watch(opts $.apiListOptions|raw$) ($.watchInterface|raw$, error)
Watch(opts $.apiListOptions|raw$) ($.watchInterface|raw$, error)`
var
interfaceTemplate4
=
`
$.type|public$Expansion
$.type|public$Expansion
}
}
`
`
...
...
pkg/apis/extensions/types.go
View file @
9d23d750
...
@@ -49,6 +49,8 @@ type ScaleStatus struct {
...
@@ -49,6 +49,8 @@ type ScaleStatus struct {
Selector
map
[
string
]
string
`json:"selector,omitempty"`
Selector
map
[
string
]
string
`json:"selector,omitempty"`
}
}
// +genclient=true,noMethods=true
// represents a scaling request for a resource.
// represents a scaling request for a resource.
type
Scale
struct
{
type
Scale
struct
{
unversioned
.
TypeMeta
`json:",inline"`
unversioned
.
TypeMeta
`json:",inline"`
...
...
pkg/client/typed/generated/extensions/unversioned/extensions_client.go
View file @
9d23d750
...
@@ -28,6 +28,7 @@ type ExtensionsInterface interface {
...
@@ -28,6 +28,7 @@ type ExtensionsInterface interface {
HorizontalPodAutoscalersGetter
HorizontalPodAutoscalersGetter
IngressesGetter
IngressesGetter
JobsGetter
JobsGetter
ScalesGetter
ThirdPartyResourcesGetter
ThirdPartyResourcesGetter
}
}
...
@@ -56,6 +57,10 @@ func (c *ExtensionsClient) Jobs(namespace string) JobInterface {
...
@@ -56,6 +57,10 @@ func (c *ExtensionsClient) Jobs(namespace string) JobInterface {
return
newJobs
(
c
,
namespace
)
return
newJobs
(
c
,
namespace
)
}
}
func
(
c
*
ExtensionsClient
)
Scales
(
namespace
string
)
ScaleInterface
{
return
newScales
(
c
,
namespace
)
}
func
(
c
*
ExtensionsClient
)
ThirdPartyResources
(
namespace
string
)
ThirdPartyResourceInterface
{
func
(
c
*
ExtensionsClient
)
ThirdPartyResources
(
namespace
string
)
ThirdPartyResourceInterface
{
return
newThirdPartyResources
(
c
,
namespace
)
return
newThirdPartyResources
(
c
,
namespace
)
}
}
...
...
pkg/client/typed/generated/extensions/unversioned/generated_expansion.go
View file @
9d23d750
...
@@ -26,4 +26,6 @@ type IngressExpansion interface{}
...
@@ -26,4 +26,6 @@ type IngressExpansion interface{}
type
JobExpansion
interface
{}
type
JobExpansion
interface
{}
type
ScaleExpansion
interface
{}
type
ThirdPartyResourceExpansion
interface
{}
type
ThirdPartyResourceExpansion
interface
{}
pkg/client/typed/generated/extensions/unversioned/scale.go
0 → 100644
View file @
9d23d750
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
unversioned
// ScalesGetter has a method to return a ScaleInterface.
// A group's client should implement this interface.
type
ScalesGetter
interface
{
Scales
(
namespace
string
)
ScaleInterface
}
// ScaleInterface has methods to work with Scale resources.
type
ScaleInterface
interface
{
ScaleExpansion
}
// scales implements ScaleInterface
type
scales
struct
{
client
*
ExtensionsClient
ns
string
}
// newScales returns a Scales
func
newScales
(
c
*
ExtensionsClient
,
namespace
string
)
*
scales
{
return
&
scales
{
client
:
c
,
ns
:
namespace
,
}
}
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