k3d-io / k3d

Little helper to run CNCF's k3s in Docker
https://k3d.io/
MIT License
5.48k stars 462 forks source link

[BUG] Version command should not require a docker runtime #1514

Open erikgb opened 2 months ago

erikgb commented 2 months ago

What did you do

We are building a container image with k3d installed. As part of the build pipeline, I want to do a lightweight test/verification of the k3d installation. When the pipeline had access to docker, both k3d --version and k3d version worked. But now I want to avoid having docker (or any other container runtime) available to the pipeline. But this does not seem to work:

$ k3d version
Failed to initialize: unable to resolve docker endpoint: open /certs/client/ca.pem: no such file or directory

The only reference to this path I can find is the environment variable DOCKER_CERT_PATH=/certs/client . I've been looking briefly at the k3d source code, and I suspect there might be something in the generic init applied to all commands: https://github.com/k3d-io/k3d/blob/7f8ffd64b23ee3b69da576186b09014d5b352f28/cmd/root.go#L203

The container image has docker installed adding some DOCKER_* environment variables. As a workaround, I tried to unset all DOCKER_* environment variables before running the test (inside the image). And it works! But I think the k3d version should be independent of a Docker runtime present - regardless of docker environment variables present.

What did you expect to happen

The commands k3d --version and k3d version prints the versions as it should without errors.

Which version of k3d

v5.7.4