Skip to content

previewctl: Wrap shell script that list VMs #10771

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

Merged
merged 1 commit into from
Jun 20, 2022
Merged

Conversation

ArthurSens
Copy link
Contributor

@ArthurSens ArthurSens commented Jun 20, 2022

Signed-off-by: ArthurSens [email protected]

Description

Add command previewctl list, which lists all existing preview environments.

It is done by re-implementing the shell script dev/preview/list-vms.sh but with go and native Kubernetes go clients.

Related Issue(s)

Looks like we don't have an issue for this one, but we did agree on working on this during our team-sync.

How to test

Run the command previewctl list

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-as-preview-list-vms.2 because the annotations in the pull request description changed
(with .werft/ from main)

@@ -89,3 +95,46 @@ func (p *Preview) GetPreviewName() string {

return sanitizedBranch
}

func ListAllPreviews() error {
configLoadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: "/home/gitpod/.kube/config"}
Copy link
Contributor

@vulkoingim vulkoingim Jun 20, 2022

Choose a reason for hiding this comment

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

I think it's safer to use the default rule. If you really want to use this explicit one - then still merging with the default one is a safer option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree, for some reason it didn't work though 🤔

I tried using:

  • ~/.kube/config
  • ${HOME}/.kube/config
  • $HOME/.kube/config

They all fail with the same error: stat <filepath>: file or directory does not exist

The only way I was able to make this run was by using the explicit path :(

Copy link
Contributor

Choose a reason for hiding this comment

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

The default path should be in $KUBECONFIG, but the package provides a way to load from well-known paths. Have a look at the godocs and the examples: https://pkg.go.dev/k8s.io/client-go/tools/clientcmd

Ultimately have one rule loading the default + this one with the explicit and then merge them together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nice, I was not aware of those defaults. Changed the PR to use them :)

@ArthurSens ArthurSens force-pushed the as/preview-list-vms branch from 593d1ff to cfd1185 Compare June 20, 2022 17:35
@roboquat roboquat merged commit 59071b4 into main Jun 20, 2022
@roboquat roboquat deleted the as/preview-list-vms branch June 20, 2022 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

3 participants