forked from alexsteinerde/docker-client-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Container.swift
42 lines (37 loc) · 1.35 KB
/
Container.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Foundation
import Network
/// Representation of a container.
/// Some actions can be performed on an instance.
public struct Container {
public var id: Identifier<Container>
public var image: Image
public var createdAt: Date
public var names: [String]
public var state: String
public var command: String
}
extension Container: Codable {}
/// Representation of a port binding
public struct PortBinding {
public var hostIP: IPAddress
public var hostPort: UInt16
public var containerPort: UInt16
public var networkProtocol: NetworkProtocol
/// Creates a PortBinding
///
/// - Parameters:
/// - hostIP: The host IP address to map the connection to. Default `0.0.0.0`.
/// - hostPort: The port on the Docker host to map connections to. `0` means map to a random available port. Default `0`.
/// - containerPort: The port on the container to map connections from.
/// - networkProtocol: The protocol (`tcp`/`udp`) to bind. Default `tcp`.
public init(hostIP: IPAddress=IPv4Address.any, hostPort: UInt16=0, containerPort: UInt16, networkProtocol: NetworkProtocol = .tcp) {
self.hostIP = hostIP
self.hostPort = hostPort
self.containerPort = containerPort
self.networkProtocol = networkProtocol
}
}
public enum NetworkProtocol: String {
case tcp
case udp
}