feat: add --split-options option#168
Merged
k9withabone merged 2 commits intomainfrom Jan 28, 2026
Merged
Conversation
0791cd5 to
b846cc5
Compare
Member
Author
|
@cgzones Do you want to test this out to see if it matches your expectations? |
Changed `podlet::serde::quadlet::Serializer` to accept sequences and
tuples in addition to structs. Elements in a sequence are serialized as
separate sections. Tuples are combined into a single section (for
combining `podlet::quadlet::Resource` and `podlet::quadlet::Globals`).
Added `impl Serialize for podlet::quadlet::File`, serializing it as a
sequence.
Changed `impl Display for podlet::quadlet::File` to use the new
`Serialize` impl.
Removed `Display` impls from all of
`podlet::{cli::{Service, Unit}, quadlet::{Build, Container, Globals,
Image, Install, Kube, Network, Pod, Resource, Volume}}` as they are no
longer used.
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
By default, when generating a Quadlet file, Podlet will combine all
Quadlet options that can be into a space separated list
(e.g., `Environment=ONE=one TWO=two`). The `--split-options` option
allows the user to specify which Quadlet options they would like Podlet
to write on separate lines.
This is achieved by subtracting the given Quadlet options from the set
of all Quadlet options that can be joined together and passing the
resulting set to the serializer. The serializer uses that set to
determine which Quadlet options should be joined together in a space
separated list.
Added `podlet::Cli.split_options` field.
Added `podlet::Cli::SPLIT_OPTIONS_HELP`, the long help for
`--split-options`. Set separately from the field in order to preserve
the formatting of the examples.
Replaced `impl Display for podlet::cli::File` with
`podlet::cli::File::serialize()`.
Replaced `impl Display for podlet::cli::k8s::File` with
`podlet::cli::k8s::File::serialize_to_yaml()`.
Replaced `impl Display for podlet::quadlet::File` with
`podlet::quadlet::File::serialize_to_quadlet()`.
Added `podlet::quadlet::JoinOption` enum, which represents all Quadlet
options that can be joined together.
Replaced both of
`podlet::serde::quadlet::{quote_spaces_join_colon(),
quote_spaces_join_space()}` with
`podlet::serde::quadlet::seq_quote_whitespace()` which serializes
a sequence while quoting any values with whitespace.
Changed `podlet::serde::quadlet::to_string()` to take a set of
`podlet::quadlet::JoinOption`s.
Added `podlet::serde::quadlet::to_string_join_all()` as a shortcut to
use in tests.
Changed `podlet::serde::quadlet::ValueSerializer` to use the added
`podlet::serde::quadlet::SeqValueSerializer` to serialize sequences.
`SeqValueSerializer` is where it's decided whether to serialize a
sequence as a single space separated line or as multiple key-value
pairs.
Closes: #118
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
b846cc5 to
95ae763
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a
-s, --split-optionsoption that allows the user to specify Quadlet options that should be split onto multiple lines. By default, Podlet combines all Quadlet options that can be into a space separated list.For example,
podlet podman run -e ONE=one -e TWO=two imageresults in:While
podlet -s Environment podman run -e ONE=one -e TWO=two imageresults in:Implementing this required some refactoring of how
podlet::serde::quadlet::Serializerworks, see the commit messages for details.This is a draft PR until I get CI working again. I will be creating and merging a branch to update dependencies, make Clippy fixes, and add a MSRV policy. Then I'll rebase this branch and it'll be ready for review.
Closes: #118