Add json output for ignition

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2023-08-15 17:37:03 -06:00
committed by Jonathon Anderson
parent 45539a0d1f
commit a7df560a30
9 changed files with 242 additions and 16 deletions

View File

@@ -5,6 +5,7 @@ import (
"reflect"
"regexp"
"sort"
"strconv"
"strings"
"github.com/hpcng/warewulf/internal/pkg/util"
@@ -281,6 +282,37 @@ func (ent *Entry) GotReal() bool {
return len(ent.value) != 0
}
/*
Get a pointer to the value
*/
func (ent *Entry) GetPointer() *string {
ret := ent.Get()
return &ret
}
/*
Try to get a int of a value, 0 if value can't be parsed!
*/
func (ent *Entry) GetInt() int {
var ret int
if len(ent.value) != 0 {
ret, _ = strconv.Atoi(ent.value[0])
} else if len(ent.altvalue) != 0 {
ret, _ = strconv.Atoi(ent.altvalue[0])
} else if len(ent.def) != 0 {
ret, _ = strconv.Atoi(ent.def[0])
}
return ret
}
/*
Ptr to int
*/
func (ent *Entry) GetIntPtr() *int {
ret := ent.GetInt()
return &ret
}
/**********
*
* Misc