Skip to content
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

Check for a $KUBECONFIG env-variable #316

Merged
merged 3 commits into from Feb 14, 2022
Merged

Check for a $KUBECONFIG env-variable #316

merged 3 commits into from Feb 14, 2022

Conversation

YrrepNoj
Copy link
Member

This PR adds a check for the $KUBECONFIG environment variable when Zarf is trying to generate a config to talk to a native kubernetes cluster.

Closes #315

@YrrepNoj YrrepNoj self-assigned this Feb 11, 2022
@jeff-mccoy
Copy link
Member

It would be swell to see some type of test for this. Like maybe move the k3s kube config and set the env variable.

// use the current context in the default kubeconfig in the home path of the user
homePath, err := os.UserHomeDir()
if err != nil {
message.Fatal(nil, "Unable to load the current user's home directory")
Copy link
Member

Choose a reason for hiding this comment

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

What's the latest on doing this vs returning error? I thought at some point I had heard @jeff-mccoy say we were switching to returning error to make testing easier.

Though, I'm seeing right below this it doing the same thing, so maybe the question is whether a refactor of this method is warranted along with this change.

Copy link
Member

Choose a reason for hiding this comment

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

we are moving towards bubbling errors, but that would be a larger refactor than this code right now, so I think this one is okay.

@YrrepNoj
Copy link
Member Author

/test all

@YrrepNoj
Copy link
Member Author

/test all

@jeff-mccoy
Copy link
Member

/test all

Copy link
Member

@jeff-mccoy jeff-mccoy left a comment

Choose a reason for hiding this comment

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

lgtm

// use the current context in the default kubeconfig in the home path of the user
homePath, err := os.UserHomeDir()
if err != nil {
message.Fatal(nil, "Unable to load the current user's home directory")
Copy link
Member

Choose a reason for hiding this comment

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

we are moving towards bubbling errors, but that would be a larger refactor than this code right now, so I think this one is okay.

@jeff-mccoy jeff-mccoy merged commit 46a2e66 into master Feb 14, 2022
@jeff-mccoy jeff-mccoy deleted the 315-kubeconfig-env branch February 14, 2022 17:37
Noxsios pushed a commit that referenced this pull request Mar 8, 2023
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.

Zarf doesn't consider $KUBECONFIG env when running commands
3 participants