summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.go9
-rw-r--r--init.go62
2 files changed, 4 insertions, 67 deletions
diff --git a/config.go b/config.go
index fd2f94e..cff71be 100644
--- a/config.go
+++ b/config.go
@@ -3,8 +3,6 @@
package forgepb
import (
- "os"
-
"go.wit.com/lib/config"
"go.wit.com/lib/gui/prep"
"go.wit.com/log"
@@ -65,10 +63,6 @@ func (cfg *ForgeConfigs) DumpENV() {
}
log.Infof("CfgPB.Mode = %s\n", cfg.Mode)
// log.Infof("CfgPB.Hostname=%s\n", cfg.Hostname)
-
- if cfg.ReposPB != os.Getenv("FORGE_REPOSPB") {
- log.Infof("CfgPB file problem: cfg.ReposPB=%s != FORGE_REPOSPB=%s\n", cfg.ReposPB, os.Getenv("FORGE_REPOSPB"))
- }
}
/*
@@ -81,6 +75,3 @@ func (cfg *ForgeConfigs) DumpENV() {
f.SetConfigSave(true)
}
*/
-
-func (cfg *ForgeConfigs) InitDefaults() {
-}
diff --git a/init.go b/init.go
index e2491e7..463ac27 100644
--- a/init.go
+++ b/init.go
@@ -30,12 +30,10 @@ func Init() *Forge {
err := config.ConfigLoad(cfg, "forge", "forge")
f.Config = cfg
if err != nil {
- // fhelp.DumpENV("finit:")
f.setenv()
if !fhelp.QuestionUser("This is your first time using forge, use these default values?") {
os.Exit(-1)
}
- f.Config.InitDefaults()
f.Config.ConfigSave()
f.initFromConfig()
f.Config.DumpENV()
@@ -49,7 +47,6 @@ func Init() *Forge {
f.initFromConfig()
if f.Config.Mode == ForgeMode_MASTER {
log.Printf("forge.Init() %s len()=%d\n", f.Config.Filename, f.Repos.Len())
- // fhelp.DumpENV("finit:")
f.Config.DumpENV()
}
return f
@@ -75,15 +72,7 @@ func (f *Forge) initFromConfig() {
log.Info("ENV changed config. todo: save config here")
f.Config.ConfigSave()
}
- if f.Config.ReposPB != os.Getenv("FORGE_REPOSPB") {
- // if different, use the ENV var
- // this probably means that it gets saved as the default in the config
- // we probably want that (?)
- log.Info("WARN: override ReposPB", f.Config.ReposPB, os.Getenv("FORGE_REPOSPB"))
- f.Config.ReposPB = os.Getenv("FORGE_REPOSPB")
- }
if _, s := filepath.Split(f.Config.ReposPB); s != "repos.pb" {
- fhelp.DumpENV("forge:")
f.Config.DumpENV()
log.Infof("ReposPB invalid filename '%s'\n", f.Config.ReposPB)
os.Exit(-1)
@@ -110,13 +99,6 @@ func (f *Forge) SetConfigSave(b bool) {
// saves the config if there have been changes
func (f *Forge) Exit() {
- // log.Info("forge.configSave =", f.configSave)
- if f.Config.Mode == ForgeMode_MASTER {
- // fhelp.DumpENV("forge:")
- // f.Config.DumpENV()
- // todo: tell the user to switch to NORMAL mode
- }
-
f.ConfigSave()
if f.Repos != nil {
if config.HasChanged("repos") {
@@ -135,25 +117,10 @@ func (f *Forge) Exit() {
func (f *Forge) setenv() {
f.once.Do(func() {
log.Info("doing setenv()")
- if err := fhelp.ConfigureENV(); err != nil {
- log.Info("forge ConfigureENV() failed", err)
- os.Exit(-1)
- }
if f.Config == nil {
log.Info("forge.Config() was nil")
os.Exit(-1)
}
- // f.forgeURL = os.Getenv("FORGE_URL")
- f.hostname = os.Getenv("HOSTNAME")
- if os.Getenv("FORGE_GOWORK") == "true" {
- f.goWork = true
- }
-
- f.Config.ReposPB = os.Getenv("FORGE_REPOSPB")
- f.Config.ReposDir = os.Getenv("FORGE_REPOSDIR")
- f.Config.PatchDir = os.Getenv("FORGE_PATCHDIR")
- f.Config.ForgeURL = os.Getenv("FORGE_URL")
- fhelp.DumpENV("setenv end()")
})
}
@@ -180,32 +147,11 @@ func (f *Forge) SetForgeURL(url string) {
func (f *Forge) configENV() bool {
var changed bool
f.once.Do(func() {
- if err := fhelp.ConfigureENV(); err != nil {
- log.Info("forge ConfigureENV() failed", err)
- os.Exit(-1)
- }
- if os.Getenv("FORGE_REPOPB") != "" && f.Config.ReposPB != os.Getenv("FORGE_REPOPB") {
- log.Info("ENV: updating FORGE_REPOSPB from", f.Config.ReposPB, "to", os.Getenv("FORGE_REPOPB"))
- f.Config.ReposPB = os.Getenv("FORGE_REPOPB")
- changed = true
- }
-
- if os.Getenv("FORGE_GOSRC") != "" && f.Config.ReposDir != os.Getenv("FORGE_GOSRC") {
- log.Info("ENV: updating FORGE_GOSRC from", f.Config.ReposDir, "to", os.Getenv("FORGE_GOSRC"))
- f.Config.ReposDir = os.Getenv("FORGE_GOSRC")
- changed = true
+ if os.Getenv("FORGE_URL") != "" {
+ f.Config.ForgeURL = os.Getenv("FORGE_URL")
}
-
- if os.Getenv("FORGE_PATCHDIR") != "" && f.Config.PatchDir != os.Getenv("FORGE_PATCHDIR") {
- log.Info("ENV: updating FORGE_PATCHDIR from", f.Config.PatchDir, "to", os.Getenv("FORGE_PATCHDIRC"))
- f.Config.PatchDir = os.Getenv("FORGE_PATCHDIR")
- changed = true
- }
-
- f.Config.ForgeURL = os.Getenv("FORGE_URL")
- f.hostname = os.Getenv("HOSTNAME")
- if os.Getenv("FORGE_GOWORK") == "true" {
- f.goWork = true
+ if f.hostname == "" {
+ f.hostname, _ = os.Hostname()
}
})
if changed {