File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
Services/ContainerAPIService/Networks Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ public struct ClientNetwork {
2424 static let serviceIdentifier = " com.apple.container.apiserver "
2525
2626 public static let defaultNetworkName = " default "
27+ public static let noNetworkName = " none "
2728}
2829
2930extension ClientNetwork {
Original file line number Diff line number Diff line change @@ -176,11 +176,18 @@ public struct Utility {
176176
177177 config. virtualization = management. virtualization
178178
179- config. networks = try getAttachmentConfigurations ( containerId: config. id, networkIds: management. networks)
180- for attachmentConfiguration in config. networks {
181- let network : NetworkState = try await ClientNetwork . get ( id: attachmentConfiguration. network)
182- guard case . running( _, _) = network else {
183- throw ContainerizationError ( . invalidState, message: " network \( attachmentConfiguration. network) is not running " )
179+ if management. networks. contains ( ClientNetwork . noNetworkName) {
180+ guard management. networks. count == 1 else {
181+ throw ContainerizationError ( . unsupported, message: " no other networks may be created along with network \( ClientNetwork . noNetworkName) " )
182+ }
183+ config. networks = [ ]
184+ } else {
185+ config. networks = try getAttachmentConfigurations ( containerId: config. id, networkIds: management. networks)
186+ for attachmentConfiguration in config. networks {
187+ let network : NetworkState = try await ClientNetwork . get ( id: attachmentConfiguration. network)
188+ guard case . running( _, _) = network else {
189+ throw ContainerizationError ( . invalidState, message: " network \( attachmentConfiguration. network) is not running " )
190+ }
184191 }
185192 }
186193
Original file line number Diff line number Diff line change @@ -107,6 +107,11 @@ public actor NetworksService {
107107 " id " : " \( configuration. id) "
108108 ] )
109109
110+ //Ensure that the network is not named "none"
111+ if configuration. id == ClientNetwork . noNetworkName {
112+ throw ContainerizationError ( . unsupported, message: " network \( configuration. id) is not a valid name " )
113+ }
114+
110115 // Ensure nobody is manipulating the network already.
111116 guard !busyNetworks. contains ( configuration. id) else {
112117 throw ContainerizationError ( . exists, message: " network \( configuration. id) has a pending operation " )
You can’t perform that action at this time.
0 commit comments