Skip to content

Conversation

@manusa
Copy link
Member

@manusa manusa commented Nov 25, 2025

Simplifies the relationship between the Manager, Kubernetes, and AccessControlClientset types.
The changes reduce indirection and move functionality to more appropriate locations.

Kubernetes no longer wraps a Manager which could be confusing especially for the derived scenarios.

Manger should only concern with the lifecycle management and the derived instance creation (wip).
All access to the cluster should be done from a derived Kubernetes instance (wip).

@manusa manusa added this to the 0.1.0 milestone Nov 25, 2025
@manusa manusa requested a review from Cali0707 November 25, 2025 14:10
…anager and Kubernetes structs

Signed-off-by: Marc Nuri <[email protected]>
@manusa manusa force-pushed the refactor/kubernetes-manager branch from b1e7b0b to 6148224 Compare November 25, 2025 15:18
Comment on lines +60 to +71
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
}
Copy link
Collaborator

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)
Copy link
Collaborator

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")
Copy link
Collaborator

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

Suggested change
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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants