mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-08-17 15:57:46 +00:00
Ensure only numeric part of systemd version is converted to int (#362)
This commit is contained in:
parent
3462167492
commit
54a528a44a
@ -3,6 +3,7 @@ package hook
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -32,6 +33,12 @@ func (k KcryptUKI) Run(c config.Config, spec v1.Spec) error {
|
|||||||
c.Logger.Errorf("could not get systemd version: %s", err)
|
c.Logger.Errorf("could not get systemd version: %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// Extract the numeric portion of the version string using a regular expression
|
||||||
|
re := regexp.MustCompile(`\d+`)
|
||||||
|
matches := re.FindString(systemdVersion)
|
||||||
|
if matches == "" {
|
||||||
|
return fmt.Errorf("could not extract numeric part from systemd version: %s", systemdVersion)
|
||||||
|
}
|
||||||
// Change systemdVersion to int value
|
// Change systemdVersion to int value
|
||||||
systemdVersionInt, err := strconv.Atoi(systemdVersion)
|
systemdVersionInt, err := strconv.Atoi(systemdVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user