Skip to content

fix(compose): support explicit network names - #223

Open
x3ccd4828 wants to merge 3 commits into
containers:mainfrom
x3ccd4828:fix/compose-network-name
Open

fix(compose): support explicit network names#223
x3ccd4828 wants to merge 3 commits into
containers:mainfrom
x3ccd4828:fix/compose-network-name

Conversation

@x3ccd4828

Copy link
Copy Markdown

Summary

  • accept the Compose name field on top-level network definitions
  • emit the explicit name as NetworkName= in the generated Quadlet network unit
  • add regression coverage for the conversion

Why

Compose allows a network resource key and the created network's name to differ:

networks:
  backend:
    name: explicit-network-name

Podlet 0.3.2 currently rejects this input because the Quadlet network conversion classifies name as unsupported. Mapping it to NetworkName= preserves the resource key for the generated backend.network file and its container references while creating the Podman network with the requested explicit name.

This implements the behavior described in #21.

Validation

  • cargo fmt --verbose --check
  • cargo clippy -- -Dwarnings
  • cargo test --verbose (78 passed)
  • end-to-end Compose conversion confirmed Network=backend.network and NetworkName=explicit-network-name

@x3ccd4828
x3ccd4828 force-pushed the fix/compose-network-name branch 2 times, most recently from 1d1df01 to ea2a9f9 Compare July 28, 2026 19:56
@x3ccd4828
x3ccd4828 marked this pull request as ready for review July 28, 2026 19:57
Signed-off-by: Cristian Filipescu <filipescu.cristian@gmail.com>
@x3ccd4828
x3ccd4828 force-pushed the fix/compose-network-name branch from ea2a9f9 to a621d55 Compare July 28, 2026 19:59
@k9withabone

Copy link
Copy Markdown
Member

Thanks for submitting a PR! Sorry for not getting to this sooner.

@k9withabone k9withabone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a couple nitpicks, this looks good!

Comment thread src/quadlet/network.rs Outdated
Comment on lines +57 to +59
/// Override the name of the Podman network created by this Quadlet.
#[serde(rename = "NetworkName")]
pub name: Option<String>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field should be named network_name instead of using the #[serde(rename = "NetworkName"] attribute. I try to reserve the attribute for when it can't be avoided such as for one-off case conversions.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied the fix

Comment thread src/quadlet/network.rs
Comment on lines 80 to 92
impl Downgrade for Network {
fn downgrade(&mut self, version: PodmanVersion) -> Result<(), DowngradeError> {
if version < PodmanVersion::V5_6 {
if let Some(interface_name) = self.interface_name.take() {
self.push_arg("interface-name", &interface_name);
}
}

if version < PodmanVersion::V4_7 {
for dns in std::mem::take(&mut self.dns) {
self.push_arg("dns", &dns);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add the new field to the Downgrade impl. Looking at old versions of the Quadlet documentation, it looks like NetworkName= was added in Podman v4.7.0.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i applied the fix

@cfilipescu

Copy link
Copy Markdown

@k9withabone i want to add more PRs what is the best way to get these reviewed and merged quickly?

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

Successfully merging this pull request may close these issues.

3 participants