Validate validates the configuration structure and returns an error if it is invalid. - dynamic enables the validation for dynamically configurable options.
(dynamic bool)
| 90 | // |
| 91 | // - dynamic enables the validation for dynamically configurable options. |
| 92 | func (cfg *AppConfig) Validate(dynamic bool) error { |
| 93 | queue := newValidationQueue() |
| 94 | queue.add("ssh", &cfg.SSH) |
| 95 | queue.add("configserver", &cfg.ConfigServer) |
| 96 | queue.add("auth", &cfg.Auth) |
| 97 | queue.add("log", &cfg.Log) |
| 98 | queue.add("metrics", &cfg.Metrics) |
| 99 | queue.add("geoip", &cfg.GeoIP) |
| 100 | queue.add("audit", &cfg.Audit) |
| 101 | queue.add("health", &cfg.Health) |
| 102 | |
| 103 | if cfg.ConfigServer.URL != "" && !dynamic { |
| 104 | return queue.Validate() |
| 105 | } |
| 106 | queue.add("security", &cfg.Security) |
| 107 | queue.add("backend", &cfg.Backend) |
| 108 | switch cfg.Backend { |
| 109 | case BackendDocker: |
| 110 | queue.add("docker", &cfg.Docker) |
| 111 | case BackendKubernetes: |
| 112 | queue.add("kubernetes", &cfg.Kubernetes) |
| 113 | case BackendSSHProxy: |
| 114 | queue.add("sshproxy", &cfg.SSHProxy) |
| 115 | } |
| 116 | |
| 117 | return queue.Validate() |
| 118 | } |
| 119 | |
| 120 | type validatable interface { |
| 121 | Validate() error |