Make "standard" flavor os-release variables optional (#62)

* Make "standard" flavor os-release variables optional

and change ARCH to TARGETARCH to simplify how it's passed down from
Earthly in the kairos repo

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Add SOFTWARE_VERSION_PREFIX in os-release

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Accept SOFTWARE_VERSION_PREFIX in cli

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Fix test

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

---------

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
Dimitris Karakasilis
2023-12-14 16:57:03 +02:00
committed by GitHub
parent a8707c113a
commit 74a57eb673
4 changed files with 41 additions and 16 deletions

View File

@@ -28,6 +28,14 @@ const (
unknown = "unknown"
)
type KeyNotFoundErr struct {
Err error
}
func (err KeyNotFoundErr) Error() string {
return err.Err.Error()
}
func SH(c string) (string, error) {
cmd := exec.Command("/bin/sh", "-c", c)
cmd.Env = os.Environ()
@@ -83,7 +91,7 @@ func OSRelease(key string, file ...string) (string, error) {
// We try with the old naming without the prefix in case the key wasn't found
v, exists = release[key]
if !exists {
return "", fmt.Errorf("%s key not found", kairosKey)
return "", KeyNotFoundErr{Err: fmt.Errorf("%s key not found", kairosKey)}
}
}
return v, nil