mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-04-28 03:32:27 +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 (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"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)
|
||||
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
|
||||
systemdVersionInt, err := strconv.Atoi(systemdVersion)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user