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

feat: Print the current context when chectl is run #647

Merged
merged 5 commits into from
Apr 17, 2020

Conversation

tolusha
Copy link
Collaborator

@tolusha tolusha commented Apr 16, 2020

Signed-off-by: Anatoliy Bazko abazko@redhat.com

What does this PR do?

Prints the current context when chectl is run

What issues does this PR fix or reference?

eclipse-che/che#15741

Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
@tolusha tolusha changed the title Support exported kubeconfigs feat: Support exported kubeconfigs Apr 16, 2020
@tolusha tolusha changed the title feat: Support exported kubeconfigs [WIP] feat: Support exported kubeconfigs Apr 16, 2020
Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
@tolusha tolusha changed the title [WIP] feat: Support exported kubeconfigs feat: Support exported kubeconfigs Apr 16, 2020
@tolusha
Copy link
Collaborator Author

tolusha commented Apr 16, 2020

[test]

Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
@tolusha
Copy link
Collaborator Author

tolusha commented Apr 16, 2020

After digging into the code I figured out that KubeConfig already takes into account KUBECONFIG env var

        if (process.env.KUBECONFIG && process.env.KUBECONFIG.length > 0) {
            const files = process.env.KUBECONFIG.split(path.delimiter);
            this.loadFromFile(files[0]);
            for (let i = 1; i < files.length; i++) {
                const kc = new KubeConfig();
                kc.loadFromFile(files[i]);
                this.mergeConfig(kc);
            }
            return;
        }

So, I've decided just to print the current context

Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
@tolusha tolusha changed the title feat: Support exported kubeconfigs feat: Print the current context when chectl is run Apr 16, 2020
@tolusha
Copy link
Collaborator Author

tolusha commented Apr 16, 2020

[test]

kc = new KubeConfig()
portForwardHelper = new PortForward(this.kc, true)
logHelper = new Log(this.kc)
public static readonly KUBE_CONFIG = KubeHelper.initializeKubeConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not keen on the idea to make kubeconfig static.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor

Choose a reason for hiding this comment

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

KubeHelper is helper class which is used to communicate with Kubernetes API. By making kubeconfig static you basically make whole class static, so it becomes more a namespace than a class... It is my vision...

@tolusha
Copy link
Collaborator Author

tolusha commented Apr 16, 2020

[test]

@tolusha tolusha merged commit 2a7a009 into master Apr 17, 2020
@tolusha tolusha deleted the ab/improvekubeconfig branch April 17, 2020 05:34
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.

None yet

3 participants