Skip to content

Commit 064655f

Browse files
authored
Set env config to use _ delimiter instead of :: (#74)
* Set env config to use _ delimiter instead of :: * Fix failing test scripts related to env delimiter * Fix e2e issues * Modify readme --------- Co-authored-by: Shide Foo <shide.foo@gojek.com>
1 parent 11f4fa6 commit 064655f

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Instructions as described in README of https://github.com/caraml-dev/mlp.
3434

3535
#### b. Starting XP
3636

37-
Prior to starting XP, we'll need to ensure correct MLP API is correctly set in the config file, i.e management-service/config/example.yaml, and setting the correct `MLPConfig::URL` value.
37+
Prior to starting XP, we'll need to ensure correct MLP API is correctly set in the config file, i.e management-service/config/example.yaml, and setting the correct `MLPConfig_URL` value.
3838

3939
```bash
4040
# Start Management Service

common/config/config.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func ParseConfig(spec interface{}, filepaths []string) error {
2626
}
2727

2828
// Load config values from environment variables.
29-
// Nested keys in the config is represented by variable name separated by '::'.
30-
// For example, DbConfig.Host can be set from environment variable DBCONFIG::HOST.
31-
v.SetEnvKeyReplacer(strings.NewReplacer(".", "::"))
29+
// Nested keys in the config is represented by variable name separated by '_'.
30+
// For example, DbConfig.Host can be set from environment variable DBCONFIG_HOST.
31+
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
3232
v.AutomaticEnv()
3333

3434
// Unmarshal config values into the config object.

common/config/config_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ func TestEnvConfigs(t *testing.T) {
6262

6363
os.Setenv("HOST", host)
6464
os.Setenv("PORT", port)
65-
os.Setenv("PUBSUB::PROJECT", pubSubProject)
66-
os.Setenv("PUBSUB::TOPICNAME", pubSubTopicName)
67-
os.Setenv("SENTRY::URL", sentryUrl)
65+
os.Setenv("PUBSUB_PROJECT", pubSubProject)
66+
os.Setenv("PUBSUB_TOPICNAME", pubSubTopicName)
67+
os.Setenv("SENTRY_URL", sentryUrl)
6868

6969
cfg := tu.Config{}
7070
var filePaths []string

tests/e2e/fixtures/services.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _start_management_service(
115115
pubsub_topic = pubsub_config.get("TopicName", "xp-update")
116116
create_pubsub_topic(pubsub_project, pubsub_topic)
117117

118-
os.environ["MLPCONFIG::URL"] = mlp_service_url
118+
os.environ["MLPCONFIG_URL"] = mlp_service_url
119119

120120
process = _start_binary(
121121
bin_path,

treatment-service/integration-test/fetch_treatment_it_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func setupManagementServiceClient() (*management.ClientWithResponses, *httptest.
307307
}
308308

309309
func setupTreatmentService(managementServiceServerURL string) (chan bool, *server.Server) {
310-
os.Setenv("MANAGEMENTSERVICE::URL", managementServiceServerURL)
310+
os.Setenv("MANAGEMENTSERVICE_URL", managementServiceServerURL)
311311
treatmentServer, err := server.NewServer([]string{"test.yaml"})
312312
if err != nil {
313313
log.Fatalf("fail to instantiate treatment server: %s", err.Error())
@@ -344,8 +344,8 @@ func (suite *TreatmentServiceTestSuite) SetupSuite() {
344344
ctx := context.Background()
345345
os.Setenv("PORT", strconv.Itoa(TreatmentServerPort))
346346
os.Setenv("PROJECTIDS", "1,2,3,4,5")
347-
os.Setenv("PUBSUB::PROJECT", PubSubProject)
348-
os.Setenv("PUBSUB::TOPICNAME", TopicName)
347+
os.Setenv("PUBSUB_PROJECT", PubSubProject)
348+
os.Setenv("PUBSUB_TOPICNAME", TopicName)
349349

350350
emulator, pubsubClient, err := testutils.StartPubSubEmulator(context.Background(), PubSubProject)
351351
if err != nil {
@@ -379,7 +379,7 @@ func (suite *TreatmentServiceTestSuite) SetupSuite() {
379379
panic(err)
380380
}
381381
suite.kafka = kafka
382-
os.Setenv("ASSIGNEDTREATMENTLOGGER::KAFKACONFIG::BROKERS", "localhost:9092")
382+
os.Setenv("ASSIGNEDTREATMENTLOGGER_KAFKACONFIG_BROKERS", "localhost:9092")
383383

384384
c, treatmentServer := setupTreatmentService(suite.managementServiceServer.URL)
385385
waitForServerToListen := func() bool {

0 commit comments

Comments
 (0)