Skip to content

Commit

Permalink
Toggle shared dirs based on the config option enable-shared-dirs
Browse files Browse the repository at this point in the history
Use the config option to decide if shared directories should be
automatically configured during start
  • Loading branch information
anjannath authored and praveenkumar committed Aug 5, 2022
1 parent a9031ad commit aa97905
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/crc/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func runStart(ctx context.Context) (*types.StartResult, error) {
PullSecret: cluster.NewInteractivePullSecretLoader(config),
KubeAdminPassword: config.Get(crcConfig.KubeAdminPassword).AsString(),
Preset: crcConfig.GetPreset(config),
EnableSharedDirs: crcConfig.ShouldEnableSharedDirs(config),
}

client := newMachine()
Expand Down
1 change: 1 addition & 0 deletions pkg/crc/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func getStartConfig(cfg crcConfig.Storage, args client.StartConfig) types.StartC
PullSecret: cluster.NewNonInteractivePullSecretLoader(cfg, args.PullSecretFile),
KubeAdminPassword: cfg.Get(crcConfig.KubeAdminPassword).AsString(),
Preset: crcConfig.GetPreset(cfg),
EnableSharedDirs: crcConfig.ShouldEnableSharedDirs(cfg),
}
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/crc/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ func GetNetworkMode(config Storage) network.Mode {
return network.ParseMode(config.Get(NetworkMode).AsString())
}

func ShouldEnableSharedDirs(config Storage) bool {
// Shared dirs are not implemented for windows
if runtime.GOOS == "windows" {
return false
}
return config.Get(EnableSharedDirs).AsBool()
}

func UpdateDefaults(cfg *Config) {
RegisterSettings(cfg)
}
7 changes: 4 additions & 3 deletions pkg/crc/machine/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,10 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
return nil, errors.Wrap(err, "Failed to add nameserver to the VM")
}
}

if err := configureSharedDirs(vm, sshRunner); err != nil {
return nil, err
if startConfig.EnableSharedDirs {
if err := configureSharedDirs(vm, sshRunner); err != nil {
return nil, err
}
}

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

0 comments on commit aa97905

Please sign in to comment.