From e9d6e00ac675e7349be22120e4ff14920d2d4eee Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 26 Sep 2025 02:18:44 -0500 Subject: remove ENV stuff --- init.go | 62 ++++---------------------------------------------------------- 1 file changed, 4 insertions(+), 58 deletions(-) (limited to 'init.go') 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 { -- cgit v1.2.3