mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
ZROK_CTRL_CONFIG_VERSION override (#648)
This commit is contained in:
parent
53f5efb17c
commit
6f35c75203
@ -1,6 +1,8 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/openziti/zrok/controller/emailUi"
|
||||
@ -14,7 +16,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const ConfigVersion = 3
|
||||
const ConfigVersion = 4
|
||||
|
||||
type Config struct {
|
||||
V int
|
||||
@ -119,8 +121,22 @@ func LoadConfig(path string) (*Config, error) {
|
||||
if err := cf.BindYaml(cfg, path, env.GetCfOptions()); err != nil {
|
||||
return nil, errors.Wrapf(err, "error loading controller config '%v'", path)
|
||||
}
|
||||
if cfg.V != ConfigVersion {
|
||||
if !envVersionOk() && cfg.V != ConfigVersion {
|
||||
return nil, errors.Errorf("expecting configuration version '%v', your configuration is version '%v'; please see zrok.io for changelog and configuration documentation", ConfigVersion, cfg.V)
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func envVersionOk() bool {
|
||||
vStr := os.Getenv("ZROK_CTRL_CONFIG_VERSION")
|
||||
if vStr != "" {
|
||||
envV, err := strconv.Atoi(vStr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if envV == ConfigVersion {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user