Since BaseConf.New could return a cached BaseConf, rather than always constructing a new struct, I've renamed it to Get to more accurately reflect its use. A new New() method is called by Get and always initializes a new struct. Signed-off-by: Jonathon Anderson <janderson@ciq.co>
69 lines
2.3 KiB
Go
69 lines
2.3 KiB
Go
package config
|
|
|
|
import (
|
|
"github.com/creasty/defaults"
|
|
)
|
|
|
|
type WarewulfConf struct {
|
|
Port int `yaml:"port" default:"9983"`
|
|
Secure bool `yaml:"secure" default:"true"`
|
|
UpdateInterval int `yaml:"update interval" default:"60"`
|
|
AutobuildOverlays bool `yaml:"autobuild overlays" default:"true"`
|
|
EnableHostOverlay bool `yaml:"host overlay" default:"true"`
|
|
Syslog bool `yaml:"syslog" default:"false"`
|
|
DataStore string `yaml:"datastore" default:"/var/lib/warewulf"`
|
|
}
|
|
|
|
type DhcpConf struct {
|
|
Enabled bool `yaml:"enabled" default:"true"`
|
|
Template string `yaml:"template" default:"default"`
|
|
RangeStart string `yaml:"range start,omitempty"`
|
|
RangeEnd string `yaml:"range end,omitempty"`
|
|
SystemdName string `yaml:"systemd name" default:"dhcpd"`
|
|
}
|
|
|
|
type TftpConf struct {
|
|
Enabled bool `yaml:"enabled" default:"true"`
|
|
TftpRoot string `yaml:"tftproot" default:"/var/lib/tftpboot"`
|
|
SystemdName string `yaml:"systemd name" default:"tftp"`
|
|
// Path is relative to buildconfig.DATADIR()
|
|
IpxeBinaries map[string]string `yaml:"ipxe" default:"{\"00:09\": \"x86_64.efi\",\"00:00\": \"x86_64.kpxe\",\"00:0B\": \"arm64.efi\",\"00:07\": \"x86_64.efi\"}"`
|
|
}
|
|
|
|
type NfsConf struct {
|
|
Enabled bool `yaml:"enabled" default:"true"`
|
|
ExportsExtended []*NfsExportConf `yaml:"export paths" default:"[]"`
|
|
SystemdName string `yaml:"systemd name" default:"nfsd"`
|
|
}
|
|
|
|
type NfsExportConf struct {
|
|
Path string `yaml:"path" default:"/dev/null"`
|
|
ExportOptions string `default:"rw,sync,no_subtree_check" yaml:"export options"`
|
|
MountOptions string `default:"defaults" yaml:"mount options"`
|
|
Mount bool `default:"true" yaml:"mount"`
|
|
}
|
|
|
|
/*
|
|
Describe a mount point for a container exec
|
|
*/
|
|
type MountEntry struct {
|
|
Source string `yaml:"source" default:"/etc/resolv.conf"`
|
|
Dest string `yaml:"dest,omitempty" default:"/etc/resolv.conf"`
|
|
ReadOnly bool `yaml:"readonly,omitempty" default:"false"`
|
|
Options string `yaml:"options,omitempty"` // ignored at the moment
|
|
}
|
|
|
|
func (s *NfsConf) Unmarshal(unmarshal func(interface{}) error) error {
|
|
if err := defaults.Set(s); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Waste processor cycles to make code more readable
|
|
|
|
func DataStore() string {
|
|
_ = Get()
|
|
return cachedConf.Warewulf.DataStore
|
|
}
|