Skip to content

Commit aa97905

Browse files
anjannathpraveenkumar
authored andcommitted
Toggle shared dirs based on the config option enable-shared-dirs
Use the config option to decide if shared directories should be automatically configured during start
1 parent a9031ad commit aa97905

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

cmd/crc/cmd/start.go

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func runStart(ctx context.Context) (*types.StartResult, error) {
7474
PullSecret: cluster.NewInteractivePullSecretLoader(config),
7575
KubeAdminPassword: config.Get(crcConfig.KubeAdminPassword).AsString(),
7676
Preset: crcConfig.GetPreset(config),
77+
EnableSharedDirs: crcConfig.ShouldEnableSharedDirs(config),
7778
}
7879

7980
client := newMachine()

pkg/crc/api/handlers.go

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func getStartConfig(cfg crcConfig.Storage, args client.StartConfig) types.StartC
116116
PullSecret: cluster.NewNonInteractivePullSecretLoader(cfg, args.PullSecretFile),
117117
KubeAdminPassword: cfg.Get(crcConfig.KubeAdminPassword).AsString(),
118118
Preset: crcConfig.GetPreset(cfg),
119+
EnableSharedDirs: crcConfig.ShouldEnableSharedDirs(cfg),
119120
}
120121
}
121122

pkg/crc/config/settings.go

+8
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ func GetNetworkMode(config Storage) network.Mode {
145145
return network.ParseMode(config.Get(NetworkMode).AsString())
146146
}
147147

148+
func ShouldEnableSharedDirs(config Storage) bool {
149+
// Shared dirs are not implemented for windows
150+
if runtime.GOOS == "windows" {
151+
return false
152+
}
153+
return config.Get(EnableSharedDirs).AsBool()
154+
}
155+
148156
func UpdateDefaults(cfg *Config) {
149157
RegisterSettings(cfg)
150158
}

pkg/crc/machine/start.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,10 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
367367
return nil, errors.Wrap(err, "Failed to add nameserver to the VM")
368368
}
369369
}
370-
371-
if err := configureSharedDirs(vm, sshRunner); err != nil {
372-
return nil, err
370+
if startConfig.EnableSharedDirs {
371+
if err := configureSharedDirs(vm, sshRunner); err != nil {
372+
return nil, err
373+
}
373374
}
374375

375376
if _, _, err := sshRunner.RunPrivileged("make root Podman socket accessible", "chmod 777 /run/podman/ /run/podman/podman.sock"); err != nil {

0 commit comments

Comments
 (0)