Skip to content

Commit ad7c524

Browse files
skittk8s-publishing-bot
authored andcommitted
Generify fake clientsets
This adds a generic implementation of a fake clientset, and uses it to replace the template code in generated fake clientsets for the default methods. The templates are preserved as-is (or as close as they can be) for use in extensions, whether for resources or subresources. Fake clientsets with no extensions are reduced to their main getter, their specific struct, and their constructor. All method implementations are provided by the generic implementation. The dedicated struct is preserved to allow extensions and expansions to be defined where necessary. Instead of handling the variants (with/without list, apply) with a complex sequence of if statements, build up an index into an array containing the various declarations. Similarly, instead of calling different action constructors for namespaced and non-namespaced clientsets, assume the current behaviour of non-namespaced action creation (equivalent to creating a namespaced action with an empty namespace) and document that assumption in the action implementation. Signed-off-by: Stephen Kitt <[email protected]> Kubernetes-commit: b0ce65df9b74d4dc72050840d5ad067596d7b822
1 parent 804c007 commit ad7c524

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

go.mod

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ require (
2727
go.opentelemetry.io/otel/trace v1.28.0
2828
go.uber.org/zap v1.27.0
2929
golang.org/x/sys v0.26.0
30-
k8s.io/apimachinery v0.0.0-20241108022104-96b97de8d6ba
31-
k8s.io/client-go v0.0.0-20241108115827-ec126553e25c
30+
k8s.io/apimachinery v0.0.0-20240920213627-16af2ff33fbf
31+
k8s.io/client-go v0.0.0-20241127164845-55d23e26d5ef
3232
k8s.io/klog/v2 v2.130.1
3333
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
3434
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3
@@ -60,6 +60,7 @@ require (
6060
github.com/mailru/easyjson v0.7.7 // indirect
6161
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6262
github.com/modern-go/reflect2 v1.0.2 // indirect
63+
github.com/pkg/errors v0.9.1 // indirect
6364
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
6465
github.com/x448/float16 v0.8.4 // indirect
6566
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
@@ -75,9 +76,10 @@ require (
7576
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect
7677
google.golang.org/grpc v1.65.0 // indirect
7778
google.golang.org/protobuf v1.35.1 // indirect
79+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
7880
gopkg.in/inf.v0 v0.9.1 // indirect
7981
gopkg.in/yaml.v3 v3.0.1 // indirect
80-
k8s.io/api v0.0.0-20241108114315-3f43b5a94246 // indirect
82+
k8s.io/api v0.0.0-20241127162655-f8e5e36c84f1 // indirect
8183
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
8284
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
8385
)

go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
200200
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
201201
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
202202
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
203-
k8s.io/api v0.0.0-20241108114315-3f43b5a94246 h1:lTiwDILcPkCelpoYPkQ0jt8tmY0/s6Q9sM2mq2qie8g=
204-
k8s.io/api v0.0.0-20241108114315-3f43b5a94246/go.mod h1:jw6pQTESH9mdZL2vOK3twojvpPxipl5TpLZpPyl5ZYU=
205-
k8s.io/apimachinery v0.0.0-20241108022104-96b97de8d6ba h1:ghB5Iygt6Ge8UyIwW7C1kJx4kP7AUTCL9Qg6GCsUUOY=
206-
k8s.io/apimachinery v0.0.0-20241108022104-96b97de8d6ba/go.mod h1:HqhdaJUgQqky29T1V0o2yFkt/pZqLFIDyn9Zi/8rxoY=
207-
k8s.io/client-go v0.0.0-20241108115827-ec126553e25c h1:oFkwLbL3wiQ1J3kiXB3e8RekXFhWB4G3jtWxX4qz/fk=
208-
k8s.io/client-go v0.0.0-20241108115827-ec126553e25c/go.mod h1:qdg0yiHKZF4DimKIPqdu9N9y1VLkHDn8Jtbsblkf6O0=
203+
k8s.io/api v0.0.0-20241127162655-f8e5e36c84f1 h1:MTqd8524+MzN0Kxt42qAvh/aUYC18yz1BJUmfWADaDg=
204+
k8s.io/api v0.0.0-20241127162655-f8e5e36c84f1/go.mod h1:qs155+gTdM43TXy/cV8a8yOjDeNR8kGJc82AraJrh/c=
205+
k8s.io/apimachinery v0.0.0-20240920213627-16af2ff33fbf h1:ZRwu8YHh3bFbQU4NRvHB6fiovWLBouxY86wIcLd7sBA=
206+
k8s.io/apimachinery v0.0.0-20240920213627-16af2ff33fbf/go.mod h1:HqhdaJUgQqky29T1V0o2yFkt/pZqLFIDyn9Zi/8rxoY=
207+
k8s.io/client-go v0.0.0-20241127164845-55d23e26d5ef h1:vruVg7dEUvIzst/cCIMyxHj6Xh2vTpaVH9wrONW6SM4=
208+
k8s.io/client-go v0.0.0-20241127164845-55d23e26d5ef/go.mod h1:DtqcGpVY2YUJlRhkIBvTwD/kYAIV58FrFHjjLlNR4VM=
209209
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
210210
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
211211
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=

0 commit comments

Comments
 (0)