2
0
mirror of https://github.com/linka-cloud/d2vm.git synced 2025-12-14 15:03:12 +00:00

luks: do not support ubuntu < 20.04 and debian < 10

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
2023-03-01 13:29:10 +01:00
committed by Adphi
parent 8c36d42e06
commit fb33b2a74e
9 changed files with 44 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"text/template"
@@ -66,6 +67,31 @@ type OSRelease struct {
VersionCodeName string
}
func (r OSRelease) SupportsLUKS() bool {
switch r.ID {
case ReleaseUbuntu:
return r.VersionID >= "20.04"
case ReleaseDebian:
v, err := strconv.Atoi(r.VersionID)
if err != nil {
logrus.Warnf("%s: failed to parse version id: %v", r.Version, err)
return false
}
return v >= 10
case ReleaseKali:
// TODO: check version
return true
case ReleaseCentOS:
return true
case ReleaseAlpine:
return true
case ReleaseRHEL:
return false
default:
return false
}
}
func ParseOSRelease(s string) (OSRelease, error) {
env, err := godotenv.Parse(strings.NewReader(s))
if err != nil {