Skip to content

Commit e4bd128

Browse files
author
Edouard Thuleau
committed
Fixes fake client test generation
The test code generation for create subresource was missing the resource name parameter in the template which caused a compile error for the sample projects using the scale subresource. That only occurs with non-namespaced resource kind. Also re-ran the code generation after applying the fix.
1 parent 05d1b94 commit e4bd128

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

staging/src/k8s.io/code-generator/_examples/MixedCase/apis/example/v1/types.go

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type ClusterTestTypeList struct {
6060
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
6161
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/api/autoscaling/v1.Scale
6262
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
63+
// +genclient:method=CreateScale,verb=create,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
6364

6465
type ClusterTestType struct {
6566
metav1.TypeMeta `json:",inline"`

staging/src/k8s.io/code-generator/_examples/MixedCase/clientset/versioned/typed/example/v1/clustertesttype.go

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/code-generator/_examples/MixedCase/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/code-generator/cmd/client-gen/generators/fake/generator_fake_for_type.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ var createSubresourceTemplate = `
411411
func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
412412
obj, err := c.Fake.
413413
$if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", c.ns, $.inputType|private$), &$.resultType|raw${})
414-
$else$Invokes($.NewRootCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", $.inputType|private$), &$.resultType|raw${})$end$
414+
$else$Invokes($.NewRootCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", $.inputType|private$), &$.resultType|raw${})$end$
415415
if obj == nil {
416416
return nil, err
417417
}

0 commit comments

Comments
 (0)