mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-01 17:16:40 +00:00
Add UKI functionlity to replace titles (#246)
* Add UKI functionlity to replace titles Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com> * Move common logic to constants Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com> --------- Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
This commit is contained in:
@@ -17,7 +17,9 @@ limitations under the License.
|
||||
package constants
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -112,6 +114,10 @@ const (
|
||||
UkiEfiDir = "/efi"
|
||||
UkiEfiDiskByLabel = `/dev/disk/by-label/` + EfiLabel
|
||||
UkiMaxEntries = 3
|
||||
|
||||
// Boot labeling
|
||||
PassiveBootSuffix = " (fallback)"
|
||||
RecoveryBootSuffix = " recovery"
|
||||
)
|
||||
|
||||
func UkiDefaultSkipEntries() []string {
|
||||
@@ -160,3 +166,25 @@ func GetConfigScanDirs() []string {
|
||||
"/etc/elemental", // for backwards compatibility
|
||||
}
|
||||
}
|
||||
|
||||
func BaseBootTitle(title string) string {
|
||||
if strings.HasSuffix(title, RecoveryBootSuffix) {
|
||||
return strings.TrimSuffix(title, RecoveryBootSuffix)
|
||||
} else if strings.HasSuffix(title, PassiveBootSuffix) {
|
||||
return strings.TrimSuffix(title, PassiveBootSuffix)
|
||||
}
|
||||
return title
|
||||
}
|
||||
|
||||
func BootTitleForRole(role, title string) (string, error) {
|
||||
switch role {
|
||||
case ActiveImgName:
|
||||
return BaseBootTitle(title), nil
|
||||
case PassiveImgName:
|
||||
return BaseBootTitle(title) + PassiveBootSuffix, nil
|
||||
case RecoveryImgName:
|
||||
return BaseBootTitle(title) + RecoveryBootSuffix, nil
|
||||
default:
|
||||
return "", errors.New("invalid role")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user