vv9k / podman-api-rs

Rust interface to Podman (libpod).
MIT License
84 stars 12 forks source link

Question regarding `ContainerCreateOptsBuilder::mounts` #138

Closed marhkb closed 2 years ago

marhkb commented 2 years ago

Hi @vv9k,

I just noticed that you added ContainerCreateOptsBuilder::mounts, which expects the following data. https://github.com/vv9k/podman-api-rs/blob/f87d80d50d4a4b3846c0f7f899b3f16ecf5fcd44/podman-api-stubs/lib/src/models.rs#L4694

I have been using my own fork of podman-api-rs with a slightly different mounts option for a while now and would love to switch back to upstream. Here you can see how it looks. https://github.com/marhkb/pods/blob/95dee64fc5d2a79a3ddd7fe7d03f790d2ef986d1/src/view/container/creation_page.rs#L771 https://github.com/marhkb/pods/blob/95dee64fc5d2a79a3ddd7fe7d03f790d2ef986d1/src/view/container/creation_page.rs#L882

podman-cockpit was taken as an example for this. https://github.com/cockpit-project/cockpit-podman/blob/c53c2c9c5c7d8dd834994a9c7db4d7d09391ccdc/src/ImageRunModal.jsx#L220

What is noticeable here is that the schema of the data that podman-cockpit uses does not match that of the official API and that in podman-rs. https://docs.podman.io/en/latest/_static/api.html?version=v4.2#tag/containers/operation/ContainerCreateLibpod

However, when I switch back to podman-api-rs upstream, I have problems creating the volumes.

.mounts(
                imp.volumes
                    .borrow()
                    .to_owned()
                    .to_typed_list_model::<model::Volume>()
                    .into_iter()
                    .map(|volume| podman::models::Mount {
                        bind_options: None,
                        consistency: None,
                        read_only: Some(volume.writable()),
                        source: Some(volume.host_path()),
                        target: Some(volume.container_path()),
                        tmpfs_options: None,
                        type_: Some("bind".to_owned()),
                        volume_options: None,
                        // Some({
                        //     let selinux = volume.selinux().to_string();
                        //     if !selinux.is_empty() {
                        //         options.push(selinux)
                        //     }

                        //     options
                        // }),
                    }),
            )

grafik

I'm quite clueless. :-D Would you have any idea how to correctly use mounts option? Is the documentation of the podman API wrong, or do I use it in the wrong way?

vv9k commented 2 years ago

Hey,

It seems that the documentation here is wrong and the actual type currently doesn't get generated. https://github.com/containers/podman/issues/13717

We'll probably have to add the new type by hand (as you have added in pods) for now and override the parameter used in ContainerCreateOptsBuilder.

Here is the full type to be added: https://github.com/opencontainers/runtime-spec/blob/main/specs-go/config.go#L110-L120