Leverage release as version

This commit is contained in:
Malachi Soord
2023-11-19 22:33:54 +01:00
parent 8be566afb9
commit 03f7ac8468
5 changed files with 201 additions and 257 deletions
+2 -21
View File
@@ -6,7 +6,6 @@ import (
"path/filepath"
"strings"
"github.com/edgebox-iot/edgeboxctl/internal/diagnostics"
"github.com/edgebox-iot/edgeboxctl/internal/utils"
"github.com/shirou/gopsutil/disk"
)
@@ -75,20 +74,9 @@ const (
DISK_TYPE_VDA DeviceIdentifier = "vda"
)
func GetDeviceIdentifier(release_version diagnostics.ReleaseVersion) DeviceIdentifier {
switch release_version {
case diagnostics.CLOUD_VERSION:
return DISK_TYPE_VDA
case diagnostics.PROD_VERSION:
return DISK_TYPE_MCBLK
}
return DISK_TYPE_SDA
}
// GetDevices : Returns a list of all available sotrage devices in structs filled with information
func GetDevices(release_version diagnostics.ReleaseVersion) []Device {
// GetDevices : Returns a list of all available storage devices in structs filled with information
func GetDevices() []Device {
var devices []Device
cmdArgs := []string{"--raw", "--bytes", "--noheadings"}
@@ -100,8 +88,6 @@ func GetDevices(release_version diagnostics.ReleaseVersion) []Device {
firstDevice := true
currentDeviceInUseFlag := false
mainDiskID := GetDeviceIdentifier(release_version)
for scanner.Scan() {
// 1 Device is represented here. Extract words in order for filling a Device struct
// Example deviceRawInfo: "mmcblk0 179:0 0 29.7G 0 disk"
@@ -153,14 +139,9 @@ func GetDevices(release_version diagnostics.ReleaseVersion) []Device {
Status: DeviceStatus{ID: 1, Description: "healthy"},
}
if device.ID == mainDiskID {
device.MainDevice = true
}
currentDevice = device
} else if isPartition {
mountpoint := ""
if len(deviceRawInfo) >= 7 {
mountpoint = deviceRawInfo[6]