removed getters as configs must exportable
Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
3
.github/workflows/lint.yaml
vendored
3
.github/workflows/lint.yaml
vendored
@@ -21,7 +21,8 @@ jobs:
|
|||||||
go: [ '1.17' ]
|
go: [ '1.17' ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- name: Create config
|
||||||
|
run: make config
|
||||||
- name: Setup go ${{ matrix.go }}
|
- name: Setup go ${{ matrix.go }}
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
3
Makefile
3
Makefile
@@ -101,7 +101,7 @@ export GOPROXY
|
|||||||
WW_GO_BUILD_TAGS := containers_image_openpgp containers_image_ostree
|
WW_GO_BUILD_TAGS := containers_image_openpgp containers_image_ostree
|
||||||
|
|
||||||
# Default target
|
# Default target
|
||||||
all: config vendor wwctl wwclient man_pages config_defaults wwapid wwapic wwapird
|
all: config vendor wwctl wwclient man_pages wwapid wwapic wwapird
|
||||||
|
|
||||||
# Validate source and build all packages
|
# Validate source and build all packages
|
||||||
build: lint test-it vet all
|
build: lint test-it vet all
|
||||||
@@ -287,7 +287,6 @@ contclean:
|
|||||||
rm -f config
|
rm -f config
|
||||||
rm -f Defaults.mk
|
rm -f Defaults.mk
|
||||||
rm -rf $(TOOLS_DIR)
|
rm -rf $(TOOLS_DIR)
|
||||||
rm -f config_defaults
|
|
||||||
rm -f update_configuration
|
rm -f update_configuration
|
||||||
rm -f etc/wwapi{c,d,rd}.conf
|
rm -f etc/wwapi{c,d,rd}.conf
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func main() {
|
|||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
|
|
||||||
// Read the config file.
|
// Read the config file.
|
||||||
config, err := apiconfig.NewClient(path.Join(conf.SYSCONFDIR(), "warewulf/wwapic.conf"))
|
config, err := apiconfig.NewClient(path.Join(conf.Paths.Sysconfdir, "warewulf/wwapic.conf"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("err: %v", err)
|
log.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func main() {
|
|||||||
|
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
// Read the config file.
|
// Read the config file.
|
||||||
config, err := apiconfig.NewServer(path.Join(conf.SYSCONFDIR(), "warewulf/wwapid.conf"))
|
config, err := apiconfig.NewServer(path.Join(conf.Paths.Sysconfdir, "warewulf/wwapid.conf"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("err: %v", err)
|
log.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func run() error {
|
|||||||
|
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
// Read the config file.
|
// Read the config file.
|
||||||
config, err := apiconfig.NewClientServer(path.Join(conf.SYSCONFDIR(), "warewulf/wwapird.conf"))
|
config, err := apiconfig.NewClientServer(path.Join(conf.Paths.Sysconfdir, "warewulf/wwapird.conf"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Failed to read config file, err: %v", err)
|
glog.Fatalf("Failed to read config file, err: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
return errors.New("found pidfile " + PIDFile + " not starting")
|
return errors.New("found pidfile " + PIDFile + " not starting")
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Args[0] == path.Join(conf.WWCLIENTDIR(), "wwclient") {
|
if os.Args[0] == path.Join(conf.Paths.WWClientdir, "wwclient") {
|
||||||
err := os.Chdir("/")
|
err := os.Chdir("/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Error("failed to change dir: %s", err)
|
wwlog.Error("failed to change dir: %s", err)
|
||||||
@@ -70,7 +70,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Printf("Called via: %s\n", os.Args[0])
|
fmt.Printf("Called via: %s\n", os.Args[0])
|
||||||
fmt.Printf("Runtime overlay is being put in '/warewulf/wwclient-test' rather than '/'\n")
|
fmt.Printf("Runtime overlay is being put in '/warewulf/wwclient-test' rather than '/'\n")
|
||||||
fmt.Printf("For full functionality call with: %s\n", path.Join(conf.WWCLIENTDIR(), "wwclient"))
|
fmt.Printf("For full functionality call with: %s\n", path.Join(conf.Paths.WWClientdir, "wwclient"))
|
||||||
err := os.MkdirAll("/warewulf/wwclient-test", 0755)
|
err := os.MkdirAll("/warewulf/wwclient-test", 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Error("failed to create dir: %s", err)
|
wwlog.Error("failed to create dir: %s", err)
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ func SSH() error {
|
|||||||
if os.Getuid() == 0 {
|
if os.Getuid() == 0 {
|
||||||
fmt.Printf("Updating system keys\n")
|
fmt.Printf("Updating system keys\n")
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
wwkeydir := path.Join(conf.SYSCONFDIR(), "warewulf/keys") + "/"
|
wwkeydir := path.Join(conf.Paths.Sysconfdir, "warewulf/keys") + "/"
|
||||||
|
|
||||||
err := os.MkdirAll(path.Join(conf.SYSCONFDIR(), "warewulf/keys"), 0755)
|
err := os.MkdirAll(path.Join(conf.Paths.Sysconfdir, "warewulf/keys"), 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Error("Could not create base directory: %s", err)
|
wwlog.Error("Could not create base directory: %s", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
func TFTP() error {
|
func TFTP() error {
|
||||||
controller := warewulfconf.New()
|
controller := warewulfconf.New()
|
||||||
var tftpdir string = path.Join(controller.TFTPDIR(), "warewulf")
|
var tftpdir string = path.Join(controller.Paths.Tftpdir, "warewulf")
|
||||||
|
|
||||||
err := os.MkdirAll(tftpdir, 0755)
|
err := os.MkdirAll(tftpdir, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -27,7 +27,7 @@ func TFTP() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
copyCheck[f] = true
|
copyCheck[f] = true
|
||||||
err = util.SafeCopyFile(path.Join(controller.DATADIR(), f), path.Join(tftpdir, f))
|
err = util.SafeCopyFile(path.Join(controller.Paths.Datadir, f), path.Join(tftpdir, f))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Warn("ipxe binary could not be copied, booting may not work: %s", err)
|
wwlog.Warn("ipxe binary could not be copied, booting may not work: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func SourceParentDir() string {
|
func SourceParentDir() string {
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
return conf.WWCHROOTDIR()
|
return conf.Paths.WWChrootdir
|
||||||
}
|
}
|
||||||
|
|
||||||
func SourceDir(name string) string {
|
func SourceDir(name string) string {
|
||||||
@@ -21,7 +21,7 @@ func RootFsDir(name string) string {
|
|||||||
|
|
||||||
func ImageParentDir() string {
|
func ImageParentDir() string {
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
return path.Join(conf.WWPROVISIONDIR(), "container/")
|
return path.Join(conf.Paths.WWProvisiondir, "container/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImageFile(name string) string {
|
func ImageFile(name string) string {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ var (
|
|||||||
|
|
||||||
func KernelImageTopDir() string {
|
func KernelImageTopDir() string {
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
return path.Join(conf.WWPROVISIONDIR(), "kernel")
|
return path.Join(conf.Paths.WWProvisiondir, "kernel")
|
||||||
}
|
}
|
||||||
|
|
||||||
func KernelImage(kernelName string) string {
|
func KernelImage(kernelName string) string {
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ defaultnode:
|
|||||||
func init() {
|
func init() {
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
if ConfigFile == "" {
|
if ConfigFile == "" {
|
||||||
ConfigFile = path.Join(conf.SYSCONFDIR(), "warewulf/nodes.conf")
|
ConfigFile = path.Join(conf.Paths.Sysconfdir, "warewulf/nodes.conf")
|
||||||
}
|
}
|
||||||
if DefaultConfig == "" {
|
if DefaultConfig == "" {
|
||||||
DefaultConfig = path.Join(conf.SYSCONFDIR(), "warewulf/defaults.conf")
|
DefaultConfig = path.Join(conf.Paths.Sysconfdir, "warewulf/defaults.conf")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
func OverlaySourceTopDir() string {
|
func OverlaySourceTopDir() string {
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
return conf.WWOVERLAYDIR()
|
return conf.Paths.WWOverlaydir
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -32,5 +32,5 @@ Returns the overlay name of the image for a given node
|
|||||||
*/
|
*/
|
||||||
func OverlayImage(nodeName string, overlayName []string) string {
|
func OverlayImage(nodeName string, overlayName []string) string {
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
return path.Join(conf.WWPROVISIONDIR(), "overlays/", nodeName, strings.Join(overlayName, "-")+".img")
|
return path.Join(conf.Paths.WWProvisiondir, "overlays/", nodeName, strings.Join(overlayName, "-")+".img")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,12 @@ import (
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Reads a file file from the host fs. If the file has nor '/' prefix
|
Reads a file file from the host fs. If the file has nor '/' prefix
|
||||||
the path is relative to SYSCONFDIR.
|
the path is relative to Paths.SysconfdirTemplates in the file are no evaluated.
|
||||||
Templates in the file are no evaluated.
|
|
||||||
*/
|
*/
|
||||||
func templateFileInclude(inc string) string {
|
func templateFileInclude(inc string) string {
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
if !strings.HasPrefix(inc, "/") {
|
if !strings.HasPrefix(inc, "/") {
|
||||||
inc = path.Join(conf.SYSCONFDIR(), "warewulf", inc)
|
inc = path.Join(conf.Paths.Sysconfdir, "warewulf", inc)
|
||||||
}
|
}
|
||||||
wwlog.Debug("Including file into template: %s", inc)
|
wwlog.Debug("Including file into template: %s", inc)
|
||||||
content, err := os.ReadFile(inc)
|
content, err := os.ReadFile(inc)
|
||||||
@@ -38,7 +37,7 @@ Templates in the file are no evaluated.
|
|||||||
func templateFileBlock(inc string, abortStr string) (string, error) {
|
func templateFileBlock(inc string, abortStr string) (string, error) {
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
if !strings.HasPrefix(inc, "/") {
|
if !strings.HasPrefix(inc, "/") {
|
||||||
inc = path.Join(conf.SYSCONFDIR(), "warewulf", inc)
|
inc = path.Join(conf.Paths.Sysconfdir, "warewulf", inc)
|
||||||
}
|
}
|
||||||
wwlog.Debug("Including file block into template: %s", inc)
|
wwlog.Debug("Including file block into template: %s", inc)
|
||||||
readFile, err := os.Open(inc)
|
readFile, err := os.Open(inc)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Return the version of wwctl
|
|||||||
*/
|
*/
|
||||||
func GetVersion() string {
|
func GetVersion() string {
|
||||||
conf := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
return fmt.Sprintf("%s-%s", conf.VERSION(), conf.RELEASE())
|
return fmt.Sprintf("%s-%s", conf.Paths.Version, conf.Paths.Release)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ type BuildConfig struct {
|
|||||||
Tftpdir string `default:"@TFTPDIR@"`
|
Tftpdir string `default:"@TFTPDIR@"`
|
||||||
Firewallddir string `default:"@FIREWALLDDIR@"`
|
Firewallddir string `default:"@FIREWALLDDIR@"`
|
||||||
Systemddir string `default:"@SYSTEMDDIR@"`
|
Systemddir string `default:"@SYSTEMDDIR@"`
|
||||||
Wwoverlaydir string `default:"@WWOVERLAYDIR@"`
|
WWOverlaydir string `default:"@WWOVERLAYDIR@"`
|
||||||
Wwchrootdir string `default:"@WWCHROOTDIR@"`
|
WWChrootdir string `default:"@WWCHROOTDIR@"`
|
||||||
Wwprovisiondir string `default:"@WWPROVISIONDIR@"`
|
WWProvisiondir string `default:"@WWPROVISIONDIR@"`
|
||||||
Version string `default:"@VERSION@"`
|
Version string `default:"@VERSION@"`
|
||||||
Release string `default:"@RELEASE@"`
|
Release string `default:"@RELEASE@"`
|
||||||
Wwclientdir string `default:"@WWCLIENTDIR@"`
|
WWClientdir string `default:"@WWCLIENTDIR@"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
package warewulfconf
|
|
||||||
|
|
||||||
import "github.com/hpcng/warewulf/internal/pkg/wwlog"
|
|
||||||
|
|
||||||
func (conf *ControllerConf) BINDIR() string {
|
|
||||||
wwlog.Debug("BINDIR = '%s'", conf.Paths.Bindir)
|
|
||||||
return conf.Paths.Bindir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) DATADIR() string {
|
|
||||||
wwlog.Debug("DATADIR = '%s'", conf.Paths.Datadir)
|
|
||||||
return conf.Paths.Datadir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) SYSCONFDIR() string {
|
|
||||||
wwlog.Debug("SYSCONFDIR = '%s'", conf.Paths.Sysconfdir)
|
|
||||||
return conf.Paths.Sysconfdir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) LOCALSTATEDIR() string {
|
|
||||||
wwlog.Debug("LOCALSTATEDIR = '%s'", conf.Paths.Localstatedir)
|
|
||||||
return conf.Paths.Localstatedir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) SRVDIR() string {
|
|
||||||
wwlog.Debug("SRVDIR = '%s'", conf.Paths.Srvdir)
|
|
||||||
return conf.Paths.Srvdir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) TFTPDIR() string {
|
|
||||||
wwlog.Debug("TFTPDIR = '%s'", conf.Paths.Tftpdir)
|
|
||||||
return conf.Paths.Tftpdir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) FIREWALLDDIR() string {
|
|
||||||
wwlog.Debug("FIREWALLDDIR = '%s'", conf.Paths.Firewallddir)
|
|
||||||
return conf.Paths.Firewallddir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) SYSTEMDDIR() string {
|
|
||||||
wwlog.Debug("SYSTEMDDIR = '%s'", conf.Paths.Systemddir)
|
|
||||||
return conf.Paths.Systemddir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) WWOVERLAYDIR() string {
|
|
||||||
wwlog.Debug("WWOVERLAYDIR = '%s'", conf.Paths.Wwoverlaydir)
|
|
||||||
return conf.Paths.Wwoverlaydir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) WWCHROOTDIR() string {
|
|
||||||
wwlog.Debug("WWCHROOTDIR = '%s'", conf.Paths.Wwchrootdir)
|
|
||||||
return conf.Paths.Wwchrootdir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) WWPROVISIONDIR() string {
|
|
||||||
wwlog.Debug("WWPROVISIONDIR = '%s'", conf.Paths.Wwprovisiondir)
|
|
||||||
return conf.Paths.Wwprovisiondir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) VERSION() string {
|
|
||||||
wwlog.Debug("VERSION = '%s'", conf.Paths.Version)
|
|
||||||
return conf.Paths.Version
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) RELEASE() string {
|
|
||||||
wwlog.Debug("RELEASE = '%s'", conf.Paths.Release)
|
|
||||||
return conf.Paths.Release
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conf *ControllerConf) WWCLIENTDIR() string {
|
|
||||||
wwlog.Debug("WWCLIENTDIR = '%s'", conf.Paths.Wwclientdir)
|
|
||||||
return conf.Paths.Wwclientdir
|
|
||||||
}
|
|
||||||
@@ -79,13 +79,13 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
|
|||||||
if !node.Id.Defined() {
|
if !node.Id.Defined() {
|
||||||
wwlog.Error("%s (unknown/unconfigured node)", rinfo.hwaddr)
|
wwlog.Error("%s (unknown/unconfigured node)", rinfo.hwaddr)
|
||||||
if rinfo.stage == "ipxe" {
|
if rinfo.stage == "ipxe" {
|
||||||
stage_file = path.Join(conf.SYSCONFDIR(), "/warewulf/ipxe/unconfigured.ipxe")
|
stage_file = path.Join(conf.Paths.Sysconfdir, "/warewulf/ipxe/unconfigured.ipxe")
|
||||||
tmpl_data = iPxeTemplate{
|
tmpl_data = iPxeTemplate{
|
||||||
Hwaddr: rinfo.hwaddr}
|
Hwaddr: rinfo.hwaddr}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if rinfo.stage == "ipxe" {
|
} else if rinfo.stage == "ipxe" {
|
||||||
stage_file = path.Join(conf.SYSCONFDIR(), "warewulf/ipxe/"+node.Ipxe.Get()+".ipxe")
|
stage_file = path.Join(conf.Paths.Sysconfdir, "warewulf/ipxe/"+node.Ipxe.Get()+".ipxe")
|
||||||
tmpl_data = iPxeTemplate{
|
tmpl_data = iPxeTemplate{
|
||||||
Id: node.Id.Get(),
|
Id: node.Id.Get(),
|
||||||
Cluster: node.ClusterName.Get(),
|
Cluster: node.ClusterName.Get(),
|
||||||
|
|||||||
Reference in New Issue
Block a user