Skip to content

Commit

Permalink
feat(network): add DNS= quadlet option
Browse files Browse the repository at this point in the history
  • Loading branch information
k9withabone committed Dec 20, 2023
1 parent b883330 commit 8679bc3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/cli/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ pub struct Create {
#[arg(long)]
disable_dns: bool,

/// Set network-scoped DNS resolver/nameserver for containers in this network
///
/// Converts to "DNS=IP"
///
/// Can be specified multiple times
#[arg(long, value_name = "IP")]
dns: Vec<String>,

/// Driver to manage the network
///
/// Converts to "Driver=DRIVER"
Expand Down Expand Up @@ -131,6 +139,7 @@ impl From<Create> for crate::quadlet::Network {
let podman_args = value.podman_args.to_string();
Self {
disable_dns: value.disable_dns,
dns: value.dns,
driver: value.driver,
gateway: value.gateway,
internal: value.internal,
Expand All @@ -148,13 +157,6 @@ impl From<Create> for crate::quadlet::Network {
#[derive(Args, Serialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")]
struct PodmanArgs {
/// Set network-scoped DNS resolver/nameserver for containers in this network
///
/// Can be specified multiple times
#[arg(long, value_name = "IP")]
#[serde(skip_serializing_if = "Vec::is_empty")]
dns: Vec<String>,

/// Maps to the `network_interface` option in the network config
#[arg(long, value_name = "NAME")]
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
6 changes: 5 additions & 1 deletion src/quadlet/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ use crate::serde::quadlet::quote_spaces_join_space;
#[serde(rename_all = "PascalCase")]
pub struct Network {
/// If enabled, disables the DNS plugin for this network.
#[serde(skip_serializing_if = "Not::not")]
#[serde(rename = "DisableDNS", skip_serializing_if = "Not::not")]
pub disable_dns: bool,

/// Set network-scoped DNS resolver/nameserver for containers in this network.
#[serde(rename = "DNS")]
pub dns: Vec<String>,

/// Driver to manage the network.
pub driver: Option<String>,

Expand Down

0 comments on commit 8679bc3

Please sign in to comment.