Skip to content

Commit 7d560cc

Browse files
committed
UnixSocketConfiguration: Change from/to to source/destination
This is something I forgot to update ages ago. The field names, while they do make sense, were different than the constructor names that eventually set the fields themselves. This is kind of awkward, and I'd much rather fix this now while it's much easier. Signed-off-by: Danny Canter <danny_canter@apple.com>
1 parent 530126f commit 7d560cc

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

Sources/Containerization/Agent/Vminitd+SocketRelay.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ extension Vminitd: SocketRelayAgent {
2828

2929
switch configuration.direction {
3030
case .into:
31-
$0.guestPath = configuration.to.path
31+
$0.guestPath = configuration.destination.path
3232
$0.action = .into
3333
case .outOf:
34-
$0.guestPath = configuration.from.path
34+
$0.guestPath = configuration.source.path
3535
$0.action = .outOf
3636
}
3737
}

Sources/Containerization/LinuxContainer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,9 +738,9 @@ extension LinuxContainer {
738738
let rootInGuest = URL(filePath: self.root)
739739

740740
if socket.direction == .into {
741-
socket.to = rootInGuest.appending(path: socket.to.path)
741+
socket.destination = rootInGuest.appending(path: socket.destination.path)
742742
} else {
743-
socket.from = rootInGuest.appending(path: socket.from.path)
743+
socket.source = rootInGuest.appending(path: socket.source.path)
744744
}
745745

746746
let port = self.hostVsockPorts.wrappingAdd(1, ordering: .relaxed).oldValue

Sources/Containerization/UnixSocketConfiguration.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ public struct UnixSocketConfiguration: Sendable {
3131
/// direction this should be the path on the host to a unix socket.
3232
/// For direction .outOf this should be the path in the container/guest
3333
/// to a unix socket.
34-
public var from: URL
34+
public var source: URL
3535

3636
/// The path you'd like the socket to be relayed to. For .into
37-
/// direction this should be ther path in the container/guest. For
37+
/// direction this should be the path in the container/guest. For
3838
/// direction .outOf this should be the path on your host.
39-
public var to: URL
39+
public var destination: URL
4040

4141
/// What to set the file permissions of the unix socket being created
4242
/// to. For .into direction this will be the socket in the guest. For
@@ -57,13 +57,13 @@ public struct UnixSocketConfiguration: Sendable {
5757
}
5858

5959
public init(
60-
host: URL,
60+
source: URL,
6161
destination: URL,
6262
permissions: FilePermissions? = nil,
6363
direction: Direction = .into
6464
) {
65-
self.from = host
66-
self.to = destination
65+
self.source = source
66+
self.destination = destination
6767
self.permissions = permissions
6868
self.direction = direction
6969
}

Sources/Containerization/UnixSocketRelay.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ extension SocketRelay {
144144
case .outOf:
145145
// If we created the host conn, lets unlink it also. It's possible it was
146146
// already unlinked if the relay failed earlier.
147-
try? FileManager.default.removeItem(at: self.configuration.to)
147+
try? FileManager.default.removeItem(at: self.configuration.destination)
148148
case .into:
149149
try self.vm.stopListen(self.port)
150150
}
151151
}
152152

153153
private func setupHostVsockDial() async throws {
154-
let hostConn = self.configuration.to
154+
let hostConn = self.configuration.destination
155155

156156
let socketType = try UnixType(
157157
path: hostConn.path,
@@ -181,7 +181,7 @@ extension SocketRelay {
181181
}
182182

183183
private func setupHostVsockListener() throws {
184-
let hostPath = self.configuration.from
184+
let hostPath = self.configuration.source
185185
let port = self.port
186186
let log = self.log
187187

0 commit comments

Comments
 (0)