Skip to content

ref(*): refactor flag and environment settings - #6508

Closed
adamreese wants to merge 1 commit into
helm:dev-v3from
adamreese:ref/envvars
Closed

adamreese wants to merge 1 commit into
helm:dev-v3from
adamreese:ref/envvars

Conversation

@adamreese

Copy link
Copy Markdown
Member

No description provided.

@adamreese adamreese self-assigned this Sep 26, 2019
@helm-bot helm-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 26, 2019
@thomastaylor312 thomastaylor312 added refactor v3.x Issues and Pull Requests related to the major version v3 labels Sep 26, 2019

@thomastaylor312 thomastaylor312 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few points of discussion. Otherwise a great looking refactor

Comment thread pkg/cli/environment.go
env := EnvSettings{
Namespace: os.Getenv("HELM_NAMESPACE"),
return &EnvSettings{
// Namespace: os.Getenv("HELM_NAMESPACE"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume this line should be deleted

Comment thread pkg/cli/environment.go
fs.StringVar(&s.RegistryConfig, "registry-config", s.RegistryConfig, "path to the registry config file")
fs.StringVar(&s.RepositoryConfig, "repository-config", s.RepositoryConfig, "path to the file containing repository names and URLs")
fs.StringVar(&s.RepositoryCache, "repository-cache", s.RepositoryCache, "path to the file containing cached repository indexes")
s.KubeConfig.AddFlags(fs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is going to add tons of flags to the commands. Do we really want all of them? Obviously this would get us closer to what kubectl has, but it still feels a bit like overkill.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same to me, I would like to at least hide some of the flags here and for the logging setup

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should not add the flags now and if the need comes up later, we can add this back in. I'm not married to the idea, so if you like it as is now, that should be fine!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After looking at this again, I think this is ok to have

if settings.Debug != tt.debug {
t.Errorf("expected debug %t, got %t", tt.debug, settings.Debug)
}
if settings.Namespace != tt.ns {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need a unit test for the new Namespace function instead?

Comment thread pkg/plugin/plugin.go Resolved
Comment thread pkg/cli/environment.go
"HELM_REGISTRY_CONFIG": s.RegistryConfig,
"HELM_REPOSITORY_CACHE": s.RepositoryCache,
"HELM_REPOSITORY_CONFIG": s.RepositoryConfig,
"HELM_NAMESPACE": s.Namespace(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Trying to adopt the helm-diff plugin for helm3 it came up that plugins are unaware of --kube-context and --namespace passed to the main binary. This makes it impossible to talk to the k8s cluster used by helm:
databus23/helm-diff#151 (comment)

Not sure if this is the right place but how about passing the values from --kube0context as HELM_KUBECONTEXT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also of note from that issue in helm-diff is that @databus23 pointed out that we still have --kube-context as a top level flag in the helm CLI, and now we will also have --context due to the flags we attach with the AddFlags method

@mumoshu mumoshu Oct 10, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this is the right place to set something like HELM_KUBECONTEXT as this EnvVars are inherited to the plugin via

env := settings.EnvVars()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A dedicated issue opened for adding those envvars: #6631

@bacongobbler

bacongobbler commented Oct 10, 2019 •

Copy link
Copy Markdown
Member

Hey @adamreese! How are we on this PR? Do you need another set of eyes to review this one, or is there some refactoring work involved before I take this for a spin?

@adamreese adamreese closed this Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size/L Denotes a PR that changes 100-499 lines, ignoring generated files. v3.x Issues and Pull Requests related to the major version v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants