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 @@ -180,11 +180,18 @@ public struct Utility {
180180
181181 config. virtualization = management. virtualization
182182
183- config. networks = try getAttachmentConfigurations ( containerId: config. id, networkIds: management. networks)
184- for attachmentConfiguration in config. networks {
185- let network : NetworkState = try await ClientNetwork . get ( id: attachmentConfiguration. network)
186- guard case . running( _, _) = network else {
187- throw ContainerizationError ( . invalidState, message: " network \( attachmentConfiguration. network) is not running " )
183+ if management. networks. contains ( ClientNetwork . noNetworkName) {
184+ if management. networks. count != 1 {
185+ throw ContainerizationError ( . unsupported, message: " no other networks may be created along with network \( ClientNetwork . noNetworkName) " )
186+ }
187+ config. networks = [ ]
188+ } else {
189+ config. networks = try getAttachmentConfigurations ( containerId: config. id, networkIds: management. networks)
190+ for attachmentConfiguration in config. networks {
191+ let network : NetworkState = try await ClientNetwork . get ( id: attachmentConfiguration. network)
192+ guard case . running( _, _) = network else {
193+ throw ContainerizationError ( . invalidState, message: " network \( attachmentConfiguration. network) is not running " )
194+ }
188195 }
189196 }
190197
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