Răsfoiți Sursa

better version error handling

reid 2 ani în urmă
părinte
comite
02aa1bdda1
3 a modificat fișierele cu 18 adăugiri și 13 ștergeri
  1. 12 11
      config/config.go
  2. 1 1
      config/version.go
  3. 5 1
      main.go

+ 12 - 11
config/config.go

@@ -1,4 +1,5 @@
 package config
+
 // code for managing groundseg and container configurations
 
 import (
@@ -17,25 +18,25 @@ import (
 )
 
 var (
-	logger         = slog.New(slog.NewJSONHandler(os.Stdout, nil))
+	logger = slog.New(slog.NewJSONHandler(os.Stdout, nil))
 	// global settings config (accessed via funcs)
-	globalConfig   structs.SysConfig
+	globalConfig structs.SysConfig
 	// base path for installation (override default with env var)
-	BasePath       = os.Getenv("GS_BASE_PATH")
+	BasePath = os.Getenv("GS_BASE_PATH")
 	// only amd64 or arm64
-	Architecture   = getArchitecture()
+	Architecture = getArchitecture()
 	// struct of /retrieve blob
 	StartramConfig structs.StartramRetrieve
 	// unused for now, set with `./groundseg dev`
-	DebugMode      = false
-	Ready          = false
+	DebugMode = false
+	Ready     = false
 	// representation of desired/actual container states
-	GSContainers   = make(map[string]structs.ContainerState)
+	GSContainers = make(map[string]structs.ContainerState)
 	// version server check
-	checkInterval  = 5 * time.Minute
-	confMutex      sync.Mutex
-	contMutex      sync.Mutex
-	versMutex      sync.Mutex
+	checkInterval = 5 * time.Minute
+	confMutex     sync.Mutex
+	contMutex     sync.Mutex
+	versMutex     sync.Mutex
 )
 
 // try initializing from system.json on disk

+ 1 - 1
config/version.go

@@ -154,4 +154,4 @@ func LocalVersion() structs.Version {
 		panic(errmsg)
 	}
 	return versionStruct
-}
+}

+ 5 - 1
main.go

@@ -84,7 +84,7 @@ func main() {
 	if conf.WgRegistered == true {
 		_, err := startram.Retrieve()
 		if err != nil {
-			logger.Warn(fmt.Sprintf("Could not retrieve StarTram/Anchor config: %v",err))
+			logger.Warn(fmt.Sprintf("Could not retrieve StarTram/Anchor config: %v", err))
 		}
 	}
 	// block until version info returns
@@ -94,6 +94,10 @@ func main() {
 			logger.Info("Version info retrieved")
 		case <-time.After(10 * time.Second):
 			logger.Warn("Could not retrieve version info after 10 seconds!")
+			versionStruct := config.LocalVersion()
+			releaseChannel := conf.UpdateBranch
+			targetChan := versionStruct.Groundseg[releaseChannel]
+			config.VersionInfo = targetChan
 		}
 	}
 	// Load Netdata