-
Notifications
You must be signed in to change notification settings - Fork 185
refactor(kubernetes): enhance AccessControlClientset and streamline Manager and Kubernetes structs #503
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
base: main
Are you sure you want to change the base?
Conversation
…anager and Kubernetes structs Signed-off-by: Marc Nuri <[email protected]>
b1e7b0b to
6148224
Compare
| func (k *Kubernetes) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error) { | ||
| return k.AccessControlClientset().DiscoveryClient(), nil | ||
| } | ||
|
|
||
| func (k *Kubernetes) ToRESTMapper() (meta.RESTMapper, error) { | ||
| return k.AccessControlClientset().RESTMapper(), nil | ||
| } | ||
|
|
||
| // ToRESTConfig returns the rest.Config object (genericclioptions.RESTClientGetter) | ||
| func (k *Kubernetes) ToRESTConfig() (*rest.Config, error) { | ||
| return k.AccessControlClientset().cfg, nil | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manusa do we want to keep the error in the return types here? I understand changing that would be a breaking change downstream, but I think long term it could simplify our code somewhat if we don't anticipate changes re-introducing the error value here
| derived, err := NewAccessControlClientset(m.staticConfig, clientcmd.NewDefaultClientConfig(clientCmdApiConfig, nil), derivedCfg) | ||
| if err != nil { | ||
| if m.staticConfig.RequireOAuth { | ||
| klog.Errorf("failed to get kubeconfig: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manusa is this error message still accurate?
| ctx := context.WithValue(s.T().Context(), HeaderKey("Authorization"), "Bearer aiTana-julIA") | ||
| derived, err := badManager.Derived(ctx) | ||
| s.Require().NoErrorf(err, "expected no error when RequireOAuth=false, got: %v", err) | ||
| s.Equal(derived.accessControlClientSet, badManager.accessControlClientset, "expected original clientset when RawConfig fails and RequireOAuth=false") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use the getter method here
| s.Equal(derived.accessControlClientSet, badManager.accessControlClientset, "expected original clientset when RawConfig fails and RequireOAuth=false") | |
| s.Equal(derived.AccessControlClientset(), badManager.AccessControlClientset(), "expected original clientset when RawConfig fails and RequireOAuth=false") |
Simplifies the relationship between the
Manager,Kubernetes, andAccessControlClientsettypes.The changes reduce indirection and move functionality to more appropriate locations.
Kubernetesno longer wraps aManagerwhich could be confusing especially for the derived scenarios.Mangershould only concern with the lifecycle management and the derived instance creation (wip).All access to the cluster should be done from a derived
Kubernetesinstance (wip).