Skip to content

Commit 34af3cd

Browse files
committed
Check list/watch verbs on types
Signed-off-by: Nelo-T. Wallus <[email protected]>
1 parent e635c8b commit 34af3cd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmd/cluster-client-gen/generators/generator_for_type.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,12 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
144144
sw.Do(nonNamespacedClusterInterfaceImpl, m)
145145
}
146146

147-
if !tags.NoVerbs {
148-
sw.Do(clusterInterfaceVerbs, m)
147+
if !tags.NoVerbs && tags.HasVerb("list") {
148+
sw.Do(listClusterInterfaceImpl, m)
149+
}
150+
151+
if !tags.NoVerbs && tags.HasVerb("watch") {
152+
sw.Do(watchClusterInterfaceImpl, m)
149153
}
150154

151155
if !tags.NonNamespaced {
@@ -228,12 +232,14 @@ func (c *$.type|privatePlural$ClusterInterface) Cluster(clusterPath logicalclust
228232
}
229233
`
230234

231-
var clusterInterfaceVerbs = `
235+
var listClusterInterfaceImpl = `
232236
// List returns the entire collection of all $.type|publicPlural$ across all clusters.
233237
func (c *$.type|privatePlural$ClusterInterface) List(ctx context.Context, opts $.ListOptions|raw$) (*$.resultType|raw$List, error) {
234238
return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).$.type|publicPlural$($if .namespaced$$.NamespaceAll|raw$$end$).List(ctx, opts)
235239
}
240+
`
236241

242+
var watchClusterInterfaceImpl = `
237243
// Watch begins to watch all $.type|publicPlural$ across all clusters.
238244
func (c *$.type|privatePlural$ClusterInterface) Watch(ctx context.Context, opts $.ListOptions|raw$) (watch.Interface, error) {
239245
return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).$.type|publicPlural$($if .namespaced$$.NamespaceAll|raw$$end$).Watch(ctx, opts)

0 commit comments

Comments
 (0)