From 8e073db3e765f09db956c7dc03512a4a425759ed Mon Sep 17 00:00:00 2001 From: mohammad mahdi rezaei Date: Mon, 18 Dec 2023 10:03:31 +0330 Subject: [PATCH] fix(config): change ormus to eb --- config/README.md | 8 ++++---- config/config_test.go | 16 ++++++++-------- config/loader.go | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/config/README.md b/config/README.md index dd890f6..4bf6c26 100644 --- a/config/README.md +++ b/config/README.md @@ -24,12 +24,12 @@ The package allows setting up configurations in three ways: 💡 Use this way for storing `important secrets` that should not be hard coded in repo or in `config.yml` file. For example, `DB_PASSWORD`, or `JWT_SECRET`. -Environment variables are used to configure the application at runtime. The variable names must start with `ORMUS_`, and nested variables should use `__` as a separator (`ORMUS_DB__HOST`). +Environment variables are used to configure the application at runtime. The variable names must start with `EB_`, and nested variables should use `__` as a separator (`EB_DB__HOST`). Example setting environment variables: ```go -os.Setenv("ORMUS_DEBUG", "true") -os.Setenv("ORMUS_MULTI_WORD_VAR", "this is a multi-word var") +os.Setenv("EB_DEBUG", "true") +os.Setenv("EB_MULTI_WORD_VAR", "this is a multi-word var") // ... set other environment variables ... ``` @@ -44,7 +44,7 @@ Example `config.yml` file: debug: true multi_word_var: "this is a multi-word var in YAML" db: - username: ormus + username: eb password: youcannotbreakme # ... other configurations ... ``` diff --git a/config/config_test.go b/config/config_test.go index 8806e54..2cd147f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -32,7 +32,7 @@ type nestedMultiWordConfig struct { } const ( - prefix = "ORMUS_" + prefix = "EB_" delimiter = "." separator = "__" ) @@ -115,13 +115,13 @@ db: func TestLoadConfigFromEnvironmentVariable(t *testing.T) { k := koanf.New(".") - os.Setenv("ORMUS_DEBUG", "false") - os.Setenv("ORMUS_MULTI_WORD_VAR", "this is multi word var") - os.Setenv("ORMUS_DB__HOST", "localhost") - os.Setenv("ORMUS_DB__USERNAME", "hossein") - os.Setenv("ORMUS_DB__PASSWORD", "1234") - os.Setenv("ORMUS_DB__MULTI_WORD_NESTED_VAR", "testing make it easy (:") - os.Setenv("ORMUS_DB__NESTED_MULTI_WORD_CONFIG__DOWN_HERE", "im here") + os.Setenv("EB_DEBUG", "false") + os.Setenv("EB_MULTI_WORD_VAR", "this is multi word var") + os.Setenv("EB_DB__HOST", "localhost") + os.Setenv("EB_DB__USERNAME", "hossein") + os.Setenv("EB_DB__PASSWORD", "1234") + os.Setenv("EB_DB__MULTI_WORD_NESTED_VAR", "testing make it easy (:") + os.Setenv("EB_DB__NESTED_MULTI_WORD_CONFIG__DOWN_HERE", "im here") if err := k.Load(env.Provider(prefix, delimiter, callbackEnv), nil); err != nil { t.Logf("error loading environment variables: %s", err) diff --git a/config/loader.go b/config/loader.go index 6a4199c..4ecf582 100644 --- a/config/loader.go +++ b/config/loader.go @@ -12,7 +12,7 @@ import ( ) const ( - defaultPrefix = "ORMUS_" + defaultPrefix = "EB_" defaultDelimiter = "." defaultSeparator = "__" defaultYamlFilePath = "config.yml" @@ -28,8 +28,8 @@ type Option struct { CallbackEnv func(string) string } -// our environment variables must prefix with `ORMUS_` -// for nested env should use `__` aka: ORMUS_DB__HOST. +// our environment variables must prefix with `EB_` +// for nested env should use `__` aka: EB__DB__HOST. func defaultCallbackEnv(source string) string { base := strings.ToLower(strings.TrimPrefix(source, defaultPrefix))