replace bools in disk structures with wwBool
This commit is contained in:
@@ -93,7 +93,7 @@ Holds the disks of a node
|
||||
*/
|
||||
type Disk struct {
|
||||
id string `yaml:"-" json:"-"`
|
||||
WipeTable bool `yaml:"wipe_table,omitempty" json:"wipe_table,omitempty" lopt:"diskwipe" comment:"whether or not the partition tables shall be wiped"`
|
||||
WipeTable wwtype.WWbool `yaml:"wipe_table,omitempty" json:"wipe_table,omitempty" lopt:"diskwipe" comment:"whether or not the partition tables shall be wiped"`
|
||||
Partitions map[string]*Partition `yaml:"partitions,omitempty" json:"partitions,omitempty"`
|
||||
}
|
||||
|
||||
@@ -102,29 +102,29 @@ partition definition, the label must be uniq so its used as the key in the
|
||||
Partitions map
|
||||
*/
|
||||
type Partition struct {
|
||||
id string `yaml:"-" json:"-"`
|
||||
Number string `yaml:"number,omitempty" json:"number,omitempty" lopt:"partnumber" comment:"Set the partition number, if not set next free slot is used" type:"uint"`
|
||||
SizeMiB string `yaml:"size_mib,omitempty" json:"size_mib,omitempty" lopt:"partsize" comment:"Set the size of the partition, if not set maximal possible size is used" type:"uint"`
|
||||
StartMiB string `yaml:"start_mib,omitempty" json:"start_mib,omitempty" comment:"the start of the partition" type:"uint"`
|
||||
TypeGuid string `yaml:"type_guid,omitempty" json:"type_guid,omitempty" lopt:"parttype" comment:"Set the partition type GUID"`
|
||||
Guid string `yaml:"guid,omitempty" json:"guid,omitempty" comment:"the GPT unique partition GUID"`
|
||||
WipePartitionEntry bool `yaml:"wipe_partition_entry,omitempty" json:"wipe_partition_entry,omitempty" comment:"if true, Ignition will clobber an existing partition if it does not match the config"`
|
||||
ShouldExist bool `yaml:"should_exist,omitempty" json:"should_exist,omitempty" lopt:"partcreate" comment:"Create partition if it does not exist"`
|
||||
Resize bool `yaml:"resize,omitempty" json:"resize,omitempty" comment:"whether or not the existing partition should be resize"`
|
||||
id string `yaml:"-" json:"-"`
|
||||
Number string `yaml:"number,omitempty" json:"number,omitempty" lopt:"partnumber" comment:"Set the partition number, if not set next free slot is used" type:"uint"`
|
||||
SizeMiB string `yaml:"size_mib,omitempty" json:"size_mib,omitempty" lopt:"partsize" comment:"Set the size of the partition, if not set maximal possible size is used" type:"uint"`
|
||||
StartMiB string `yaml:"start_mib,omitempty" json:"start_mib,omitempty" comment:"the start of the partition" type:"uint"`
|
||||
TypeGuid string `yaml:"type_guid,omitempty" json:"type_guid,omitempty" lopt:"parttype" comment:"Set the partition type GUID"`
|
||||
Guid string `yaml:"guid,omitempty" json:"guid,omitempty" comment:"the GPT unique partition GUID"`
|
||||
WipePartitionEntry wwtype.WWbool `yaml:"wipe_partition_entry,omitempty" json:"wipe_partition_entry,omitempty" comment:"if true, Ignition will clobber an existing partition if it does not match the config"`
|
||||
ShouldExist wwtype.WWbool `yaml:"should_exist,omitempty" json:"should_exist,omitempty" lopt:"partcreate" comment:"Create partition if it does not exist"`
|
||||
Resize wwtype.WWbool `yaml:"resize,omitempty" json:"resize,omitempty" comment:"whether or not the existing partition should be resize"`
|
||||
}
|
||||
|
||||
/*
|
||||
Definition of a filesystem. The device is uniq so its used as key
|
||||
*/
|
||||
type FileSystem struct {
|
||||
id string `yaml:"-" json:"-"`
|
||||
Format string `yaml:"format,omitempty" json:"format,omitempty" lopt:"fsformat" comment:"format of the file system"`
|
||||
Path string `yaml:"path,omitempty" json:"path,omitempty" lopt:"fspath" comment:"the mount point of the file system"`
|
||||
WipeFileSystem bool `yaml:"wipe_filesystem,omitempty" json:"wipe_filesystem,omitempty" lopt:"fswipe" comment:"wipe file system at boot"`
|
||||
Label string `yaml:"label,omitempty" json:"label,omitempty" comment:"the label of the filesystem"`
|
||||
Uuid string `yaml:"uuid,omitempty" json:"uuid,omitempty" comment:"the uuid of the filesystem"`
|
||||
Options []string `yaml:"options,omitempty" json:"options,omitempty" comment:"any additional options to be passed to the format-specific mkfs utility"`
|
||||
MountOptions string `yaml:"mount_options,omitempty" json:"mount_options,omitempty" comment:"any special options to be passed to the mount command"`
|
||||
id string `yaml:"-" json:"-"`
|
||||
Format string `yaml:"format,omitempty" json:"format,omitempty" lopt:"fsformat" comment:"format of the file system"`
|
||||
Path string `yaml:"path,omitempty" json:"path,omitempty" lopt:"fspath" comment:"the mount point of the file system"`
|
||||
WipeFileSystem wwtype.WWbool `yaml:"wipe_filesystem,omitempty" json:"wipe_filesystem,omitempty" lopt:"fswipe" comment:"wipe file system at boot"`
|
||||
Label string `yaml:"label,omitempty" json:"label,omitempty" comment:"the label of the filesystem"`
|
||||
Uuid string `yaml:"uuid,omitempty" json:"uuid,omitempty" comment:"the uuid of the filesystem"`
|
||||
Options []string `yaml:"options,omitempty" json:"options,omitempty" comment:"any additional options to be passed to the format-specific mkfs utility"`
|
||||
MountOptions string `yaml:"mount_options,omitempty" json:"mount_options,omitempty" comment:"any special options to be passed to the mount command"`
|
||||
}
|
||||
|
||||
type Resource interface{}
|
||||
|
||||
@@ -115,7 +115,7 @@ func (node *Node) GetIgnitionStorage() (stor types_3_4.Storage, rep string, err
|
||||
myFs := types_3_4.Filesystem{
|
||||
Device: fsdevice,
|
||||
Path: &fs.Path,
|
||||
WipeFilesystem: &wipe,
|
||||
WipeFilesystem: wipe.BoolPtr(),
|
||||
}
|
||||
if fs.Format != "" {
|
||||
myFs.Format = &fs.Format
|
||||
@@ -156,14 +156,14 @@ func (node *Node) GetIgnitionStorage() (stor types_3_4.Storage, rep string, err
|
||||
myPart := types_3_4.Partition{
|
||||
Label: &label,
|
||||
Number: number,
|
||||
ShouldExist: &shouldExist,
|
||||
WipePartitionEntry: &wipe,
|
||||
ShouldExist: shouldExist.BoolPtr(),
|
||||
WipePartitionEntry: wipe.BoolPtr(),
|
||||
}
|
||||
if part.Guid != "" {
|
||||
myPart.GUID = &part.Guid
|
||||
}
|
||||
if part.Resize {
|
||||
myPart.Resize = &resize
|
||||
if part.Resize.Bool() {
|
||||
myPart.Resize = resize.BoolPtr()
|
||||
}
|
||||
if part.SizeMiB != "" {
|
||||
var size int
|
||||
@@ -202,7 +202,7 @@ func (node *Node) GetIgnitionStorage() (stor types_3_4.Storage, rep string, err
|
||||
disks = append(disks, types_3_4.Disk{
|
||||
Device: diskDev,
|
||||
Partitions: partitions,
|
||||
WipeTable: &wipe,
|
||||
WipeTable: wipe.BoolPtr(),
|
||||
})
|
||||
}
|
||||
stor = types_3_4.Storage{
|
||||
|
||||
@@ -33,6 +33,14 @@ func (val WWbool) Bool() bool {
|
||||
return bval
|
||||
}
|
||||
|
||||
/*
|
||||
Return a pointer to a bool
|
||||
*/
|
||||
func (val WWbool) BoolPtr() *bool {
|
||||
ret := val.Bool()
|
||||
return &ret
|
||||
}
|
||||
|
||||
func (val WWbool) BoolDefaultTrue() bool {
|
||||
str := strings.ToLower(string(val))
|
||||
if isUnsetValue(str) {
|
||||
@@ -89,3 +97,11 @@ var unsetValues = []string{"unset", "delete", "undef", "--", "nil", "0.0.0.0"}
|
||||
func isUnsetValue(value string) bool {
|
||||
return util.InSlice(unsetValues, strings.ToLower(value))
|
||||
}
|
||||
|
||||
/*
|
||||
Parse a string to a WWBool
|
||||
*/
|
||||
func Parse(in string) (ret WWbool) {
|
||||
ret.Set(in)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user