Skip to content

[WIP][DIFF] ✨ Update to code-generator/v3 #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ GOBIN_DIR=$(abspath ./bin )
PATH := $(GOBIN_DIR):$(TOOLS_GOBIN_DIR):$(PATH)
TMPDIR := $(shell mktemp -d)

CODE_GENERATOR_VER := 572c29375f0e63c13b31c70931914c420a0a9d59
CODE_GENERATOR_BIN := code-generator
CODE_GENERATOR := $(TOOLS_DIR)/$(CODE_GENERATOR_BIN)-$(CODE_GENERATOR_VER)
export CODE_GENERATOR # so hack scripts can use it

$(CODE_GENERATOR):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/kcp-dev/code-generator/v2 $(CODE_GENERATOR_BIN) $(CODE_GENERATOR_VER)

OPENSHIFT_GOIMPORTS_VER := c70783e636f2213cac683f6865d88c5edace3157
OPENSHIFT_GOIMPORTS_BIN := openshift-goimports
OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)-$(OPENSHIFT_GOIMPORTS_VER)
Expand All @@ -56,7 +48,7 @@ lint: $(GOLANGCI_LINT)
tools: $(CODE_GENERATOR) $(OPENSHIFT_GOIMPORTS) $(GOLANGCI_LINT)
.PHONY: tools

codegen: $(CODE_GENERATOR)
codegen:
go mod download
./hack/update-codegen.sh
$(MAKE) imports
Expand All @@ -79,4 +71,5 @@ verify: verify-codegen

.PHONY: clean-generated
clean-generated:
grep --exclude Makefile -l 'Code generated by kcp code-generator. DO NOT EDIT.' -r . | xargs rm
grep --exclude Makefile -l -e 'Code generated by [a-z-]*. DO NOT EDIT.' -r . | xargs rm -f
find . -type d -empty -delete
1 change: 1 addition & 0 deletions dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
_ "github.com/kcp-dev/apimachinery/v2/pkg/cache"
_ "github.com/kcp-dev/code-generator/v3/cmd/cluster-client-gen/generators"
_ "github.com/kcp-dev/logicalcluster/v3"

_ "k8s.io/api/core/v1"
Expand Down
6 changes: 5 additions & 1 deletion dynamic/dynamicinformer/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ func (d *dynamicClusterInformer) Lister() kcpcache.GenericClusterLister {
}

func (d *dynamicClusterInformer) Cluster(clusterName logicalcluster.Name) upstreaminformers.GenericInformer {
return d.ClusterWithContext(context.Background(), clusterName)
}

func (d *dynamicClusterInformer) ClusterWithContext(ctx context.Context, clusterName logicalcluster.Name) upstreaminformers.GenericInformer {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClusterWithContext is already part of code-generator/v3 so the interfaces must be satisfied.

return &dynamicInformer{
informer: d.Informer().Cluster(clusterName),
informer: d.Informer().ClusterWithContext(ctx, clusterName),
lister: d.Lister().ByCluster(clusterName),
}
}
Expand Down
14 changes: 9 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ module github.com/kcp-dev/client-go
go 1.23.0

require (
github.com/evanphx/json-patch v5.6.0+incompatible
github.com/google/gnostic-models v0.6.9
github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250425065633-635c2a0fbaba
github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250512171935-ebb573a40077
github.com/kcp-dev/code-generator/v3 v3.0.0-20250707080944-4094fb87e20f
github.com/kcp-dev/logicalcluster/v3 v3.0.5
gopkg.in/evanphx/json-patch.v4 v4.12.0
k8s.io/api v0.32.3
k8s.io/apiextensions-apiserver v0.32.3
k8s.io/apimachinery v0.32.3
k8s.io/client-go v0.32.3
k8s.io/klog/v2 v2.130.1
sigs.k8s.io/structured-merge-diff/v4 v4.4.2
sigs.k8s.io/yaml v1.4.0
)

