diff --git a/cmd/update_configuration/update_configuration.go b/cmd/update_configuration/update_configuration.go index c64de182..728eaaf6 100644 --- a/cmd/update_configuration/update_configuration.go +++ b/cmd/update_configuration/update_configuration.go @@ -8,7 +8,6 @@ import ( "github.com/hpcng/warewulf/cmd/update_configuration/vers42" "github.com/hpcng/warewulf/cmd/update_configuration/vers43" - "github.com/hpcng/warewulf/internal/pkg/buildconfig" "github.com/hpcng/warewulf/internal/pkg/util" "gopkg.in/yaml.v2" ) @@ -125,7 +124,7 @@ func main() { var endVers int var startVers int flag.StringVar(&confFile, "f", "", "Config file for update") - flag.IntVar(&endVers, "e", buildconfig.WWVer, "Final version of configuration file") + flag.IntVar(&endVers, "e", 0, "Final version of configuration file") flag.IntVar(&startVers, "s", 0, "Start version of configuration file, 0 is for autodetection") flag.BoolVar(&nowrite, "n", false, "Do not write, just print new conf to terminal") flag.BoolVar(&quiet, "q", false, "Do not print what the program is doing") diff --git a/internal/app/api/wwapic/wwapic.go b/internal/app/api/wwapic/wwapic.go index 65cd85b5..bd35a973 100644 --- a/internal/app/api/wwapic/wwapic.go +++ b/internal/app/api/wwapic/wwapic.go @@ -12,7 +12,7 @@ import ( "github.com/hpcng/warewulf/internal/pkg/api/apiconfig" "github.com/hpcng/warewulf/internal/pkg/api/routes/wwapiv1" - "github.com/hpcng/warewulf/internal/pkg/buildconfig" + "github.com/hpcng/warewulf/internal/pkg/warewulfconf" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -24,9 +24,10 @@ import ( func main() { log.Println("Client running") + conf := warewulfconf.New() // Read the config file. - config, err := apiconfig.NewClient(path.Join(buildconfig.SYSCONFDIR(), "warewulf/wwapic.conf")) + config, err := apiconfig.NewClient(path.Join(conf.SYSCONFDIR(), "warewulf/wwapic.conf")) if err != nil { log.Fatalf("err: %v", err) } diff --git a/internal/app/api/wwapid/wwapid.go b/internal/app/api/wwapid/wwapid.go index 1cea854f..0678114c 100644 --- a/internal/app/api/wwapid/wwapid.go +++ b/internal/app/api/wwapid/wwapid.go @@ -15,8 +15,8 @@ import ( "github.com/hpcng/warewulf/internal/pkg/api/container" apinode "github.com/hpcng/warewulf/internal/pkg/api/node" "github.com/hpcng/warewulf/internal/pkg/api/routes/wwapiv1" - "github.com/hpcng/warewulf/internal/pkg/buildconfig" "github.com/hpcng/warewulf/internal/pkg/version" + "github.com/hpcng/warewulf/internal/pkg/warewulfconf" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" @@ -34,8 +34,9 @@ var apiVersion string func main() { log.Println("Server running") + conf := warewulfconf.New() // Read the config file. - config, err := apiconfig.NewServer(path.Join(buildconfig.SYSCONFDIR(), "warewulf/wwapid.conf")) + config, err := apiconfig.NewServer(path.Join(conf.SYSCONFDIR(), "warewulf/wwapid.conf")) if err != nil { log.Fatalf("err: %v", err) } diff --git a/internal/app/api/wwapird/wwapird.go b/internal/app/api/wwapird/wwapird.go index dcbaecf1..13f12d4e 100644 --- a/internal/app/api/wwapird/wwapird.go +++ b/internal/app/api/wwapird/wwapird.go @@ -18,20 +18,20 @@ import ( "google.golang.org/grpc/credentials/insecure" "github.com/hpcng/warewulf/internal/pkg/api/apiconfig" + "github.com/hpcng/warewulf/internal/pkg/warewulfconf" gw "github.com/hpcng/warewulf/internal/pkg/api/routes/wwapiv1" "path" - - "github.com/hpcng/warewulf/internal/pkg/buildconfig" ) func run() error { log.Println("test0") + conf := warewulfconf.New() // Read the config file. - config, err := apiconfig.NewClientServer(path.Join(buildconfig.SYSCONFDIR(), "warewulf/wwapird.conf")) + config, err := apiconfig.NewClientServer(path.Join(conf.SYSCONFDIR(), "warewulf/wwapird.conf")) if err != nil { glog.Fatalf("Failed to read config file, err: %v", err) } diff --git a/internal/app/wwclient/root.go b/internal/app/wwclient/root.go index e657c21b..72691595 100644 --- a/internal/app/wwclient/root.go +++ b/internal/app/wwclient/root.go @@ -58,7 +58,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { return errors.New("found pidfile " + PIDFile + " not starting") } - if os.Args[0] == path.Join(buildconfig.WWCLIENTDIR(), "wwclient") { + if os.Args[0] == path.Join(conf.WWCLIENTDIR(), "wwclient") { err := os.Chdir("/") if err != nil { wwlog.Error("failed to change dir: %s", err) @@ -70,7 +70,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } else { 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("For full functionality call with: %s\n", path.Join(buildconfig.WWCLIENTDIR(), "wwclient")) + fmt.Printf("For full functionality call with: %s\n", path.Join(conf.WWCLIENTDIR(), "wwclient")) err := os.MkdirAll("/warewulf/wwclient-test", 0755) if err != nil { wwlog.Error("failed to create dir: %s", err) diff --git a/internal/app/wwctl/root.go b/internal/app/wwctl/root.go index f40e859d..a59a9739 100644 --- a/internal/app/wwctl/root.go +++ b/internal/app/wwctl/root.go @@ -63,7 +63,7 @@ func GetRootCommand() *cobra.Command { return rootCmd } -func rootPersistentPreRunE(cmd *cobra.Command, args []string) error { +func rootPersistentPreRunE(cmd *cobra.Command, args []string) (err error) { if DebugFlag { wwlog.SetLogLevel(wwlog.DEBUG) } else if verboseArg { @@ -76,9 +76,9 @@ func rootPersistentPreRunE(cmd *cobra.Command, args []string) error { } conf := warewulfconf.New() if WarewulfConfArg != "" { - conf.ReadConf(WarewulfConfArg) + err = conf.ReadConf(WarewulfConfArg) } else if os.Getenv("WAREWULFCONF") != "" { - conf.ReadConf(os.Getenv("WAREWULFCONF")) + err = conf.ReadConf(os.Getenv("WAREWULFCONF")) } - return nil + return } diff --git a/internal/pkg/warewulfconf/constructors.go b/internal/pkg/warewulfconf/constructors.go index 0b01e760..f7cfc325 100644 --- a/internal/pkg/warewulfconf/constructors.go +++ b/internal/pkg/warewulfconf/constructors.go @@ -30,7 +30,7 @@ func New() (ret ControllerConf) { ret.Nfs = new(NfsConf) ret.Paths = new(BuildConfig) _ = defaults.Set(&ret) - ret.setDynamicDefaults() + _ = ret.setDynamicDefaults() cachedConf = ret cachedConf.current = true