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

create doesn't provide a way to pass a null argument for the template #33

Open
griwes opened this issue Jul 8, 2024 · 1 comment
Open

Comments

@griwes
Copy link

griwes commented Jul 8, 2024

container.create in the C bindings for LXC allows a user to pass in a null pointer instead of a template name for that argument; this is used for example when you run lxc-create -t none, which allows creating a container, but without a rootfs (thus allowing for full customization of the container with config options).

The current API in this crate doesn't allow for that, as it always passes a string into the C bindings. There should be a way to create a container without a rootfs. (I'd be happy with just an additional function that invokes the bindings with a reasonable set of arguments to achieve this, but I'm not sure if that's the right design for such an interface in general.)

@sanpii
Copy link
Owner

sanpii commented Jul 9, 2024

The current API in this crate doesn't allow for that, as it always passes a string into the C bindings

Fixed 5bbe44a

I'd be happy with just an additional function that invokes the bindings with a reasonable set of arguments to achieve this, but I'm not sure if that's the right design for such an interface in general.

It’s probably a good idea to redesign this function with a builder:

c.create()
    .template("download")
    .flag(lxc::CreateFlags::QUIET)
    .arg("-d")
    .arg("ubuntu")
    .arg("-r")
    .arg("trusty")
    .arg("-a")
    .arg("i386")
    // or .args(&["-d", "ubuntu", "-r", "trusty", "-a", "i386"])
    .build()

What do you think?

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

No branches or pull requests

2 participants