@@ -6,10 +6,12 @@ package local
6
6
import (
7
7
"context"
8
8
9
+ openapi_v2 "github.com/google/gnostic/openapiv2"
9
10
authenticationv1api "k8s.io/api/authentication/v1"
10
11
corev1api "k8s.io/api/core/v1"
11
12
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
13
types "k8s.io/apimachinery/pkg/types"
14
+ version "k8s.io/apimachinery/pkg/version"
13
15
watch "k8s.io/apimachinery/pkg/watch"
14
16
aplcorev1 "k8s.io/client-go/applyconfigurations/core/v1"
15
17
discovery "k8s.io/client-go/discovery"
@@ -64,6 +66,7 @@ import (
64
66
storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
65
67
storagev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1"
66
68
storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1"
69
+ "k8s.io/client-go/openapi"
67
70
rest "k8s.io/client-go/rest"
68
71
)
69
72
@@ -91,7 +94,7 @@ type MinCoreClient struct {
91
94
92
95
var _ kubernetes.Interface = & MinCoreClient {}
93
96
94
- func (* MinCoreClient ) Discovery () discovery.DiscoveryInterface { panic ( "Not implemented" ); return nil }
97
+ func (* MinCoreClient ) Discovery () discovery.DiscoveryInterface { return & MinDiscoveryClient {} }
95
98
func (* MinCoreClient ) AdmissionregistrationV1 () admissionregistrationv1.AdmissionregistrationV1Interface {
96
99
panic ("Not implemented" )
97
100
return nil
@@ -172,6 +175,11 @@ func (*MinCoreClient) CoordinationV1() coordinationv1.CoordinationV1Interface {
172
175
return nil
173
176
}
174
177
func (c * MinCoreClient ) CoreV1 () corev1.CoreV1Interface {
178
+ if c .client == nil {
179
+ // To be used only while releasing packages where we do not expect nil client to be used
180
+ // MinServiceAccount will mock necessary bits
181
+ return & MinCoreV1Client {nil , c .localSecrets , c .localConfigMaps }
182
+ }
175
183
return & MinCoreV1Client {c .client .CoreV1 (), c .localSecrets , c .localConfigMaps }
176
184
}
177
185
func (* MinCoreClient ) DiscoveryV1 () discoveryv1.DiscoveryV1Interface {
@@ -324,6 +332,10 @@ func (*MinCoreV1Client) Services(namespace string) corev1.ServiceInterface {
324
332
return nil
325
333
}
326
334
func (c * MinCoreV1Client ) ServiceAccounts (namespace string ) corev1.ServiceAccountInterface {
335
+ if c .client == nil {
336
+ // To handle package release scenarios with DownwardsAPI
337
+ return & ServiceAccounts {namespace , nil }
338
+ }
327
339
return & ServiceAccounts {namespace , c .client .ServiceAccounts (namespace )}
328
340
}
329
341
@@ -452,6 +464,10 @@ func (*ServiceAccounts) DeleteCollection(ctx context.Context, opts metav1.Delete
452
464
return nil
453
465
}
454
466
func (sa * ServiceAccounts ) Get (ctx context.Context , name string , opts metav1.GetOptions ) (* corev1api.ServiceAccount , error ) {
467
+ if sa .client == nil {
468
+ // To handle package release scenarios with DownwardsAPI
469
+ return & corev1api.ServiceAccount {}, nil
470
+ }
455
471
return sa .client .Get (ctx , name , opts )
456
472
}
457
473
func (* ServiceAccounts ) List (ctx context.Context , opts metav1.ListOptions ) (* corev1api.ServiceAccountList , error ) {
@@ -471,5 +487,39 @@ func (*ServiceAccounts) Apply(ctx context.Context, serviceAccount *aplcorev1.Ser
471
487
return nil , nil
472
488
}
473
489
func (sa * ServiceAccounts ) CreateToken (ctx context.Context , serviceAccountName string , tokenRequest * authenticationv1api.TokenRequest , opts metav1.CreateOptions ) (* authenticationv1api.TokenRequest , error ) {
490
+ if sa .client == nil {
491
+ // To handle package release scenarios with DownwardsAPI
492
+ return & authenticationv1api.TokenRequest {}, nil
493
+ }
474
494
return sa .client .CreateToken (ctx , serviceAccountName , tokenRequest , opts )
475
495
}
496
+
497
+ // Minimum required values to
498
+ type MinDiscoveryClient struct {}
499
+
500
+ var _ discovery.DiscoveryInterface = & MinDiscoveryClient {}
501
+
502
+ func (* MinDiscoveryClient ) ServerVersion () (* version.Info , error ) {
503
+ return & version.Info {Major : "1" , Minor : "30.0-invalid" , GitVersion : "1.30.0-invalid" }, nil
504
+ }
505
+
506
+ func (* MinDiscoveryClient ) ServerGroups () (* metav1.APIGroupList , error ) {
507
+ return & metav1.APIGroupList {}, nil
508
+ }
509
+
510
+ func (* MinDiscoveryClient ) RESTClient () rest.Interface { panic ("Not implemented" ) }
511
+ func (* MinDiscoveryClient ) ServerResourcesForGroupVersion (groupVersion string ) (* metav1.APIResourceList , error ) {
512
+ panic ("Not implemented" )
513
+ }
514
+ func (* MinDiscoveryClient ) ServerGroupsAndResources () ([]* metav1.APIGroup , []* metav1.APIResourceList , error ) {
515
+ panic ("Not implemented" )
516
+ }
517
+ func (* MinDiscoveryClient ) ServerPreferredResources () ([]* metav1.APIResourceList , error ) {
518
+ panic ("Not implemented" )
519
+ }
520
+ func (* MinDiscoveryClient ) ServerPreferredNamespacedResources () ([]* metav1.APIResourceList , error ) {
521
+ panic ("Not implemented" )
522
+ }
523
+ func (* MinDiscoveryClient ) OpenAPISchema () (* openapi_v2.Document , error ) { panic ("Not implemented" ) }
524
+ func (* MinDiscoveryClient ) OpenAPIV3 () openapi.Client { panic ("Not implemented" ) }
525
+ func (* MinDiscoveryClient ) WithLegacy () discovery.DiscoveryInterface { panic ("Not implemented" ) }
0 commit comments