Skip to content

WIP: Rebase 1.32 Pre.1 Diff #161

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

Open
wants to merge 58 commits into
base: kcp-1.32-baseline
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
dead945
UPSTREAM: 113151: Revert: Revert: Clean up CRD conversion code structure
sttts Sep 11, 2023
d157aea
README
sttts Sep 1, 2023
a0f3d68
UPSTREAM: <carry>: controlplane/apiserver: add miniaggregator
sttts Sep 27, 2023
7234f81
UPSTREAM: <carry>: clusterize controllers
sttts Sep 1, 2023
28ac217
UPSTREAM: <carry>: re-add GC worker locks
gman0 Feb 3, 2025
570c6ed
UPSTREAM: <carry>: Add kcp patchers
sttts Oct 8, 2023
c93e304
UPSTREAM: <carry>: re-generated pkg/controller/resourcequota/resource…
gman0 Jan 26, 2025
2016601
UPSTREAM: <carry>: re-generated pkg/controller/garbagecollector/garba…
gman0 Feb 11, 2025
f87a202
UPSTREAM: <carry>: storage: etcd cluster key computation
sttts Sep 27, 2023
aad4a42
UPSTREAM: <carry>: clusterize serviceaccounts
sttts Sep 1, 2023
86eb6a8
UPSTREAM: <carry>: registry/core/serviceaccount: do not crash without…
sttts Sep 27, 2023
0e41242
UPSTREAM: <carry>: kube-aggregator
sttts Sep 1, 2023
006648f
UPSTREAM: <carry>: INTERESTING: clusterize admission
sttts Sep 1, 2023
ba55bcf
UPSTREAM: <carry>: Clusterize ValidatingAdmissionPolicy admission plu…
embik Jul 24, 2024
aaa0e92
UPSTREAM: <carry>: clusterize storage hash
sttts Sep 27, 2023
f2ad525
UPSTREAM: <carry>: endpoints: add Cluster struct for ctx
sttts Sep 27, 2023
4ed5b98
UPSTREAM: <carry>: endpoints/patch: wire openapi for CRD strategic me…
sttts Sep 27, 2023
4739ef6
UPSTREAM: <carry>: storage/etcd3: clusterize
sttts Sep 27, 2023
ab335e9
UPSTREAM: <carry>: apiserver: partial wildcard metadata request accro…
sttts Sep 27, 2023
d868a62
UPSTREAM: <carry>: endpoints: set kcp.io/original-api-version on wild…
sttts Sep 27, 2023
7f28105
UPSTREAM: <carry>: watch(er/cache): clusterize
sttts Sep 27, 2023
e271562
UPSTREAM: <carry>: apiserver: split chain into pre and post authz
sttts Sep 27, 2023
4a2b5f9
UPSTREAM: <carry>: apiserver: clusterize listed paths
sttts Sep 27, 2023
b9669e3
UPSTREAM: <carry>: apiserver: clusterize OpenAPI v2
sttts Sep 27, 2023
b5939d8
UPSTREAM: <carry>: clusterize BuiltInAuthenticationOptions
sttts Sep 27, 2023
bf1a2a1
UPSTREAM: <carry>: storage: add UseResourceAsPrefixDefault for legacy…
sttts Sep 27, 2023
879e485
UPSTREAM: <carry>: apiextensions-apiserver
sttts Sep 27, 2023
0203da1
UPSTREAM: <carry>: cache-server: wire shard name into storage
sttts Sep 27, 2023
db825b7
UPSTREAM: <carry>: add client and informer hacks
sttts Sep 27, 2023
1159daa
UPSTREAM: <carry>: controlplane: wire informers and clients
sttts Sep 11, 2023
4c9c3df
UPSTREAM: <carry>: generic cleanup
mjudeikis Sep 3, 2024
ab917a9
UPSTREAM: <carry>: controlplane/apiserver: disable protobuf for loopback
sttts Sep 25, 2023
e142cc7
UPSTREAM: <carry>: pass system:admin clients and informers in generic…
embik Jun 13, 2024
a71d65e
UPSTREAM: <carry>: remove REST mapper from admission plugins
embik Jun 20, 2024
68b54d6
UPSTREAM: <carry>: provide supportedMediaTypes for custom resoure han…
embik Jun 21, 2024
50c9ea5
UPSTREAM: <carry>: prevent NPE if no authorization is set
embik Jun 21, 2024
2034abe
UPSTREAM: <carry>: wrap CRD group into packagePrefix for OpenAPIV3 bu…
embik Jul 12, 2024
8a207b8
UPSTREAM: <CARRY>: clusterize validatingadmissionpolicystatus controller
embik Jul 23, 2024
7a27a28
UPSTREAM: <carry>: apiserver cleaning
mjudeikis Sep 3, 2024
5c809ee
UPSTREAM: <squash>: remove syncer custom code from apiextensions-apis…
sttts Sep 18, 2024
fe0acf7
UPSTREAM: <carry>: include cluster name in authz SubjectAccessReview …
xrstf Nov 13, 2024
d57c237
UPSTREAM: <squash>: prevent conflict with pre-existing auth annotation
xrstf Nov 14, 2024
455d854
CARRY: split auth/authz chains even more
mjudeikis Dec 10, 2024
1a37a19
UPSTREAM: <carry>: authz: add scoping to default rule resolver
sttts Aug 23, 2024
b6ac17f
UPSTREAM: <carry>: authz: add warrants to default rule resolver
sttts Aug 23, 2024
dc03406
UPSTREAM: <squash>: authz: add warrants to default rule resolver: glo…
sttts Jan 24, 2025
b06d2a8
UPSTREAM: <squash>: authz: add warrants to default rule resolver: hel…
sttts Jan 24, 2025
1b0b146
UPSTREAM: <squash>: authz: add warrants to default rule resolver: glo…
sttts Jan 25, 2025
0ced631
UPSTREAM: <squash>: authz: add warrants to default rule resolver: for…
sttts Jan 25, 2025
bffed1d
UPSTREAM: <squash>: authz: add warrants to default rule resolver: sim…
sttts Jan 25, 2025
8fd95d6
UPSTREAM: <carry>: endpoints: wire in ctx to watchListTransformer
gman0 Jan 22, 2025
8befcaf
UPSTREAM: <carry>: Clusterize MutatingAdmissionPolicy admission plugi…
gman0 Jan 23, 2025
8fc9059
UPSTREAM: <carry>: don't use --prefers-protobuf with client-gen
gman0 Feb 10, 2025
03a3c1b
UPSTREAM: <drop>: Pinned kcp dependencies
gman0 Feb 12, 2025
204c308
UPSTREAM: <drop>: Updated vendor modules
gman0 Feb 12, 2025
c6ebc59
UPSTREAM: <drop>: Re-generated client code
gman0 Feb 12, 2025
89e1549
UPSTREAM 130180: Make disable lookups of SA related artifacts working
mjudeikis Feb 14, 2025
3b193fc
Merge pull request #163 from mjudeikis/mjudeikis/cherry.sa.lookup
mjudeikis Feb 21, 2025
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
328 changes: 328 additions & 0 deletions staging/src/k8s.io/apiserver/pkg/clientsethack/adapter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
/*
Copyright 2022 The KCP Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +kcp-code-generator:skip

package clientsethack

import (
kcpkubernetesclientset "github.com/kcp-dev/client-go/kubernetes"

"k8s.io/client-go/discovery"
"k8s.io/client-go/kubernetes"
admissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1"
admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1"
admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1"
internalv1alpha1 "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1"
appsv1 "k8s.io/client-go/kubernetes/typed/apps/v1"
appsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
appsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2"
authenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1"
"k8s.io/client-go/kubernetes/typed/authentication/v1alpha1"
authenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1"
authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1"
authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1"
autoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1"
autoscalingv2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2"
autoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1"
autoscalingv2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2"
batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1"
batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1"
certificatesv1 "k8s.io/client-go/kubernetes/typed/certificates/v1"
certificatesv1alpha1 "k8s.io/client-go/kubernetes/typed/certificates/v1alpha1"
certificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
coordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1"
coordinationv1alpha2 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2"
coordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
discoveryv1 "k8s.io/client-go/kubernetes/typed/discovery/v1"
discoveryv1beta1 "k8s.io/client-go/kubernetes/typed/discovery/v1beta1"
eventsv1 "k8s.io/client-go/kubernetes/typed/events/v1"
eventsv1beta1 "k8s.io/client-go/kubernetes/typed/events/v1beta1"
extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
flowcontrolv1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
flowcontrolv1beta1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1"
flowcontrolv1beta2 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
flowcontrolv1beta3 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
networkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1"
networkingv1alpha1 "k8s.io/client-go/kubernetes/typed/networking/v1alpha1"
networkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1"
nodev1 "k8s.io/client-go/kubernetes/typed/node/v1"
nodev1alpha1 "k8s.io/client-go/kubernetes/typed/node/v1alpha1"
nodev1beta1 "k8s.io/client-go/kubernetes/typed/node/v1beta1"
policyv1 "k8s.io/client-go/kubernetes/typed/policy/v1"
policyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1"
rbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
rbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1"
rbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1"
resourcev1alpha3 "k8s.io/client-go/kubernetes/typed/resource/v1alpha3"
resourcev1beta1 "k8s.io/client-go/kubernetes/typed/resource/v1beta1"
schedulingv1 "k8s.io/client-go/kubernetes/typed/scheduling/v1"
schedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1"
schedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1"
storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
storagev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1"
storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1"
storagemigrationv1alpha1 "k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1"
)

// Interface allows us to hold onto a strongly-typed cluster-aware clients here, while
// passing in a cluster-unaware (but non-functional) clients to k8s libraries. We export this type so that we
// can get the cluster-aware clients back using casting in admission plugin initialization.
type Interface interface {
kubernetes.Interface
ClusterAware() kcpkubernetesclientset.ClusterInterface
}

var _ Interface = (*hack)(nil)

// Wrap adapts a cluster-aware informer factory to a cluster-unaware wrapper that can divulge it after casting.
func Wrap(clusterAware kcpkubernetesclientset.ClusterInterface) Interface {
return &hack{clusterAware: clusterAware}
}

// Unwrap extracts a cluster-aware informer factory from the cluster-unaware wrapper, or panics if we get the wrong input.
func Unwrap(clusterUnaware kubernetes.Interface) kcpkubernetesclientset.ClusterInterface {
return clusterUnaware.(Interface).ClusterAware()
}

type hack struct {
clusterAware kcpkubernetesclientset.ClusterInterface
}

func (h *hack) AdmissionregistrationV1alpha1() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface {
Copy link
Author

Choose a reason for hiding this comment

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

im surprised this didn't changed

Copy link

Choose a reason for hiding this comment

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

The Interface interface seems to still have that method in upstream's v1.32: https://github.com/kubernetes/kubernetes/blob/v1.32.0/staging/src/k8s.io/client-go/kubernetes/clientset.go#L27

Unless you meant something else, @mjudeikis ?

Copy link
Author

Choose a reason for hiding this comment

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

I mean no new types were added/removed in 1.32.

Copy link

@gman0 gman0 Feb 17, 2025

Choose a reason for hiding this comment

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

git diff kcp-1.31.0..kcp-1.32-pre.7-review -- staging/src/k8s.io/apiserver/pkg/clientsethack/adapter.go says that:

  • coordinationV1alpha1 was replaced by coordinationV1alpha2, and
  • resourceV1beta1 was added

Should I document this somewhere?

panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AuthenticationV1alpha1() v1alpha1.AuthenticationV1alpha1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) ResourceV1alpha3() resourcev1alpha3.ResourceV1alpha3Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) ResourceV1beta1() resourcev1beta1.ResourceV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AdmissionregistrationV1() admissionregistrationv1.AdmissionregistrationV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AdmissionregistrationV1beta1() admissionregistrationv1beta1.AdmissionregistrationV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) InternalV1alpha1() internalv1alpha1.InternalV1alpha1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AppsV1() appsv1.AppsV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AppsV1beta1() appsv1beta1.AppsV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AppsV1beta2() appsv1beta2.AppsV1beta2Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AuthenticationV1() authenticationv1.AuthenticationV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AuthenticationV1beta1() authenticationv1beta1.AuthenticationV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AuthorizationV1() authorizationv1.AuthorizationV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AuthorizationV1beta1() authorizationv1beta1.AuthorizationV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AutoscalingV1() autoscalingv1.AutoscalingV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AutoscalingV2() autoscalingv2.AutoscalingV2Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) AutoscalingV2beta2() autoscalingv2beta2.AutoscalingV2beta2Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) BatchV1() batchv1.BatchV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) BatchV1beta1() batchv1beta1.BatchV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) CertificatesV1() certificatesv1.CertificatesV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) CertificatesV1alpha1() certificatesv1alpha1.CertificatesV1alpha1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) CertificatesV1beta1() certificatesv1beta1.CertificatesV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) CoordinationV1alpha2() coordinationv1alpha2.CoordinationV1alpha2Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) CoordinationV1beta1() coordinationv1beta1.CoordinationV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) CoordinationV1() coordinationv1.CoordinationV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) CoreV1() corev1.CoreV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) DiscoveryV1() discoveryv1.DiscoveryV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) DiscoveryV1beta1() discoveryv1beta1.DiscoveryV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) EventsV1() eventsv1.EventsV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) EventsV1beta1() eventsv1beta1.EventsV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) ExtensionsV1beta1() extensionsv1beta1.ExtensionsV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) FlowcontrolV1beta1() flowcontrolv1beta1.FlowcontrolV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) FlowcontrolV1beta2() flowcontrolv1beta2.FlowcontrolV1beta2Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) FlowcontrolV1beta3() flowcontrolv1beta3.FlowcontrolV1beta3Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) FlowcontrolV1() flowcontrolv1.FlowcontrolV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) NetworkingV1() networkingv1.NetworkingV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) NetworkingV1beta1() networkingv1beta1.NetworkingV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) NodeV1() nodev1.NodeV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) NodeV1alpha1() nodev1alpha1.NodeV1alpha1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) NodeV1beta1() nodev1beta1.NodeV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) PolicyV1() policyv1.PolicyV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) PolicyV1beta1() policyv1beta1.PolicyV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) RbacV1() rbacv1.RbacV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) RbacV1beta1() rbacv1beta1.RbacV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) RbacV1alpha1() rbacv1alpha1.RbacV1alpha1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) SchedulingV1() schedulingv1.SchedulingV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) StorageV1beta1() storagev1beta1.StorageV1beta1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) StorageV1() storagev1.StorageV1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) StoragemigrationV1alpha1() storagemigrationv1alpha1.StoragemigrationV1alpha1Interface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) Discovery() discovery.DiscoveryInterface {
panic("programmer error: using a cluster-unaware clientset, need to cast this to use the cluster-aware one!")
}

func (h *hack) ClusterAware() kcpkubernetesclientset.ClusterInterface {
return h.clusterAware
}
59 changes: 59 additions & 0 deletions staging/src/k8s.io/apiserver/pkg/dynamichack/adapter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2023 The KCP Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +kcp-code-generator:skip

package dynamichack

import (
kcpdynamic "github.com/kcp-dev/client-go/dynamic"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
)

// Interface allows us to hold onto a strongly-typed cluster-aware clients here, while
// passing in a cluster-unaware (but non-functional) clients to k8s libraries. We export this type so that we
// can get the cluster-aware clients back using casting in admission plugin initialization.
type Interface interface {
dynamic.Interface
ClusterAware() kcpdynamic.ClusterInterface
}

var _ Interface = (*hack)(nil)

// Wrap adapts a cluster-aware dynamic client to a cluster-unaware wrapper that can divulge it after casting.
func Wrap(clusterAware kcpdynamic.ClusterInterface) Interface {
return &hack{clusterAware: clusterAware}
}

// Unwrap extracts a cluster-aware dynamic client from the cluster-unaware wrapper, or panics if we get the wrong input.
func Unwrap(clusterUnaware dynamic.Interface) kcpdynamic.ClusterInterface {
return clusterUnaware.(Interface).ClusterAware()
}

type hack struct {
clusterAware kcpdynamic.ClusterInterface
}

func (h hack) Resource(resource schema.GroupVersionResource) dynamic.NamespaceableResourceInterface {
panic("programmer error: using a cluster-unaware dynamic client, need to cast this to use the cluster-aware one!")

}

func (h hack) ClusterAware() kcpdynamic.ClusterInterface {
panic("programmer error: using a cluster-unaware dynamic, need to cast this to use the cluster-aware one!")

}
Loading