Skip to content

Commit d35502d

Browse files
committed
cleanup: use local CmdRunner instead of exposing CmdRunner at volumeMounter
1 parent 15dd698 commit d35502d

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

Diff for: providers/os/connection/device/linux/device_manager.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const (
3636

3737
type LinuxDeviceManager struct {
3838
volumeMounter snapshot.VolumeMounter
39+
cmdRunner *snapshot.LocalCommandRunner
3940
opts map[string]string
4041
}
4142

@@ -46,6 +47,7 @@ func NewLinuxDeviceManager(shell []string, opts map[string]string) (*LinuxDevice
4647

4748
return &LinuxDeviceManager{
4849
volumeMounter: snapshot.NewVolumeMounter(shell),
50+
cmdRunner: &snapshot.LocalCommandRunner{Shell: shell},
4951
opts: opts,
5052
}, nil
5153
}
@@ -161,7 +163,7 @@ func (d *LinuxDeviceManager) hintFSTypes(partitions []*snapshot.PartitionInfo) (
161163
}
162164

163165
func (d *LinuxDeviceManager) attemptFindFstab(dir string) ([]resources.FstabEntry, error) {
164-
cmd, err := d.volumeMounter.CmdRunner().RunCommand(fmt.Sprintf("find %s -type f -wholename '*/etc/fstab'", dir))
166+
cmd, err := d.cmdRunner.RunCommand(fmt.Sprintf("find %s -type f -wholename '*/etc/fstab'", dir))
165167
if err != nil {
166168
log.Error().Err(err).Msg("error searching for fstab")
167169
return nil, nil
@@ -479,7 +481,7 @@ func (c *LinuxDeviceManager) identifyViaDeviceName(deviceName string, mountAll b
479481
return []*snapshot.PartitionInfo{}, nil
480482
}
481483

482-
blockDevices, err := c.volumeMounter.CmdRunner().GetBlockDevices()
484+
blockDevices, err := c.cmdRunner.GetBlockDevices()
483485
if err != nil {
484486
return nil, err
485487
}

Diff for: providers/os/connection/device/linux/lun.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type scsiDeviceInfo struct {
2222
type scsiDevices = []scsiDeviceInfo
2323

2424
func (c *LinuxDeviceManager) listScsiDevices() ([]scsiDeviceInfo, error) {
25-
cmd, err := c.volumeMounter.CmdRunner().RunCommand("lsscsi --brief")
25+
cmd, err := c.cmdRunner.RunCommand("lsscsi --brief")
2626
if err != nil {
2727
return nil, err
2828
}

Diff for: providers/os/connection/snapshot/volumemounter.go

-6
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ type VolumeMounter interface {
2424
UmountP(partition *PartitionInfo) error
2525
UnmountVolumeFromInstance() error
2626
RemoveTempScanDir() error
27-
28-
CmdRunner() *LocalCommandRunner
2927
}
3028

3129
type volumeMounter struct {
@@ -174,7 +172,3 @@ func (m *volumeMounter) RemoveTempScanDir() error {
174172

175173
return errors.Join(errs...)
176174
}
177-
178-
func (m *volumeMounter) CmdRunner() *LocalCommandRunner {
179-
return m.cmdRunner
180-
}

0 commit comments

Comments
 (0)