@@ -19,6 +19,9 @@ struct VMStartCommand: AsyncParsableCommand {
1919 @Flag ( help: " Mount the system git mirrors directory into the virtual machine on startup? " )
2020 var withGitMirrors : Bool = false
2121
22+ @Flag ( help: " Mount the directory with shared credentials into the virtual machine on startup? " )
23+ var withCommonCredentials : Bool = false
24+
2225 @Flag ( help: " Wait indefinitely for the SSH server to become available (useful when provisioning a new image " )
2326 var waitForever : Bool = false
2427
@@ -33,6 +36,7 @@ struct VMStartCommand: AsyncParsableCommand {
3336 case name
3437 case handle
3538 case withGitMirrors
39+ case withCommonCredentials
3640 case waitForever
3741 case persistent
3842 case skipNetworkChecks
@@ -72,19 +76,30 @@ struct VMStartCommand: AsyncParsableCommand {
7276 }
7377 }
7478
79+ // Those paths are auto-mounted in the VM in the `/Volumes/My Shared Files/` path
80+ // See https://developer.apple.com/documentation/virtualization/vzvirtiofilesystemdeviceconfiguration
81+ // See Sources/libhostmgr/VM/LaunchConfiguration.swift#L69-L82
7582 var sharedPaths : [ LaunchConfiguration . SharedPath ] {
7683 get throws {
77- guard try FileManager . default. directoryExists ( at: Paths . gitMirrorStorageDirectory) else {
78- return [ ]
84+ var paths : [ LaunchConfiguration . SharedPath ] = [ ]
85+
86+ if self . withGitMirrors {
87+ if try FileManager . default. directoryExists ( at: Paths . gitMirrorStorageDirectory) {
88+ paths. append (
89+ LaunchConfiguration . SharedPath ( source: Paths . gitMirrorStorageDirectory, readOnly: true )
90+ )
91+ }
7992 }
8093
81- guard self . withGitMirrors == true else {
82- return [ ]
94+ if self . withCommonCredentials {
95+ if try FileManager . default. directoryExists ( at: Paths . commonCredentialsDirectory) {
96+ paths. append (
97+ LaunchConfiguration . SharedPath ( source: Paths . commonCredentialsDirectory, readOnly: true )
98+ )
99+ }
83100 }
84101
85- return [
86- LaunchConfiguration . SharedPath ( source: Paths . gitMirrorStorageDirectory, readOnly: true )
87- ]
102+ return paths
88103 }
89104 }
90105}
0 commit comments