Skip to content

Conversation

@k9withabone
Copy link
Member

Changes the library used for deserializing a compose file from docker-compose-types to compose_spec. Most of the conversion logic was refactored/rewritten and hopefully readability and maintainability have improved in those areas. compose_spec is a lot stricter about what it accepts as a valid compose file. This is a breaking change as some compose files (those that don't comply with the spec) will no longer successfully deserialize and convert.

A new --binds-to option was added, which sets BindsTo= in the [Unit] section. It was needed for converting from long syntax depends_on when restart is true.

One other breaking change is that podlet compose --pod was renamed to podlet compose --kube and no longer takes an argument. Instead, podlet uses the top-level name field from the compose file for the name of pod. --pod will return with Podman v5.0.0 support (#68).

Closes #47
Closes #61
Closes #62
Closes #63
Closes #69

@k9withabone k9withabone added bug Something isn't working enhancement New feature or request labels Apr 24, 2024
@k9withabone k9withabone added this to the v0.3.0 milestone Apr 24, 2024
@k9withabone k9withabone linked an issue Apr 24, 2024 that may be closed by this pull request
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Added `compose_spec` dependency, temporarily using the git repository.

Also updated some error messages and error docs for
`cli::compose::from_file_or_stdin()`, `cli::compose::from_stdin()`,
and `cli::Commands::try_into_files()`.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Required for converting `compose_spec::service::Dependency`.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Check each field instead of comparing to the default.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Changed `cli::Commands::try_into_files()` to use `compose_spec::Compose`
for conversion to `quadlet::File`s. Now rejects `include` and `configs`,
and requires `secrets` to be external.

Changed `cli::compose::try_into_quadlet_files()` to use
`compose_spec::Compose` and added error docs. `cli::compose::services()`
was removed as it is no longer needed.

Changed `cli::compose::service_try_into_quadlet_file()` to use
`compose_spec::Service` and added more docs. Instead of going through
`cli::PodmanCommands`, the service is converted into a `cli::Container`
directly and then into a `quadlet::Container`. The `cli::Service` is
created from the `compose_spec::service::Restart`.

Removed `cli::ComposeService` as `.volume` is now added to the
`quadlet::container::volume::Source::NamedVolume` after the
`compose_spec::Service` is converted into a `quadlet::Container` in
`cli::compose::service_try_into_quadlet_file()`.

Changed `cli::Unit::add_dependencies()` to `add_dependency()` which now
takes a dependency name `compose_spec::Identifier` and a
`compose_spec::service::Dependency` from `compose_spec::Service`'s
`depends_on` field. It also errors if the `Dependency` is not compatible
with quadlet.

Changed `cli::compose::networks_try_into_quadlet_files()` to use
`compose_spec::Networks` and added error docs.

Changed `cli::compose::volumes_try_into_quadlet_files()` to use
`compose_spec::Volumes` and added more docs.

Added docs to `cli::Container::name()`.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
First, a `cli::GlobalArgs` is created by taking the `runtime` and
`storage_opt` fields from the `compose_spec::Service`.
Next, that is converted to a `quadlet::Globals` which is used in the
generated `quadlet::File`.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
…ice`

Split up `compose_spec::Service` into separate parts in
`cli::container::compose`. Allows for destructuring, ensuring all fields
of `compose_spec::Service` are considered for conversion. Also, no more
`TryFrom<&mut ComposeService>`, yay!

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Completes the creation of `cli::Container` from `compose_spec::Service`.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Also changed `options` field of `quadlet::Network` to a `Vec<String>`.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
`podlet compose --pod <POD>` is now `podlet compose --kube`.

The `name` field of a compose file is required when using `--kube`.
It is used as the name of the pod and in the filenames of the generated
`.kube` quadlet file and Kubernetes YAML file.

Frees `podlet compose --pod` for creating a `.pod` quadlet file from a
compose file in the future.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
`cli::File::KubePod { .. }` changed to
`cli::File::Kubernetes(cli::k8s::File)`.

`cli::k8s::File` created from `compose_spec::Compose`.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
All usages were replaced with `compose_spec::duration`.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

2 participants