1
1
import Foundation
2
2
3
3
struct Config : Codable {
4
- internal init ( provisioner: ProvisionerConfig , hardware: HardwareConfig , directoryMounts: [ DirectoryMountConfig ] , source: VMSource , vmClonePath: String , numberOfRunsUntilHostReboot: Int ? = nil , runnerName: String ? = nil , editorMode: Bool , autoTransferImageVolume: String ? = nil , retryDelay: Int , sshCredentials: SSHCredentials , preRun: String ? = nil , postRun: String ? = nil ) {
4
+ internal init (
5
+ provisioner: ProvisionerConfig ,
6
+ hardware: HardwareConfig ,
7
+ directoryMounts: [ DirectoryMountConfig ] ,
8
+ source: VMSource ,
9
+ vmClonePath: String ,
10
+ numberOfRunsUntilHostReboot: Int ? = nil ,
11
+ runnerName: String ? = nil ,
12
+ editorMode: Bool ,
13
+ autoTransferImageVolume: String ? = nil ,
14
+ retryDelay: Int ,
15
+ sshCredentials: SSHCredentials ,
16
+ preRun: String ? = nil ,
17
+ postRun: String ? = nil
18
+ ) {
5
19
self . provisioner = provisioner
6
20
self . hardware = hardware
7
21
self . directoryMounts = directoryMounts
@@ -15,7 +29,7 @@ struct Config: Codable {
15
29
self . preRun = preRun
16
30
self . postRun = postRun
17
31
}
18
-
32
+
19
33
/// Provisioner Configuration.
20
34
let provisioner : ProvisionerConfig
21
35
/// Hardware Configuration.
@@ -42,7 +56,7 @@ struct Config: Codable {
42
56
let preRun : String ?
43
57
/// A command to run after the provisioning commands are run.
44
58
let postRun : String ?
45
-
59
+
46
60
enum CodingKeys : CodingKey {
47
61
case provisioner
48
62
case hardware
@@ -57,14 +71,16 @@ struct Config: Codable {
57
71
case preRun
58
72
case postRun
59
73
}
60
-
74
+
61
75
init ( from decoder: Decoder ) throws {
62
76
let container = try decoder. container ( keyedBy: CodingKeys . self)
63
77
self . provisioner = try container. decode ( ProvisionerConfig . self, forKey: . provisioner)
64
78
self . hardware = try container. decodeIfPresent ( HardwareConfig . self, forKey: . hardware) ?? . default
65
79
self . directoryMounts = try container. decodeIfPresent ( [ DirectoryMountConfig ] . self, forKey: . directoryMounts) ?? [ ]
66
80
self . source = try container. decode ( VMSource . self, forKey: . source)
67
- self . vmClonePath = ( try container. decodeIfPresent ( String . self, forKey: . vmClonePath) . map { ( $0 as NSString ) . standardizingPath } ) ?? URL ( filePath: NSHomeDirectory ( ) ) . appending ( component: " vmclone " ) . path
81
+ self . vmClonePath = (
82
+ try container. decodeIfPresent ( String . self, forKey: . vmClonePath) . map { ( $0 as NSString ) . standardizingPath }
83
+ ) ?? URL ( filePath: NSHomeDirectory ( ) ) . appending ( component: " vmclone " ) . path
68
84
self . numberOfRunsUntilHostReboot = try container. decodeIfPresent ( Int . self, forKey: . numberOfRunsUntilHostReboot)
69
85
self . runnerName = try container. decodeIfPresent ( String . self, forKey: . runnerName)
70
86
self . editorMode = try container. decodeIfPresent ( Bool . self, forKey: . editorMode) ?? false
@@ -76,8 +92,7 @@ struct Config: Codable {
76
92
}
77
93
78
94
struct SSHCredentials : Codable {
79
- static var `default` = Self . init ( username: " admin " , password: " admin " )
95
+ static var `default` = Self ( username: " admin " , password: " admin " )
80
96
let username : String
81
97
let password : String
82
98
}
83
-
0 commit comments