mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
allow client-gen genereate typed client with only expansion methods
This commit is contained in:
parent
f9f4b74a29
commit
00b18446ac
@ -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)
|
||||||
|
if !noMethods {
|
||||||
|
sw.Do(interfaceTemplate2, m)
|
||||||
// Include the UpdateStatus method if the type has a status
|
// Include the UpdateStatus method if the type has a status
|
||||||
if hasStatus(t) {
|
if hasStatus(t) {
|
||||||
sw.Do(interfaceUpdateStatusTemplate, m)
|
sw.Do(interfaceUpdateStatusTemplate, m)
|
||||||
}
|
}
|
||||||
sw.Do(interfaceTemplate2, m)
|
sw.Do(interfaceTemplate3, 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,6 +104,8 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !noMethods {
|
||||||
sw.Do(createTemplate, m)
|
sw.Do(createTemplate, m)
|
||||||
sw.Do(updateTemplate, m)
|
sw.Do(updateTemplate, m)
|
||||||
// Generate the UpdateStatus method if the type has a status
|
// Generate the UpdateStatus method if the type has a status
|
||||||
@ -108,6 +117,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
|
|||||||
sw.Do(getTemplate, m)
|
sw.Do(getTemplate, m)
|
||||||
sw.Do(listTemplate, m)
|
sw.Do(listTemplate, m)
|
||||||
sw.Do(watchTemplate, m)
|
sw.Do(watchTemplate, m)
|
||||||
|
}
|
||||||
|
|
||||||
return sw.Error()
|
return sw.Error()
|
||||||
}
|
}
|
||||||
@ -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 = `
|
|||||||
UpdateStatus(*$.type|raw$) (*$.type|raw$, error)`
|
UpdateStatus(*$.type|raw$) (*$.type|raw$, error)`
|
||||||
|
|
||||||
// template for the Interface
|
// template for the Interface
|
||||||
var interfaceTemplate2 = `
|
var interfaceTemplate3 = `
|
||||||
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
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
Loading…
Reference in New Issue
Block a user