Files
warewulf/internal/pkg/config/buildconfig.go.in
2026-03-09 21:34:40 -06:00

98 lines
3.5 KiB
Go

package config
import (
"github.com/warewulf/warewulf/internal/pkg/util"
"path"
)
var ConfigFile = "@SYSCONFDIR@/warewulf/warewulf.conf"
type BuildConfig struct {
Bindir string `yaml:"bindir,omitempty" default:"@BINDIR@"`
Sysconfdir string `yaml:"sysconfdir,omitempty" default:"@SYSCONFDIR@"`
Localstatedir string `yaml:"localstatedir,omitempty" default:"@LOCALSTATEDIR@"`
Cachedir string `yaml:"cachedir,omitempty" default:"@CACHEDIR@"`
Ipxesource string `yaml:"ipxesource,omitempty" default:"@IPXESOURCE@"`
Srvdir string `yaml:"srvdir,omitempty" default:"@SRVDIR@"`
Firewallddir string `yaml:"firewallddir,omitempty" default:"@FIREWALLDDIR@"`
Systemddir string `yaml:"systemddir,omitempty" default:"@SYSTEMDDIR@"`
Datadir string `yaml:"datadir,omitempty" default:"@DATADIR@"`
WWOverlaydir string `yaml:"wwoverlaydir,omitempty" default:"@WWOVERLAYDIR@"`
WWChrootdir string `yaml:"wwchrootdir,omitempty" default:"@WWCHROOTDIR@"`
WWProvisiondir string `yaml:"wwprovisiondir,omitempty" default:"@WWPROVISIONDIR@"`
WWClientdir string `yaml:"wwclientdir,omitempty" 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 (conf TFTPConf) Enabled() bool {
return util.BoolP(conf.EnabledP)
}
// WarewulfConf adds additional Warewulf-specific configuration to
// BaseConf.
type WarewulfConf struct {
Port int `yaml:"port,omitempty" default:"9873"`
SecurePort int `yaml:"secure port,omitempty" default:"9874"`
SecureP *bool `yaml:"secure,omitempty" default:"true"`
EnableTLSP *bool `yaml:"tls,omitempty" default:"false"`
UpdateInterval int `yaml:"update interval,omitempty" default:"60"`
AutobuildOverlaysP *bool `yaml:"autobuild overlays,omitempty" default:"true"`
EnableHostOverlayP *bool `yaml:"host overlay,omitempty" default:"true"`
GrubBootP *bool `yaml:"grubboot,omitempty" default:"false"`
SystemdName string `yaml:"systemd name,omitempty"`
}
func (conf WarewulfConf) Secure() bool {
return util.BoolP(conf.SecureP)
}
func (conf WarewulfConf) EnableTLS() bool {
return util.BoolP(conf.EnableTLSP)
}
func (conf WarewulfConf) AutobuildOverlays() bool {
return util.BoolP(conf.AutobuildOverlaysP)
}
func (conf WarewulfConf) EnableHostOverlay() bool {
return util.BoolP(conf.EnableHostOverlayP)
}
func (conf WarewulfConf) GrubBoot() bool {
return util.BoolP(conf.GrubBootP)
}
func (paths BuildConfig) NodesConf() string {
return path.Join(paths.Sysconfdir, "warewulf", "nodes.conf")
}
func (paths BuildConfig) AuthenticationConf() string {
return path.Join(paths.Sysconfdir, "warewulf", "auth.conf")
}
func (paths BuildConfig) OciBlobCachedir() string {
return path.Join(paths.Cachedir, "warewulf")
}
func (paths BuildConfig) SiteOverlaydir() string {
return paths.WWOverlaydir
}
func (paths BuildConfig) DistributionOverlaydir() string {
return path.Join(paths.Datadir, "warewulf", "overlays")
}
func (paths BuildConfig) OverlayProvisiondir() string {
return path.Join(paths.WWProvisiondir, "overlays")
}