Reject conflicting DNS flags (#1559)

Rejects conflicting DNS configuration when `--no-dns` is supplied
together with explicit DNS flags.

Fixes #1536.
This commit is contained in:
Shaurya Singh
2026-05-15 09:49:15 -07:00
committed by GitHub
parent 5317536888
commit 64bd48bb9e
2 changed files with 55 additions and 0 deletions
@@ -344,6 +344,21 @@ public struct Flags {
@Option(name: [.customLong("volume"), .short], help: "Bind mount a volume into the container")
public var volumes: [String] = []
public func validate() throws {
if dnsDisabled {
let hasDNSConfig =
!dns.nameservers.isEmpty
|| dns.domain != nil
|| !dns.options.isEmpty
|| !dns.searchDomains.isEmpty
if hasDNSConfig {
throw ValidationError(
"`--no-dns` cannot be used with DNS configuration flags (`--dns`, `--dns-domain`, `--dns-option`, `--dns-search`)"
)
}
}
}
}
public struct Progress: ParsableArguments {