Files
warewulf/internal/pkg/config/buildconfig.go.in
Jonathon Anderson a80ba8ee01 Configure nodes.conf path dynamically from config
Removes the use of init() to initialize the variable.

- Closes: #1596
- See also: #1569

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-17 11:04:43 -07:00

85 lines
2.7 KiB
Go

package config
import (
"path"
"github.com/warewulf/warewulf/internal/pkg/util"
)
var ConfigFile = "@SYSCONFDIR@/warewulf/warewulf.conf"
type BuildConfig struct {
Bindir string `default:"@BINDIR@"`
Sysconfdir string `default:"@SYSCONFDIR@"`
Localstatedir string `default:"@LOCALSTATEDIR@"`
Cachedir string `default:"@CACHEDIR@"`
Ipxesource string `default:"@IPXESOURCE@"`
Srvdir string `default:"@SRVDIR@"`
Firewallddir string `default:"@FIREWALLDDIR@"`
Systemddir string `default:"@SYSTEMDDIR@"`
WWOverlaydir string `default:"@WWOVERLAYDIR@"`
WWChrootdir string `default:"@WWCHROOTDIR@"`
WWProvisiondir string `default:"@WWPROVISIONDIR@"`
WWClientdir string `default:"@WWCLIENTDIR@"`
}
const Version = "@VERSION@"
const Release = "@RELEASE@"
type TFTPConf struct {
EnabledP *bool `yaml:"enabled" default:"true"`
TftpRoot string `yaml:"tftproot,omitempty" default:"@TFTPDIR@"`
SystemdName string `yaml:"systemd name,omitempty" default:"tftp"`
IpxeBinaries map[string]string `yaml:"ipxe,omitempty" default:"{\"00:09\": \"ipxe-snponly-x86_64.efi\",\"00:00\": \"undionly.kpxe\",\"00:0B\": \"arm64-efi/snponly.efi\",\"00:07\": \"ipxe-snponly-x86_64.efi\"}"`
}
func (this TFTPConf) Enabled() bool {
return util.BoolP(this.EnabledP)
}
// WarewulfConf adds additional Warewulf-specific configuration to
// BaseConf.
type WarewulfConf struct {
Port int `yaml:"port,omitempty" default:"9873"`
SecureP *bool `yaml:"secure,omitempty" default:"true"`
UpdateInterval int `yaml:"update interval,omitempty" default:"60"`
AutobuildOverlaysP *bool `yaml:"autobuild overlays,omitempty" default:"true"`
EnableHostOverlayP *bool `yaml:"host overlay,omitempty" default:"true"`
SyslogP *bool `yaml:"syslog,omitempty" default:"false"`
DataStore string `yaml:"datastore,omitempty" default:"@DATADIR@"`
GrubBootP *bool `yaml:"grubboot,omitempty" default:"false"`
}
func (this WarewulfConf) Secure() bool {
return util.BoolP(this.SecureP)
}
func (this WarewulfConf) AutobuildOverlays() bool {
return util.BoolP(this.AutobuildOverlaysP)
}
func (this WarewulfConf) EnableHostOverlay() bool {
return util.BoolP(this.EnableHostOverlayP)
}
func (this WarewulfConf) Syslog() bool {
return util.BoolP(this.SyslogP)
}
func (this WarewulfConf) GrubBoot() bool {
return util.BoolP(this.GrubBootP)
}
func (paths BuildConfig) NodesConf() string {
return path.Join(paths.Sysconfdir, "warewulf", "nodes.conf")
}
func (paths BuildConfig) OciBlobCachedir() string {
return path.Join(paths.Cachedir, "warewulf")
}
func (paths BuildConfig) OverlayProvisiondir() string {
return path.Join(paths.WWProvisiondir, "overlays")
}