mirror of
https://github.com/openziti/zrok.git
synced 2025-02-02 03:20:26 +01:00
ZROK_CTRL_CONFIG_VERSION override (#648)
This commit is contained in:
parent
53f5efb17c
commit
6f35c75203
@ -1,6 +1,8 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openziti/zrok/controller/emailUi"
|
"github.com/openziti/zrok/controller/emailUi"
|
||||||
@ -14,7 +16,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ConfigVersion = 3
|
const ConfigVersion = 4
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
V int
|
V int
|
||||||
@ -119,8 +121,22 @@ func LoadConfig(path string) (*Config, error) {
|
|||||||
if err := cf.BindYaml(cfg, path, env.GetCfOptions()); err != nil {
|
if err := cf.BindYaml(cfg, path, env.GetCfOptions()); err != nil {
|
||||||
return nil, errors.Wrapf(err, "error loading controller config '%v'", path)
|
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 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
|
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