MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / Validate

Method Validate

config/appconfig.go:92–118  ·  view source on GitHub ↗

Validate validates the configuration structure and returns an error if it is invalid. - dynamic enables the validation for dynamically configurable options.

(dynamic bool)

Source from the content-addressed store, hash-verified

90//
91// - dynamic enables the validation for dynamically configurable options.
92func (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
120type validatable interface {
121 Validate() error

Callers 2

Test04CompatibilityFunction · 0.95

Calls 3

newValidationQueueFunction · 0.85
addMethod · 0.80
ValidateMethod · 0.65

Tested by 1

Test04CompatibilityFunction · 0.76