From 6f35c75203a06ef78d75a81b020a605ecbb20fdd Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Wed, 12 Jun 2024 13:21:45 -0400 Subject: [PATCH] ZROK_CTRL_CONFIG_VERSION override (#648) --- controller/config/config.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/controller/config/config.go b/controller/config/config.go index 8e67f8c0..3a1589d4 100644 --- a/controller/config/config.go +++ b/controller/config/config.go @@ -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 +}