Skip to content

Commit

Permalink
Add comment for grizzly env variable and add retro compatibility for …
Browse files Browse the repository at this point in the history
…cortext env variables
  • Loading branch information
spinillos committed Apr 22, 2024
1 parent c3ccd8f commit 35e4e03
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
23 changes: 21 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,33 @@ func override(v *viper.Viper) {
"mimir.tenant-id": "MIMIR_TENANT_ID",
"mimir.api-key": "MIMIR_API_KEY",
}

// To keep retro compatibility
mimirBindings := map[string]string{
"MIMIR_ADDRESS": "CORTEX_ADDRESS",
"MIMIR_TENANT_ID": "CORTEX_TENANT_ID",
"MIMIR_API_KEY": "CORTEX_API_KEY",
}

for key, env := range bindings {
val := os.Getenv(env)
if val != "" {
if val := getVal(env, mimirBindings); val != "" {
v.Set(key, val)
}
}
}

func getVal(env string, alternativeMap map[string]string) string {
if val := os.Getenv(env); val != "" {
return val
}

if alternativeMap[env] != "" {
return getVal(alternativeMap[env], nil)
}

return ""
}

func Read() error {
err := viper.ReadInConfig()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/mimir/client/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (c *Client) doRequest(method string, url string, body []byte) ([]byte, erro

func createHttpClient() (*http.Client, error) {
timeout := 10 * time.Second
// TODO: Move this configuration to the global configuration
if timeoutStr := os.Getenv("GRIZZLY_HTTP_TIMEOUT"); timeoutStr != "" {
timeoutSeconds, err := strconv.Atoi(timeoutStr)
if err != nil {
Expand Down
11 changes: 0 additions & 11 deletions pkg/mimir/errors.go

This file was deleted.

0 comments on commit 35e4e03

Please sign in to comment.