Skip to content

Commit d514eff

Browse files
authored
fix: do not fail on missing urls in config (#780)
Some URLs are not always required. So we should not fail when their value is unset in the configuration files.
1 parent 3f1c9a6 commit d514eff

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

internal/config/config_handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ func parseStringAsURL() mapstructure.DecodeHookFuncType {
175175
return nil, fmt.Errorf("cannot cast URL value to string")
176176
}
177177
if dataStr == "" {
178-
return nil, fmt.Errorf("empty values are not allowed for URLs")
178+
// NOTE: In some cases a url is optional and in this case the field is just ""
179+
return nil, nil
179180
}
180181
url, err := url.Parse(dataStr)
181182
if err != nil {

internal/config/login.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,8 @@ func (c LoginConfig) Validate(e RunningEnvironment) error {
5959
if c.EnableV1Services && !c.EnableInternalGitlab {
6060
return fmt.Errorf("enabling V1 (legacy) services but disabling the internal Gitlab is not supported in the login config")
6161
}
62+
if c.RenkuBaseURL == nil {
63+
return fmt.Errorf("the renkuBaseURL cannot be null or ''")
64+
}
6265
return nil
6366
}

internal/config/revproxy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ func (r *RevproxyConfig) Validate() error {
4343
if r.EnableV1Services && !r.EnableInternalGitlab {
4444
return fmt.Errorf("enabling V1 (legacy) services but disabling the internal Gitlab is not supported in the reverse proxy config")
4545
}
46+
if r.RenkuBaseURL == nil {
47+
return fmt.Errorf("the renkuBaseURL cannot be null or ''")
48+
}
4649

4750
// Check v1 services if needed
4851
if r.EnableV1Services {

0 commit comments

Comments
 (0)