Skip to content
Merged
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
15 changes: 8 additions & 7 deletions Sources/ContainerCommands/Network/NetworkDelete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@ extension Application {
let uniqueNetworkNames = Set<String>(networkNames)
let networks: [NetworkState]

if uniqueNetworkNames.contains(ClientNetwork.defaultNetworkName) {
throw ContainerizationError(
.invalidArgument,
message: "cannot delete the default network"
)
}

if all {
networks = try await ClientNetwork.list()
.filter { $0.id != ClientNetwork.defaultNetworkName }
} else {
networks = try await ClientNetwork.list()
.filter { c in
Expand All @@ -78,13 +86,6 @@ extension Application {
}
}

if uniqueNetworkNames.contains(ClientNetwork.defaultNetworkName) {
throw ContainerizationError(
.invalidArgument,
message: "cannot delete the default network"
)
}

var failed = [String]()
let logger = log
try await withThrowingTaskGroup(of: NetworkState?.self) { group in
Expand Down