require (
Expand Down Expand Up @@ -69,26 +72,27 @@ require (
go.opentelemetry.io/otel/trace v1.33.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
golang.org/x/mod v0.24.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/oauth2 v0.29.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/time v0.11.0 // indirect
golang.org/x/tools v0.32.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/grpc v1.69.2 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.32.3 // indirect
k8s.io/code-generator v0.32.3 // indirect
k8s.io/component-base v0.32.3 // indirect
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.1 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
18 changes: 12 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU=
github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=
github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
Expand Down Expand Up @@ -72,8 +70,10 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250425065633-635c2a0fbaba h1:Ar/8wsCQWrZgRiBF2B5xCqCXEA/oiiuDI0yEsUtrxRs=
github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250425065633-635c2a0fbaba/go.mod h1:pYqnaSG3NlF/pVwfnYCAdGvrA7FpALFmd5S9X4XXf1Q=
github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250512171935-ebb573a40077 h1:lDi9nZ75ypmRJwDFXUN70Cdu8+HxAjPU1kcnn+l4MvI=
github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250512171935-ebb573a40077/go.mod h1:jnMZxVnCuKlkIXc4J1Qtmy1Lyo171CDF/RQhNAo0tvA=
github.com/kcp-dev/code-generator/v3 v3.0.0-20250707080944-4094fb87e20f h1:Qfpk7+Y5gwWV8FNY6zu+l5hbKWlFZ6oJqgL67RoCEJg=
github.com/kcp-dev/code-generator/v3 v3.0.0-20250707080944-4094fb87e20f/go.mod h1:1EZhJqiFvXq1N0xKJnJOf8kQ++wuwLkqFGIRVSoVACk=
github.com/kcp-dev/logicalcluster/v3 v3.0.5 h1:JbYakokb+5Uinz09oTXomSUJVQsqfxEvU4RyHUYxHOU=
github.com/kcp-dev/logicalcluster/v3 v3.0.5/go.mod h1:EWBUBxdr49fUB1cLMO4nOdBWmYifLbP1LfoL20KkXYY=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down Expand Up @@ -175,6 +175,8 @@ golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand Down Expand Up @@ -205,8 +207,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU=
golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down Expand Up @@ -239,8 +241,12 @@ k8s.io/apiserver v0.32.3 h1:kOw2KBuHOA+wetX1MkmrxgBr648ksz653j26ESuWNY8=
k8s.io/apiserver v0.32.3/go.mod h1:q1x9B8E/WzShF49wh3ADOh6muSfpmFL0I2t+TG0Zdgc=
k8s.io/client-go v0.32.3 h1:RKPVltzopkSgHS7aS98QdscAgtgah/+zmpAogooIqVU=
k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY=
k8s.io/code-generator v0.32.3 h1:31p2TVzC9+hVdSkAFruAk3JY+iSfzrJ83Qij1yZutyw=
k8s.io/code-generator v0.32.3/go.mod h1:+mbiYID5NLsBuqxjQTygKM/DAdKpAjvBzrJd64NU1G8=
k8s.io/component-base v0.32.3 h1:98WJvvMs3QZ2LYHBzvltFSeJjEx7t5+8s71P7M74u8k=
k8s.io/component-base v0.32.3/go.mod h1:LWi9cR+yPAv7cu2X9rZanTiFKB2kHA+JjmhkKjCZRpI=
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 h1:si3PfKm8dDYxgfbeA6orqrtLkvvIeH8UqffFJDl0bz4=
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
Expand Down
49 changes: 33 additions & 16 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,38 @@ set -o nounset
set -o pipefail
set -o xtrace

if [[ -z "${MAKELEVEL:-}" ]]; then
echo 'You must invoke this script via make'
exit 1
fi
CODEGEN_PKG="$(go list -f '{{.Dir}}' -m k8s.io/code-generator)"
source "$CODEGEN_PKG/kube_codegen.sh"

${CODE_GENERATOR} \
"client:externalOnly=true,standalone=true,outputPackagePath=github.com/kcp-dev/client-go,name=kubernetes,apiPackagePath=k8s.io/api,singleClusterClientPackagePath=k8s.io/client-go/kubernetes,singleClusterApplyConfigurationsPackagePath=k8s.io/client-go/applyconfigurations,headerFile=./hack/boilerplate/boilerplate.go.txt" \
"lister:apiPackagePath=k8s.io/api,singleClusterListerPackagePath=k8s.io/client-go/listers,headerFile=./hack/boilerplate/boilerplate.go.txt" \
"informer:clientsetName=kubernetes,externalOnly=true,standalone=true,outputPackagePath=github.com/kcp-dev/client-go,apiPackagePath=k8s.io/api,singleClusterClientPackagePath=k8s.io/client-go/kubernetes, singleClusterListerPackagePath=k8s.io/client-go/listers,singleClusterInformerPackagePath=k8s.io/client-go/informers,headerFile=./hack/boilerplate/boilerplate.go.txt" \
"paths=$( go list -m -json k8s.io/api | jq --raw-output .Dir )/..." \
"output:dir=./"
CLUSTER_CODEGEN_PKG="$(go list -f '{{.Dir}}' -m github.com/kcp-dev/code-generator/v3)"
source "$CLUSTER_CODEGEN_PKG/cluster_codegen.sh"

${CODE_GENERATOR} \
"client:externalOnly=true,standalone=true,outputPackagePath=github.com/kcp-dev/client-go/apiextensions,name=client,apiPackagePath=k8s.io/apiextensions-apiserver/pkg/apis,singleClusterClientPackagePath=k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset,singleClusterApplyConfigurationsPackagePath=k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration,headerFile=./hack/boilerplate/boilerplate.go.txt" \
"lister:apiPackagePath=k8s.io/apiextensions-apiserver/pkg/apis,singleClusterListerPackagePath=k8s.io/apiextensions-apiserver/pkg/client/listers,headerFile=./hack/boilerplate/boilerplate.go.txt" \
"informer:clientsetName=client,externalOnly=true,standalone=true,outputPackagePath=github.com/kcp-dev/client-go/apiextensions,apiPackagePath=k8s.io/apiextensions-apiserver/pkg/apis,singleClusterClientPackagePath=k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset, singleClusterListerPackagePath=k8s.io/apiextensions-apiserver/pkg/client/listers,singleClusterInformerPackagePath=k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions,headerFile=./hack/boilerplate/boilerplate.go.txt" \
"paths=$( go list -m -json k8s.io/apiextensions-apiserver | jq --raw-output .Dir )/pkg/apis/..." \
"output:dir=./apiextensions"
make clean-generated

cluster::codegen::gen_client \
--boilerplate ./hack/boilerplate/boilerplate.go.txt \
--with-watch \
--output-dir . \
--output-pkg github.com/kcp-dev/client-go \
--versioned-clientset-dir kubernetes \
--versioned-clientset-pkg github.com/kcp-dev/client-go/kubernetes \
--single-cluster-versioned-clientset-pkg k8s.io/client-go/kubernetes \
--single-cluster-applyconfigurations-pkg k8s.io/client-go/applyconfigurations \
--single-cluster-informers-pkg k8s.io/client-go/informers \
--single-cluster-listers-pkg k8s.io/client-go/listers \
--exclude-group-versions "imagepolicy/v1alpha1" \
--plural-exceptions "Endpoints:Endpoints" \
"$(go list -m -json k8s.io/api | jq --raw-output .Dir)"

cluster::codegen::gen_client \
--boilerplate ./hack/boilerplate/boilerplate.go.txt \
--output-dir apiextensions \
--output-pkg github.com/kcp-dev/client-go/apiextensions \
--with-watch \
--versioned-clientset-pkg github.com/kcp-dev/client-go/apiextensions/client \
--versioned-clientset-dir apiextensions/client \
--single-cluster-versioned-clientset-pkg k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset \
--single-cluster-applyconfigurations-pkg k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration \
--single-cluster-informers-pkg k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions \
--single-cluster-listers-pkg k8s.io/apiextensions-apiserver/pkg/client/listers \
"$(go list -m -json k8s.io/apiextensions-apiserver | jq --raw-output .Dir)/pkg/apis"
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ import (

certificates "k8s.io/api/certificates/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"

core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing"
)

func (c *certificateSigningRequestsClient) UpdateApproval(ctx context.Context, certificateSigningRequest *certificates.CertificateSigningRequest, opts metav1.UpdateOptions) (result *certificates.CertificateSigningRequest, err error) {
var certificateSigningRequestsResource = schema.GroupVersionResource{Group: "certificates.k8s.io", Version: "v1beta1", Resource: "certificatesigningrequests"}

func (c *certificateSigningRequestScopedClient) UpdateApproval(ctx context.Context, certificateSigningRequest *certificates.CertificateSigningRequest, opts metav1.UpdateOptions) (result *certificates.CertificateSigningRequest, err error) {
obj, err := c.Fake.Invokes(core.NewRootUpdateSubresourceAction(certificateSigningRequestsResource, c.ClusterPath, "approval", certificateSigningRequest), &certificates.CertificateSigningRequest{})
if obj == nil {
return nil, err
Expand Down
32 changes: 18 additions & 14 deletions kubernetes/typed/core/v1/fake/fake_event_expansion.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ limitations under the License.
package fake

import (
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"

core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing"
)

func (c *eventsClient) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
var eventsResource = schema.GroupVersionResource{Group: "events.k8s.io", Version: "v1beta1", Resource: "events"}
var eventsKind = schema.GroupVersionKind{Group: "events.k8s.io", Version: "v1beta1", Kind: "Event"}

func (c *eventScopedClient) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
action := core.NewRootCreateAction(eventsResource, c.ClusterPath, event)
if c.Namespace != "" {
action = core.NewCreateAction(eventsResource, c.ClusterPath, c.Namespace, event)
if c.Namespace() != "" {
action = core.NewCreateAction(eventsResource, c.ClusterPath, c.Namespace(), event)
}
obj, err := c.Fake.Invokes(action, event)
if obj == nil {
Expand All @@ -41,10 +45,10 @@ func (c *eventsClient) CreateWithEventNamespace(event *v1.Event) (*v1.Event, err
}

// Update replaces an existing event. Returns the copy of the event the server returns, or an error.
func (c *eventsClient) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
func (c *eventScopedClient) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
action := core.NewRootUpdateAction(eventsResource, c.ClusterPath, event)
if c.Namespace != "" {
action = core.NewUpdateAction(eventsResource, c.ClusterPath, c.Namespace, event)
if c.Namespace() != "" {
action = core.NewUpdateAction(eventsResource, c.ClusterPath, c.Namespace(), event)
}
obj, err := c.Fake.Invokes(action, event)
if obj == nil {
Expand All @@ -56,12 +60,12 @@ func (c *eventsClient) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, err

// PatchWithEventNamespace patches an existing event. Returns the copy of the event the server returns, or an error.
// TODO: Should take a PatchType as an argument probably.
func (c *eventsClient) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.Event, error) {
func (c *eventScopedClient) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.Event, error) {
// TODO: Should be configurable to support additional patch strategies.
pt := types.StrategicMergePatchType
action := core.NewRootPatchAction(eventsResource, c.ClusterPath, event.Name, pt, data)
if c.Namespace != "" {
action = core.NewPatchAction(eventsResource, c.ClusterPath, c.Namespace, event.Name, pt, data)
if c.Namespace() != "" {
action = core.NewPatchAction(eventsResource, c.ClusterPath, c.Namespace(), event.Name, pt, data)
}
obj, err := c.Fake.Invokes(action, event)
if obj == nil {
Expand All @@ -72,10 +76,10 @@ func (c *eventsClient) PatchWithEventNamespace(event *v1.Event, data []byte) (*v
}

// Search returns a list of events matching the specified object.
func (c *eventsClient) Search(scheme *runtime.Scheme, objOrRef runtime.Object) (*v1.EventList, error) {
func (c *eventScopedClient) Search(scheme *runtime.Scheme, objOrRef runtime.Object) (*v1.EventList, error) {
action := core.NewRootListAction(eventsResource, eventsKind, c.ClusterPath, metav1.ListOptions{})
if c.Namespace != "" {
action = core.NewListAction(eventsResource, eventsKind, c.ClusterPath, c.Namespace, metav1.ListOptions{})
if c.Namespace() != "" {
action = core.NewListAction(eventsResource, eventsKind, c.ClusterPath, c.Namespace(), metav1.ListOptions{})
}
obj, err := c.Fake.Invokes(action, &v1.EventList{})
if obj == nil {
Expand All @@ -85,7 +89,7 @@ func (c *eventsClient) Search(scheme *runtime.Scheme, objOrRef runtime.Object) (
return obj.(*v1.EventList), err
}

func (c *eventsClient) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector {
func (c *eventScopedClient) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector {
action := core.GenericActionImpl{}
action.Verb = "get-field-selector"
action.Resource = eventsResource
Expand Down
7 changes: 5 additions & 2 deletions kubernetes/typed/core/v1/fake/fake_namespace_expansion.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ package fake
import (
"context"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"

core "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing"
)

func (c *namespacesClient) Finalize(ctx context.Context, namespace *v1.Namespace, opts metav1.UpdateOptions) (*v1.Namespace, error) {
var namespacesResource = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"}

func (c *namespaceScopedClient) Finalize(ctx context.Context, namespace *v1.Namespace, opts metav1.UpdateOptions) (*v1.Namespace, error) {
action := core.CreateActionImpl{}
action.Verb = "create"
action.Resource = namespacesResource
Expand Down
Loading