Skip to content

Conversation

bernielomax
Copy link
Contributor

@bernielomax bernielomax commented Jul 12, 2025

This PR refactors the install command to declare the Kubernetes and Helm clients at the command level. This enables dependency injection into lower-level function calls within the command. A necessary step toward supporting version-specific Helm values since it allows us to query Helm charts and related metadata when generating Helm values. This will obviously assist in maintaining backward compatibility, etc.

Apologies for a few sneaky tidy-up commits at the start. I had planned to raise a separate "clean-up" PR, but I think combining them all here provides better context.

There are also a number of sneaky lint changes that snuck in.

This func does not need to be exported. The Run func is better
placed at the top of the file.
This struct is used by external packages.
Introduce a factory function to initialize the Kubernetes and Helm
clients required by service.Manager. This enables dependency injection
of client initialization into commands, improving testability and
flexibility.

With this approach, clients can be created before constructing the
service manager and reused for other command-level operations (like
checking Helm chart versions for backward compatibility) without
redundant initialization.
Introduce a factory function to initialize the Kubernetes and Helm
clients required by service.Manager. This enables dependency injection
of client initialization into commands, improving testability and
flexibility.

With this approach, clients can be created before constructing the
service manager and reused for other command-level operations (like
checking Helm chart versions for backward compatibility) without
redundant initialization.
@bernielomax bernielomax requested a review from a team as a code owner July 12, 2025 01:26
}

func (i *InstallCmd) installOpts(ctx context.Context, user string) (*service.InstallOpts, error) {
ctx, span := trace.NewSpan(ctx, "InstallCmd.InstallOpts")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ctx, span := trace.NewSpan(ctx, "InstallCmd.InstallOpts")
ctx, span := trace.NewSpan(ctx, "InstallCmd.installOpts")


// SvcMgrClientFactory creates and returns the Kubernetes and Helm clients
// needed by the service manager.
type SvcMgrClientFactory func(kubeConfig, kubeContext string) (k8s.Client, goHelm.Client, error)
Copy link
Member

Choose a reason for hiding this comment

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

a very java name

@bernielomax bernielomax merged commit ce1b7e7 into main Jul 14, 2025
2 checks passed
@bernielomax bernielomax deleted the bernielomax/feat/service-manager-factory branch July 14, 2025 16:51
Copy link

sentry-io bot commented Jul 15, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

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