1448 use yip (#135)

Co-authored-by: Mauro Morales <mauro.morales@spectrocloud.com>
Co-authored-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
Dimitris Karakasilis
2023-07-04 15:52:26 +03:00
committed by GitHub
parent 62831b8ecf
commit 13b06d9e35
6 changed files with 38 additions and 1552 deletions

View File

@@ -10,11 +10,8 @@ import (
"time"
"github.com/avast/retry-go"
"github.com/jaypipes/ghw"
"github.com/jaypipes/ghw/pkg/block"
"github.com/joho/godotenv"
"github.com/kairos-io/kairos-sdk/state"
"github.com/kairos-io/kairos-sdk/utils"
)
// BootStateToLabelDevice lets us know the device we need to mount sysroot on based on labels.
@@ -236,23 +233,3 @@ func GetHostProcCmdline() string {
}
return proc
}
// GetPartByLabel will identify the device by a given label.
func GetPartByLabel(label string, attempts int) (string, error) {
for tries := 0; tries < attempts; tries++ {
_, _ = utils.SH("udevadm settle")
blockDevices, err := block.New(ghw.WithDisableTools(), ghw.WithDisableWarnings())
if err != nil {
return "", err
}
for _, d := range blockDevices.Disks {
for _, part := range d.Partitions {
if part.FilesystemLabel == label {
return filepath.Join("/dev/", part.Name), nil
}
}
}
time.Sleep(1 * time.Second)
}
return "", errors.New("no device found")
}