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

Customizable image location property #2226

Closed
roman-kiselenko opened this issue Mar 1, 2024 · 4 comments
Closed

Customizable image location property #2226

roman-kiselenko opened this issue Mar 1, 2024 · 4 comments
Labels
question Further information is requested

Comments

@roman-kiselenko
Copy link
Contributor

roman-kiselenko commented Mar 1, 2024

Description

Following this issue abiosoft/colima#995

This is happening because this is a work laptop and due to security reasons, I am not allowed to download it via the Terminal. I can download this file in the browser.

I just realize that this would be a good feature to have, customizable image location:

# OpenStack-compatible disk image.
# 🟢 Builtin default: null (must be specified)
# 🔵 This file: Ubuntu images
images:
  - location: "https://cloud-images.ubuntu.com/releases/22.04/release-20240125/ubuntu-22.04-server-cloudimg-amd64.img"
    arch: "x86_64"
    digest: "sha256:f23e5b91af7f52bdd4680d8e9d091093bfc6c4a46b0da7baa3cb450ee917b66b"

If for example a user have airgapped environment or some security policy and in order to run VM you can specify you own .img. Something like this:

# OpenStack-compatible disk image.
# 🟢 Builtin default: null (must be specified)
# 🔵 This file: Ubuntu images
images:
  - location: "file://~/Downloads/ubuntu-22.04-server-cloudimg-amd64.img"
    arch: "x86_64"
    digest: "sha256:f23e5b91af7f52bdd4680d8e9d091093bfc6c4a46b0da7baa3cb450ee917b66b"

In order to achieve this functionalities all we need is a right handling of location property:

// DownloadFile downloads a file to the cache, optionally copying it to the destination. Returns path in cache.
func DownloadFile(ctx context.Context, dest string, f limayaml.File, decompress bool, description string, expectedArch limayaml.Arch) (string, error) {

@lima-vm/maintainers WDYT?

@jandubois
Copy link
Member

This already works:

images:
- location: ~/basedisk

and

$ l start
? Creating an instance "default" Open an editor to review or modify the current configuration
Waiting for Emacs...
INFO[0021] Starting the instance "default" with VM driver "qemu"
INFO[0021] QEMU binary "/usr/local/bin/qemu-system-x86_64" seems properly signed with the "com.apple.security.hypervisor" entitlement
INFO[0021] Attempting to download the image              arch=x86_64 digest="sha256:a7700ca87b691246cf57812c63f64a8ab0d6702c00f04c8f6efd97513bab5d59" location="~/basedisk"
INFO[0023] Downloaded the image from "~/basedisk"

@AkihiroSuda
Copy link
Member

Isn't this already possible?

@AkihiroSuda AkihiroSuda added the question Further information is requested label Mar 1, 2024
@roman-kiselenko
Copy link
Contributor Author

Oh, I see:

func canonicalLocalPath(s string) (string, error) {
if s == "" {
return "", fmt.Errorf("got empty path")
}
if !IsLocal(s) {
return "", fmt.Errorf("got non-local path: %q", s)
}
if strings.HasPrefix(s, "file://") {
res := strings.TrimPrefix(s, "file://")
if !filepath.IsAbs(res) {
return "", fmt.Errorf("got non-absolute path %q", res)
}
return res, nil
}
return localpathutil.Expand(s)
}

There is a checking of remote variable.

🆒

@roman-kiselenko
Copy link
Contributor Author

The bug is in the colima itself, no matter what configuration is specified, it still tries to download the image

cat ~/.colima/_lima/colima-docker/lima.yaml | grep location
    - location: ~/Downloads/data
➜  ~ colima start docker --edit
INFO[0000] editing in nvim from $EDITOR environment variable
INFO[0002] starting colima [profile=docker]
INFO[0002] runtime: docker
INFO[0003] starting ...                                  context=vm
> Using the existing instance "colima-docker"
> Starting the instance "colima-docker" with VM driver "qemu"
> QEMU binary "/opt/homebrew/bin/qemu-system-aarch64" seems properly signed with the "com.apple.security.hypervisor" entitlement
> "Attempting to download the image" arch=aarch64 digest="sha512:00e3339bdebd98c3e003570ffb3ad4b01630fe4fcecd15061d5d58e14c07b211c718ed20fa3e4cce227d3b1c59fd98241eaa3e9e2cdfa04acfe32b4bc385428c" location="https://github.com/abiosoft/colima-core/releases/download/v0.6.8-2/ubuntu-23.10-minimal-cloudimg-arm64.qcow2"
> Downloading the image (ubuntu-23.10-minimal-cloudimg-arm64.qcow2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants