Skip to content

Commit

Permalink
feat: add OS version comparison functions
Browse files Browse the repository at this point in the history
  • Loading branch information
femnad committed Dec 24, 2023
1 parent 2cff3cf commit f6c1985
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions precheck/fact.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,32 @@ func isOsVersion(version float64) (bool, error) {
return osVersion == version, err
}

func osVersionGe(version float64) (bool, error) {
osVersion, err := GetOSVersion()
if err != nil {
return false, err
}

return osVersion >= version, nil
}

func osVersionLe(version float64) (bool, error) {
osVersion, err := GetOSVersion()
if err != nil {
return false, err
}

return osVersion <= version, nil
}

var FactFns = template.FuncMap{
"env": hasEnv,
"is": isA,
"ok": isOk,
"os": isOs,
"output": hasOutput,
"pkg": hasPkgMgr,
"version": isOsVersion,
"env": hasEnv,
"is": isA,
"ok": isOk,
"os": isOs,
"output": hasOutput,
"pkg": hasPkgMgr,
"version": isOsVersion,
"versionGe": osVersionGe,
"versionLe": osVersionLe,
}

0 comments on commit f6c1985

Please sign in to comment.