@@ -117,10 +117,12 @@ func (c *FakeTypedClient) WriteContent(w io.Writer) error {
117117 "hasMethods" : c .Kind .SupportedVerbs .Len () > 0 || len (c .Kind .Extensions ) > 0 ,
118118 "needsApply" : allVerbs .Has ("apply" ),
119119 "needsList" : allVerbs .Has ("list" ),
120+ "needsPatch" : allVerbs .Has ("patch" ),
120121 "apiPackagePath" : c .APIPackagePath ,
121122 "packagePath" : c .PackagePath ,
122123 "singleClusterClientPackagePath" : c .SingleClusterClientPackagePath ,
123124 "singleClusterApplyConfigurationsPackagePath" : c .SingleClusterApplyConfigurationsPackagePath ,
125+ "generateApplyVerbs" : len (c .SingleClusterApplyConfigurationsPackagePath ) > 0 ,
124126 }
125127 return templ .Execute (w , m )
126128}
@@ -158,12 +160,14 @@ import (
158160 "k8s.io/client-go/testing"
159161{{end}}
160162
161- {{- if .needsApply }}
163+ {{- if and .generateApplyVerbs .needsApply }}
162164 "fmt"
163165 "encoding/json"
166+ {{end}}
167+ {{- if or (and .generateApplyVerbs .needsApply) .needsPatch }}
164168 "k8s.io/apimachinery/pkg/types"
165169{{end}}
166- {{- if "apply" | .kind.SupportedVerbs.Has }}
170+ {{- if and .generateApplyVerbs ( "apply" | .kind.SupportedVerbs.Has) }}
167171 applyconfigurations{{.group.PackageAlias}} "{{.singleClusterApplyConfigurationsPackagePath}}/{{.group.Group.PackageName}}/{{.group.Version.PackageName}}"
168172{{end}}
169173
@@ -330,7 +334,7 @@ func (c *{{.kind.Plural | lowerFirst}}Client) Patch(ctx context.Context, name st
330334}
331335{{end -}}
332336
333- {{if "apply" | .kind.SupportedVerbs.Has}}
337+ {{if and .generateApplyVerbs ( "apply" | .kind.SupportedVerbs.Has) }}
334338func (c *{{.kind.Plural | lowerFirst}}Client) Apply(ctx context.Context, applyConfiguration *applyconfigurations{{.group.PackageAlias}}.{{.kind.String}}ApplyConfiguration, opts metav1.ApplyOptions) (*{{.group.PackageAlias}}.{{.kind.String}}, error) {
335339 if applyConfiguration == nil {
336340 return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil")
@@ -351,7 +355,7 @@ func (c *{{.kind.Plural | lowerFirst}}Client) Apply(ctx context.Context, applyCo
351355}
352356{{end -}}
353357
354- {{if "applyStatus" | .kind.SupportedVerbs.Has}}
358+ {{if and .generateApplyVerbs ( "applyStatus" | .kind.SupportedVerbs.Has) }}
355359func (c *{{.kind.Plural | lowerFirst}}Client) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurations{{.group.PackageAlias}}.{{.kind.String}}ApplyConfiguration, opts metav1.ApplyOptions) (*{{.group.PackageAlias}}.{{.kind.String}}, error) {
356360 if applyConfiguration == nil {
357361 return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil")
@@ -435,7 +439,7 @@ func (c *{{$.kind.Plural | lowerFirst}}Client) {{.Method}}(ctx context.Context,
435439}
436440{{end -}}
437441
438- {{if eq .Verb "apply"}}
442+ {{if and $.generateApplyVerbs ( eq .Verb "apply") }}
439443func (c *{{$.kind.Plural | lowerFirst}}Client) {{.Method}}(ctx context.Context, {{$.kind.String | lowerFirst}}Name string, applyConfiguration {{if .InputType}}*{{index $.extraImports .InputPath}}.{{.InputType}}{{else}}*applyconfigurations{{$.group.PackageAlias}}.{{$.kind.String}}ApplyConfiguration,{{end}}, opts metav1.ApplyOptions) (*{{index $.extraImports .ResultPath}}.{{if .ResultType}}{{.ResultType}}{{else}}{{$.kind.String}}{{end}}, error) {
440444 if applyConfiguration == nil {
441445 return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil")
0 commit comments