Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "podlet"
version = "0.3.2-alpha.2"
version = "0.3.2-alpha.3"
authors = ["Paul Nettleton <k9@k9withabone.dev>"]
edition = "2024"
rust-version = "1.85"
Expand Down
34 changes: 26 additions & 8 deletions src/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ pub struct Build {
#[arg(long, value_name = "POLICY")]
pull: Option<PullPolicy>,

/// Number of times to retry pulling images from the registry in case of failure.
///
/// Converts to "Retry=ATTEMPTS".
///
/// Default is 3.
#[arg(long, value_name = "ATTEMPTS")]
retry: Option<u64>,

/// Duration of delay between retry attempts.
///
/// Converts to "RetryDelay=DURATION".
///
/// Default is to start at two seconds and then exponentially back off.
#[arg(long, value_name = "DURATION")]
retry_delay: Option<String>,

/// Pass secret information in a safe way to the build container.
///
/// Converts to "Secret=id=ID,src=PATH".
Expand Down Expand Up @@ -221,6 +237,8 @@ impl From<Build> for quadlet::Build {
label,
network,
pull,
retry,
retry_delay,
secret,
target,
tls_verify,
Expand Down Expand Up @@ -248,6 +266,8 @@ impl From<Build> for quadlet::Build {
network,
podman_args: (!podman_args.is_empty()).then_some(podman_args),
pull,
retry,
retry_delay,
secret,
set_working_directory: context,
target,
Expand Down Expand Up @@ -575,6 +595,12 @@ struct PodmanArgs {
#[arg(long, value_name = "IMAGE_ID_FILE")]
iidfile: Option<PathBuf>,

/// Inherit the labels from the base image or base stages.
#[arg(long, action = ArgAction::Set, default_value_t = true)]
#[serde(skip_serializing_if = "skip_true")]
#[default = true]
inherit_labels: bool,

/// Sets the configuration for IPC namespaces when handling `RUN` instructions.
#[arg(long, value_name = "HOW")]
ipc: Option<String>,
Expand Down Expand Up @@ -673,14 +699,6 @@ struct PodmanArgs {
#[serde(skip_serializing_if = "Not::not")]
quiet: bool,

/// Number of times to retry pulling images from the registry in case of failure.
#[arg(long, value_name = "ATTEMPTS")]
retry: Option<u64>,

/// Duration of delay between retry attempts.
#[arg(long, value_name = "DURATION")]
retry_delay: Option<String>,

/// Remove intermediate containers after a successful build.
#[arg(long, action = ArgAction::Set, default_value_t = true)]
#[serde(skip_serializing_if = "skip_true")]
Expand Down
4 changes: 2 additions & 2 deletions src/cli/container/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl From<compose_spec::Service> for Service {
labels,
log_driver,
log_options,
mem_limit,
network_config,
pids_limit,
ports,
Expand Down Expand Up @@ -198,7 +199,6 @@ impl From<compose_spec::Service> for Service {
ipc,
uts,
mac_address,
mem_limit,
mem_reservation,
mem_swappiness,
memswap_limit,
Expand Down Expand Up @@ -324,6 +324,7 @@ pub struct Quadlet {
pub labels: ListOrMap,
pub log_driver: Option<String>,
pub log_options: IndexMap<MapKey, Option<StringOrNumber>>,
pub mem_limit: Option<ByteValue>,
pub network_config: Option<NetworkConfig>,
pub pids_limit: Option<Limit<u32>>,
pub ports: Ports,
Expand Down Expand Up @@ -359,7 +360,6 @@ pub struct PodmanArgs {
pub ipc: Option<Ipc>,
pub uts: Option<Uts>,
pub mac_address: Option<MacAddress>,
pub mem_limit: Option<ByteValue>,
pub mem_reservation: Option<ByteValue>,
pub mem_swappiness: Option<Percent>,
pub memswap_limit: Option<Limit<ByteValue>>,
Expand Down
18 changes: 0 additions & 18 deletions src/cli/container/podman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ pub struct PodmanArgs {
#[arg(long, value_name = "ADDRESS")]
mac_address: Option<String>,

/// Memory limit
#[arg(short, long, value_name = "NUMBER[UNIT]")]
memory: Option<String>,

/// Memory soft limit
#[arg(long, value_name = "NUMBER[UNIT]")]
memory_reservation: Option<String>,
Expand Down Expand Up @@ -330,18 +326,6 @@ pub struct PodmanArgs {
#[arg(long, value_name = "CONTAINER[,...]")]
requires: Option<String>,

/// Number of times to retry pulling or pushing images between the registry and local storage
///
/// Default is 3
#[arg(long, value_name = "ATTEMPTS")]
retry: Option<u64>,

/// Duration of delay between retry attempts when pulling or pushing images
///
/// Default is to start at two seconds and then exponentially back off
#[arg(long, value_name = "DURATION")]
retry_delay: Option<String>,

/// Remove container (and pod if created) after exit
///
/// Automatically set by Quadlet
Expand Down Expand Up @@ -439,7 +423,6 @@ impl TryFrom<compose::PodmanArgs> for PodmanArgs {
ipc,
uts,
mac_address,
mem_limit,
mem_reservation,
mem_swappiness,
memswap_limit,
Expand Down Expand Up @@ -504,7 +487,6 @@ impl TryFrom<compose::PodmanArgs> for PodmanArgs {
.wrap_err("`ipc` invalid")?,
uts: uts.as_ref().map(ToString::to_string),
mac_address: mac_address.as_ref().map(ToString::to_string),
memory: mem_limit.as_ref().map(ToString::to_string),
memory_reservation: mem_reservation.as_ref().map(ToString::to_string),
memory_swap: memswap_limit,
memory_swappiness: mem_swappiness.map(Into::into),
Expand Down
30 changes: 30 additions & 0 deletions src/cli/container/quadlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ pub struct QuadletOptions {
#[arg(long, value_name = "NAME=VALUE")]
log_opt: Vec<String>,

/// Memory limit
///
/// Converts to "Memory=NUMBER[UNIT]"
#[arg(short, long, value_name = "NUMBER[UNIT]")]
memory: Option<String>,

/// Attach a filesystem mount to the container
///
/// Converts to "Mount=MOUNT"
Expand Down Expand Up @@ -369,6 +375,22 @@ pub struct QuadletOptions {
#[default = true]
read_only_tmpfs: bool,

/// Number of times to retry pulling or pushing images between the registry and local storage
///
/// Converts to "Retry=ATTEMPTS"
///
/// Default is 3
#[arg(long, value_name = "ATTEMPTS")]
retry: Option<u64>,

/// Duration of delay between retry attempts when pulling or pushing images
///
/// Converts to "RetryDelay=DURATION"
///
/// Default is to start at two seconds and then exponentially back off
#[arg(long, value_name = "DURATION")]
retry_delay: Option<String>,

/// The rootfs to use for the container
///
/// Converts to "Rootfs=PATH"
Expand Down Expand Up @@ -548,6 +570,7 @@ impl From<QuadletOptions> for crate::quadlet::Container {
log_driver,
log_opt,
mount,
memory,
network,
network_alias,
sdnotify: notify,
Expand All @@ -556,6 +579,8 @@ impl From<QuadletOptions> for crate::quadlet::Container {
pull,
read_only,
read_only_tmpfs,
retry,
retry_delay,
rootfs,
init: run_init,
secret,
Expand Down Expand Up @@ -626,6 +651,7 @@ impl From<QuadletOptions> for crate::quadlet::Container {
label,
log_driver,
log_opt,
memory,
mount,
network,
network_alias,
Expand All @@ -635,6 +661,8 @@ impl From<QuadletOptions> for crate::quadlet::Container {
pull,
read_only,
read_only_tmpfs,
retry,
retry_delay,
rootfs,
run_init,
secret,
Expand Down Expand Up @@ -683,6 +711,7 @@ impl TryFrom<compose::Quadlet> for QuadletOptions {
labels,
log_driver,
log_options,
mem_limit,
network_config,
pids_limit,
ports,
Expand Down Expand Up @@ -788,6 +817,7 @@ impl TryFrom<compose::Quadlet> for QuadletOptions {
option
})
.collect(),
memory: mem_limit.as_ref().map(ToString::to_string),
network: network_config
.map(network_config_try_into_network_options)
.transpose()
Expand Down
8 changes: 8 additions & 0 deletions src/cli/global_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ use crate::quadlet::Globals;
#[command(next_help_heading = "Podman Global Options")]
#[serde(rename_all = "kebab-case")]
pub struct GlobalArgs {
/// CDI spec directory path
///
/// Default is `/etc/cdi`
///
/// Can be specified multiple times
#[arg(long, global = true, value_name = "PATH")]
cdi_spec_dir: Vec<PathBuf>,

/// Cgroup manager to use
#[arg(long, global = true, value_name = "MANAGER")]
cgroup_manager: Option<CGroupManager>,
Expand Down
21 changes: 21 additions & 0 deletions src/cli/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ pub struct Pull {
#[arg(long, conflicts_with_all = ["os", "arch"], value_name = "OS/ARCH")]
pub platform: Option<Platform>,

/// Number of times to retry pulling or pushing images between the registry and local storage.
///
/// Converts to "Retry=ATTEMPTS".
///
/// Default is 3.
#[arg(long, value_name = "ATTEMPTS")]
#[arg(long)]
pub retry: Option<u64>,

/// Duration of delay between retry attempts when pulling or pushing images.
///
/// Converts to "RetryDelay=DURATION".
///
/// Default is to start at two seconds and then exponentially back off.
#[arg(long, value_name = "DURATION")]
pub retry_delay: Option<String>,

/// Require HTTPS and verify certificates when contacting registries
///
/// Converts to "TLSVerify=TLS_VERIFY"
Expand Down Expand Up @@ -137,6 +154,8 @@ impl From<Pull> for quadlet::Image {
disable_content_trust: _,
os,
platform,
retry,
retry_delay,
tls_verify,
variant,
source: image,
Expand All @@ -157,6 +176,8 @@ impl From<Pull> for quadlet::Image {
image_tag: None,
os,
podman_args: None,
retry,
retry_delay,
tls_verify,
variant,
}
Expand Down
36 changes: 26 additions & 10 deletions src/cli/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,43 @@ use clap::Args;
#[allow(clippy::doc_markdown)]
#[derive(Args, Debug, Clone, PartialEq)]
pub struct Install {
/// Add an [Install] section to the unit
/// Add an [Install] section to the unit.
///
/// By default, if the --wanted-by and --required-by options are not used,
/// the section will have "WantedBy=default.target".
#[allow(clippy::struct_field_names)]
#[arg(short, long)]
pub install: bool,

/// Add (weak) parent dependencies to the unit
/// Add (weak) parent dependencies to the unit.
///
/// Requires the --install option
/// Requires the --install option.
///
/// Converts to "WantedBy=WANTED_BY"
/// Converts to "WantedBy=WANTED_BY".
///
/// Can be specified multiple times
/// Can be specified multiple times.
#[arg(long, requires = "install")]
wanted_by: Vec<String>,

/// Similar to --wanted-by, but adds stronger parent dependencies
/// Similar to --wanted-by, but adds stronger parent dependencies.
///
/// Requires the --install option
/// Requires the --install option.
///
/// Converts to "RequiredBy=REQUIRED_BY"
/// Converts to "RequiredBy=REQUIRED_BY".
///
/// Can be specified multiple times
/// Can be specified multiple times.
#[arg(long, requires = "install")]
required_by: Vec<String>,

/// Similar to --wanted-by, but ensures this unit is up if the parent dependency is.
///
/// Requires the --install option.
///
/// Converts to "UpheldBy=UPHELD_BY".
///
/// Can be specified multiple times.
#[arg(long, requires = "install")]
upheld_by: Vec<String>,
}

impl From<Install> for crate::quadlet::Install {
Expand All @@ -38,15 +48,21 @@ impl From<Install> for crate::quadlet::Install {
install,
wanted_by,
required_by,
upheld_by,
}: Install,
) -> Self {
Self {
wanted_by: if install && wanted_by.is_empty() && required_by.is_empty() {
wanted_by: if install
&& wanted_by.is_empty()
&& required_by.is_empty()
&& upheld_by.is_empty()
{
vec![String::from("default.target")]
} else {
wanted_by
},
required_by,
upheld_by,
}
}
}
Loading