| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package env
- import (
- "path"
- )
- const DefaultConfigPath = "/var/configs"
- const DefaultStorageFile = "federated-store.yaml"
- const (
- APIPortEnvVar = "API_PORT"
- ClusterIDEnvVar = "CLUSTER_ID"
- AppNameEnvVar = "APP_NAME"
- ConfigPathEnvVar = "CONFIG_PATH"
- PProfEnabledEnvVar = "PPROF_ENABLED"
- InstallNamespaceEnvVar = "INSTALL_NAMESPACE"
- Resolution1dRetentionEnvVar = "RESOLUTION_1D_RETENTION" // int: number of days
- Resolution1hRetentionEnvVar = "RESOLUTION_1H_RETENTION" // int: number of hours
- Resolution10mRetentionEnvVar = "RESOLUTION_10M_RETENTION" // int: number of 10m segments
- )
- // GetAPIPort returns the environment variable value for APIPortEnvVar which
- // is the port number the API is available on.
- func GetAPIPortWithDefault(def int) int {
- return GetInt(APIPortEnvVar, def)
- }
- // GetClusterID returns the environment variable value for ClusterIDEnvVar which represents the
- // configurable identifier used for multi-cluster metric emission.
- func GetClusterID() string {
- return Get(ClusterIDEnvVar, "")
- }
- // GetAppName returns the name of the application name running the values
- func GetAppName() string {
- return Get(AppNameEnvVar, "Opencost")
- }
- // GetConfigPath returns the environment variable value for ConfigPathEnvVar which represents the cost
- // model configuration path
- func GetConfigPath() string {
- return Get(ConfigPathEnvVar, DefaultConfigPath)
- }
- func GetPathFromConfig(subPaths ...string) string {
- subPath := path.Join(subPaths...)
- return path.Join(GetConfigPath(), subPath)
- }
- func GetDefaultStorageConfigFilePath() string {
- return path.Join(GetConfigPath(), DefaultStorageFile)
- }
- func IsPProfEnabled() bool {
- return GetBool(PProfEnabledEnvVar, false)
- }
- func GetInstallNamespace(def string) string {
- return Get(InstallNamespaceEnvVar, def)
- }
|