Skip to content

Commit c59497b

Browse files
committed
allow for http/https url schemes to be passed on to advertised-endpoints
1 parent 888cbff commit c59497b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

service/arangod_config_builder.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ import (
4545
"github.com/rs/zerolog"
4646
)
4747

48+
var (
49+
urlFixer = strings.NewReplacer(
50+
"http://", "tcp://",
51+
"https://", "ssl://",
52+
)
53+
)
54+
55+
// FixupEndpointURLScheme changes endpoint URL schemes used by arangod to ones used by go.
56+
// E.g. "http://localhost:8529" -> "tcp://localhost:8529"
57+
func FixupEndpointURLScheme(u string) string {
58+
return urlFixer.Replace(u)
59+
}
60+
4861
// createArangodConf creates an arangod.conf file in the given host directory if it does not yet exists.
4962
// The arangod.conf file contains all settings that are considered static for the lifetime of the server.
5063
func createArangodConf(log zerolog.Logger, bsCfg BootstrapConfig, myHostDir, myContainerDir, myPort string, serverType ServerType, features DatabaseFeatures) ([]Volume, configFile, error) {
@@ -204,7 +217,7 @@ func createArangodArgs(log zerolog.Logger, config Config, clusterConfig ClusterC
204217
)
205218
if config.AdvertisedEndpoint != "" {
206219
options = append(options,
207-
optionPair{"--cluster.my-advertised-endpoint", config.AdvertisedEndpoint},
220+
optionPair{"--cluster.my-advertised-endpoint", FixupEndpointURLScheme(config.AdvertisedEndpoint)},
208221
)
209222
}
210223
case ServerTypeSingle:
@@ -222,7 +235,7 @@ func createArangodArgs(log zerolog.Logger, config Config, clusterConfig ClusterC
222235
)
223236
if config.AdvertisedEndpoint != "" {
224237
options = append(options,
225-
optionPair{"--cluster.my-advertised-endpoint", config.AdvertisedEndpoint},
238+
optionPair{"--cluster.my-advertised-endpoint", FixupEndpointURLScheme(config.AdvertisedEndpoint)},
226239
)
227240
}
228241
}

0 commit comments

Comments
 (0)