diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-11-25 08:32:16 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-11-25 08:32:16 +0300 |
commit | 011f2f3b20f6ce72b7aa66995a17ecee643b98bc (patch) | |
tree | 3631e07d426086445d82b6ed2754c96318b43290 /internal | |
parent | 10bd057380f7c01891a4b5c68c771b03a4d85607 (diff) | |
parent | ed5be5c6020dedda33dc43b99fa768e654c6e674 (diff) |
Merge branch 'refactor/config-multierror' into 'master'
refactor: use multierror in config validation
Closes #665
See merge request gitlab-org/gitlab-pages!622
Diffstat (limited to 'internal')
-rw-r--r-- | internal/config/validate.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/internal/config/validate.go b/internal/config/validate.go index 32238786..1e6edca0 100644 --- a/internal/config/validate.go +++ b/internal/config/validate.go @@ -22,19 +22,16 @@ var ( // Validate values populated in Config func Validate(config *Config) error { - if err := validateListeners(config); err != nil { - return err - } - - if err := validateAuthConfig(config); err != nil { - return err - } + var result *multierror.Error - if err := validateArtifactsServerConfig(config); err != nil { - return err - } + result = multierror.Append(result, + validateListeners(config), + validateAuthConfig(config), + validateArtifactsServerConfig(config), + tls.ValidateTLSVersions(*tlsMinVersion, *tlsMaxVersion), + ) - return tls.ValidateTLSVersions(*tlsMinVersion, *tlsMaxVersion) + return result.ErrorOrNil() } func validateListeners(config *Config) error { @@ -82,14 +79,17 @@ func validateArtifactsServerConfig(config *Config) error { if err != nil { return err } + + var result *multierror.Error + // url.Parse ensures that the Scheme attribute is always lower case. if u.Scheme != "http" && u.Scheme != "https" { - return ErrArtifactsServerUnsupportedScheme + result = multierror.Append(result, ErrArtifactsServerUnsupportedScheme) } if config.ArtifactsServer.TimeoutSeconds < 1 { - return ErrArtifactsServerInvalidTimeout + result = multierror.Append(result, ErrArtifactsServerInvalidTimeout) } - return nil + return result.ErrorOrNil() } |