-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
authn: Override configuration with environment variables for server
Signed-off-by: Abhishek Gaikwad <[email protected]>
- Loading branch information
1 parent
21cce48
commit bc10234
Showing
4 changed files
with
75 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Package cos provides common low-level types and utilities for all aistore projects. | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
*/ | ||
package cos | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
// getEnvOrDefault returns the value of the environment variable if it exists, | ||
// otherwise it returns the provided default value. | ||
func GetEnvOrDefault(envVar, defaultValue string) string { | ||
if value := os.Getenv(envVar); value != "" { | ||
return value | ||
} | ||
return defaultValue | ||
} | ||
|
||
// IsParseBoolOrDefault parses a boolean from the environment variable string | ||
// or returns the default value if parsing fails. | ||
func IsParseEnvBoolOrDefault(envVar string, defaultValue bool) (bool, error) { | ||
if value := os.Getenv(envVar); value != "" { | ||
return ParseBool(value) | ||
} | ||
return defaultValue, nil | ||
} |