summaryrefslogtreecommitdiff
path: root/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'init.go')
-rw-r--r--init.go38
1 files changed, 22 insertions, 16 deletions
diff --git a/init.go b/init.go
index 49f04a0..f14b658 100644
--- a/init.go
+++ b/init.go
@@ -4,6 +4,7 @@ package forgepb
import (
"os"
+ "path/filepath"
"go.wit.com/lib/config"
"go.wit.com/lib/fhelp"
@@ -12,13 +13,14 @@ import (
)
/* better syntax from gin
+
Default returns an Engine instance with the Logger and Recovery middleware already attached.
func Default(opts ...OptionFunc) *Engine {
- debugPrintWARNINGDefault()
engine := New()
engine.Use(Logger(), Recovery())
return engine.With(opts...)
}
+
*/
func Init() *Forge {
@@ -58,6 +60,18 @@ func initFromConfig(cfg *ForgeConfigs) *Forge {
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 (?)
+ 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)
+ }
f.Repos = gitpb.NewRepos()
f.Repos.ConfigLoad(f.Config.ReposPB)
@@ -71,29 +85,22 @@ func initFromConfig(cfg *ForgeConfigs) *Forge {
return f
}
-/*
-func (f *Forge) InitMachine() {
- if f.Config.Username == "" {
- usr, _ := user.Current()
- f.Config.Username = usr.Username
- }
- f.hostname, _ = os.Hostname()
- // log.Info(hostname, err)
-}
-*/
-
func (f *Forge) SetConfigSave(b bool) {
- f.configSave = b
+ config.SetChanged("forge", b)
}
// saves the config if there have been changes
func (f *Forge) Exit() {
// log.Info("forge.configSave =", f.configSave)
- if f.configSave {
- f.ConfigSave()
+ if f.Config.Mode != ForgeMode_NORMAL {
+ fhelp.DumpENV("forge:")
+ f.Config.DumpENV()
}
+
+ f.ConfigSave()
if f.Repos != nil {
if config.HasChanged("repos") {
+ log.Info("TRYING FILENAME:", f.Config.ReposPB)
if err := f.Repos.ConfigSave(f.Config.ReposPB); err != nil {
log.Info("forge.Repos.ConfigSave() error", err)
}
@@ -116,7 +123,6 @@ func (f *Forge) setenv() {
log.Info("forge.Config() was nil")
os.Exit(-1)
}
- // f.configDir = os.Getenv("FORGE_CONFIG")
// f.forgeURL = os.Getenv("FORGE_URL")
f.hostname = os.Getenv("HOSTNAME")
if os.Getenv("FORGE_GOWORK") == "true" {