-
Notifications
You must be signed in to change notification settings - Fork 28
/
DeploymentDestination.swift
62 lines (56 loc) · 2.16 KB
/
DeploymentDestination.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import Foundation
import PathLib
import QueueModels
public struct DeploymentDestination: Codable, CustomStringConvertible, Hashable {
public let workerId: WorkerId
public let host: String
public let port: Int32
public let username: String
public let authentication: DeploymentDestinationAuthenticationType
public let remoteDeploymentPath: AbsolutePath
public let configuration: WorkerSpecificConfiguration?
enum CodingKeys: String, CodingKey {
case host
case port
case username
case authentication
case remoteDeploymentPath
case configuration
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let host = try container.decode(String.self, forKey: .host)
let port = try container.decode(Int32.self, forKey: .port)
let username = try container.decode(String.self, forKey: .username)
let authentication = try container.decode(DeploymentDestinationAuthenticationType.self, forKey: .authentication)
let remoteDeploymentPath = try container.decode(AbsolutePath.self, forKey: .remoteDeploymentPath)
let configuration = try container.decodeIfPresent(WorkerSpecificConfiguration.self, forKey: .configuration)
self.init(
host: host,
port: port,
username: username,
authentication: authentication,
remoteDeploymentPath: remoteDeploymentPath,
configuration: configuration
)
}
public init(
host: String,
port: Int32,
username: String,
authentication: DeploymentDestinationAuthenticationType,
remoteDeploymentPath: AbsolutePath,
configuration: WorkerSpecificConfiguration?
) {
self.workerId = WorkerId(value: host)
self.host = host
self.port = port
self.username = username
self.authentication = authentication
self.remoteDeploymentPath = remoteDeploymentPath
self.configuration = configuration
}
public var description: String {
return "<\(type(of: self)) host: \(host)>"
}
}