-
Notifications
You must be signed in to change notification settings - Fork 100
Support colima #1332
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
base: main
Are you sure you want to change the base?
Support colima #1332
Conversation
pkg/container/runtime/types.go
Outdated
@@ -186,6 +186,8 @@ const ( | |||
TypeDocker Type = "docker" | |||
// TypeKubernetes represents the Kubernetes runtime | |||
TypeKubernetes Type = "kubernetes" | |||
// TypeColima represents the Colima runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be necessary - it looks like you are using the Docker runtime to connect to Colima. This enum is used for different implementations of our runtime interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In review, I'm checking in the Docker runtime if there is a path override in the Docker runtime check, but I'm also checking explicitly if its Colima:
https://github.com/stacklok/toolhive/pull/1332/files#diff-d58624f599f4b93a4c84d22c3d24888c6a2c57855eb451ccc72815d5cda9667bR88-R94
I'd like not to remove this, because if I do, then the user has to know and explicitly override the Docker socket to the Colima socket, which requires discovery of this in the docs or otherwise.
What are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should remove the Colima check in the docker runtime codepath:
https://github.com/stacklok/toolhive/pull/1332/files#diff-d58624f599f4b93a4c84d22c3d24888c6a2c57855eb451ccc72815d5cda9667bR65-R73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the Colima check from there and instead add it to findDockerSocket
, similar to what we currently have for Rancher Desktop:
toolhive/pkg/container/docker/sdk/client_unix.go
Lines 147 to 158 in 386e7fa
// Try Rancher Desktop socket path on macOS | |
if home := os.Getenv("HOME"); home != "" { | |
rancherDesktopPath := filepath.Join(home, RancherDesktopMacSocketPath) | |
_, err := os.Stat(rancherDesktopPath) | |
if err == nil { | |
logger.Debugf("Found Rancher Desktop socket at %s", rancherDesktopPath) | |
return rancherDesktopPath, nil | |
} | |
logger.Debugf("Failed to check Rancher Desktop socket at %s: %v", rancherDesktopPath, err) | |
} |
With that you'll be able to remove all the other changes to client_unix.go
.
@goshlanguage This makes sense to me. Feel free to update the branch and take it out of draft status. |
I added a PR that does almost exactly the same thing. I wanted to 👍 the support for this PR. I updated all of the docs to include Colima in mine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @goshlanguage! I've added a suggestion inline about how this could be simplified.
pkg/container/runtime/types.go
Outdated
@@ -186,6 +186,8 @@ const ( | |||
TypeDocker Type = "docker" | |||
// TypeKubernetes represents the Kubernetes runtime | |||
TypeKubernetes Type = "kubernetes" | |||
// TypeColima represents the Colima runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the Colima check from there and instead add it to findDockerSocket
, similar to what we currently have for Rancher Desktop:
toolhive/pkg/container/docker/sdk/client_unix.go
Lines 147 to 158 in 386e7fa
// Try Rancher Desktop socket path on macOS | |
if home := os.Getenv("HOME"); home != "" { | |
rancherDesktopPath := filepath.Join(home, RancherDesktopMacSocketPath) | |
_, err := os.Stat(rancherDesktopPath) | |
if err == nil { | |
logger.Debugf("Found Rancher Desktop socket at %s", rancherDesktopPath) | |
return rancherDesktopPath, nil | |
} | |
logger.Debugf("Failed to check Rancher Desktop socket at %s: %v", rancherDesktopPath, err) | |
} |
With that you'll be able to remove all the other changes to client_unix.go
.
@eleftherias seems that your suggestion then will only work for Colima on mac, and not colima on linux. Are you sure that's what we want? Means I still can't use this on my linux environments. edit: I haven't confirmed, so I will test this. I do like less code |
yeah unfortunately it looks like that's not a compatible approach: ➜ toolhive git:(support-colima) ./bin/thv client setup
A new version of ToolHive is available: v0.2.13
Currently running: vf0c65e0
Error: failed to create client manager: no supported container runtime available: container runtime not found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for trying it out on Linux! We do want it to work on both.
With the current proposal does it work on Linux, or is there still more to be done?
@@ -38,6 +38,7 @@ require ( | |||
go.opentelemetry.io/otel/sdk v1.37.0 | |||
go.opentelemetry.io/otel/sdk/metric v1.37.0 | |||
go.uber.org/mock v0.5.2 | |||
golang.ngrok.com/ngrok/v2 v2.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change still needed?
@@ -157,5 +166,18 @@ func findDockerSocket() (string, error) { | |||
logger.Debugf("Failed to check Rancher Desktop socket at %s: %v", rancherDesktopPath, err) | |||
} | |||
|
|||
// Try Rancher Desktop socket path on macOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
// Try Rancher Desktop socket path on macOS | |
// Try Colima socket path on macOS |
I needed to add
colima
in order to usethv
in my current setup. Opening as draft as I'm traveling as I write this PR and haven't given due diligence of going through the Dev Guide. Hoping to share for guidance.Before:
After: