costmodelenv.go 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. package env
  2. const (
  3. AWSAccessKeyIDEnvVar = "AWS_ACCESS_KEY_ID"
  4. AWSAccessKeySecretEnvVar = "AWS_SECRET_ACCESS_KEY"
  5. AWSClusterIDEnvVar = "AWS_CLUSTER_ID"
  6. KubecostNamespaceEnvVar = "KUBECOST_NAMESPACE"
  7. ClusterIDEnvVar = "CLUSTER_ID"
  8. ClusterProfileEnvVar = "CLUSTER_PROFILE"
  9. PrometheusServerEndpointEnvVar = "PROMETHEUS_SERVER_ENDPOINT"
  10. MaxQueryConcurrencyEnvVar = "MAX_QUERY_CONCURRENCY"
  11. RemoteEnabledEnvVar = "REMOTE_WRITE_ENABLED"
  12. RemotePWEnvVar = "REMOTE_WRITE_PASSWORD"
  13. SQLAddressEnvVar = "SQL_ADDRESS"
  14. UseCSVProviderEnvVar = "USE_CSV_PROVIDER"
  15. CSVRegionEnvVar = "CSV_REGION"
  16. CSVPathEnvVar = "CSV_PATH"
  17. ConfigPathEnvVar = "CONFIG_PATH"
  18. CloudProviderAPIKeyEnvVar = "CLOUD_PROVIDER_API_KEY"
  19. ThanosEnabledEnvVar = "THANOS_ENABLED"
  20. ThanosQueryUrlEnvVar = "THANOS_QUERY_URL"
  21. ThanosOffsetEnvVar = "THANOS_QUERY_OFFSET"
  22. LogCollectionEnabledEnvVar = "LOG_COLLECTION_ENABLED"
  23. ProductAnalyticsEnabledEnvVar = "PRODUCT_ANALYTICS_ENABLED"
  24. ErrorReportingEnabledEnvVar = "ERROR_REPORTING_ENABLED"
  25. ValuesReportingEnabledEnvVar = "VALUES_REPORTING_ENABLED"
  26. DBBasicAuthUsername = "DB_BASIC_AUTH_USERNAME"
  27. DBBasicAuthPassword = "DB_BASIC_AUTH_PW"
  28. DBBearerToken = "DB_BEARER_TOKEN"
  29. MultiClusterBasicAuthUsername = "MC_BASIC_AUTH_USERNAME"
  30. MultiClusterBasicAuthPassword = "MC_BASIC_AUTH_PW"
  31. MultiClusterBearerToken = "MC_BEARER_TOKEN"
  32. InsecureSkipVerify = "INSECURE_SKIP_VERIFY"
  33. KubeConfigPathEnvVar = "KUBECONFIG_PATH"
  34. )
  35. // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
  36. // the AWS access key for authentication
  37. func GetAWSAccessKeyID() string {
  38. return Get(AWSAccessKeyIDEnvVar, "")
  39. }
  40. // GetAWSAccessKeySecret returns the environment variable value for AWSAccessKeySecretEnvVar which represents
  41. // the AWS access key secret for authentication
  42. func GetAWSAccessKeySecret() string {
  43. return Get(AWSAccessKeySecretEnvVar, "")
  44. }
  45. // GetAWSClusterID returns the environment variable value for AWSClusterIDEnvVar which represents
  46. // an AWS specific cluster identifier.
  47. func GetAWSClusterID() string {
  48. return Get(AWSClusterIDEnvVar, "")
  49. }
  50. // GetKubecostNamespace returns the environment variable value for KubecostNamespaceEnvVar which
  51. // represents the namespace the cost model exists in.
  52. func GetKubecostNamespace() string {
  53. return Get(KubecostNamespaceEnvVar, "kubecost")
  54. }
  55. // GetClusterProfile returns the environment variable value for ClusterProfileEnvVar which
  56. // represents the cluster profile configured for
  57. func GetClusterProfile() string {
  58. return Get(ClusterProfileEnvVar, "development")
  59. }
  60. // GetClusterID returns the environment variable value for ClusterIDEnvVar which represents the
  61. // configurable identifier used for multi-cluster metric emission.
  62. func GetClusterID() string {
  63. return Get(ClusterIDEnvVar, "")
  64. }
  65. // GetPrometheusServerEndpoint returns the environment variable value for PrometheusServerEndpointEnvVar which
  66. // represents the prometheus server endpoint used to execute prometheus queries.
  67. func GetPrometheusServerEndpoint() string {
  68. return Get(PrometheusServerEndpointEnvVar, "")
  69. }
  70. func GetInsecureSkipVerify() bool {
  71. return GetBool(InsecureSkipVerify, false)
  72. }
  73. // IsRemoteEnabled returns the environment variable value for RemoteEnabledEnvVar which represents whether
  74. // or not remote write is enabled for prometheus for use with SQL backed persistent storage.
  75. func IsRemoteEnabled() bool {
  76. return GetBool(RemoteEnabledEnvVar, false)
  77. }
  78. // GetRemotePW returns the environment variable value for RemotePWEnvVar which represents the remote
  79. // persistent storage password.
  80. func GetRemotePW() string {
  81. return Get(RemotePWEnvVar, "")
  82. }
  83. // GetSQLAddress returns the environment variable value for SQLAddressEnvVar which represents the SQL
  84. // database address used with remote persistent storage.
  85. func GetSQLAddress() string {
  86. return Get(SQLAddressEnvVar, "")
  87. }
  88. // IsUseCSVProvider returns the environment variable value for UseCSVProviderEnvVar which represents
  89. // whether or not the use of a CSV cost provider is enabled.
  90. func IsUseCSVProvider() bool {
  91. return GetBool(UseCSVProviderEnvVar, false)
  92. }
  93. // GetCSVRegion returns the environment variable value for CSVRegionEnvVar which represents the
  94. // region configured for a CSV provider.
  95. func GetCSVRegion() string {
  96. return Get(CSVRegionEnvVar, "")
  97. }
  98. // GetCSVPath returns the environment variable value for CSVPathEnvVar which represents the key path
  99. // configured for a CSV provider.
  100. func GetCSVPath() string {
  101. return Get(CSVPathEnvVar, "")
  102. }
  103. // GetConfigPath returns the environment variable value for ConfigPathEnvVar which represents the cost
  104. // model configuration path
  105. func GetConfigPath() string {
  106. return Get(ConfigPathEnvVar, "")
  107. }
  108. // GetConfigPath returns the environment variable value for ConfigPathEnvVar which represents the cost
  109. // model configuration path
  110. func GetConfigPathWithDefault(defaultValue string) string {
  111. return Get(ConfigPathEnvVar, defaultValue)
  112. }
  113. // GetCloudProviderAPI returns the environment variable value for CloudProviderAPIEnvVar which represents
  114. // the API key provided for the cloud provider.
  115. func GetCloudProviderAPIKey() string {
  116. return Get(CloudProviderAPIKeyEnvVar, "")
  117. }
  118. // IsThanosEnabled returns the environment variable value for ThanosEnabledEnvVar which represents whether
  119. // or not thanos is enabled.
  120. func IsThanosEnabled() bool {
  121. return GetBool(ThanosEnabledEnvVar, false)
  122. }
  123. // GetThanosQueryUrl returns the environment variable value for ThanosQueryUrlEnvVar which represents the
  124. // target query endpoint for hitting thanos.
  125. func GetThanosQueryUrl() string {
  126. return Get(ThanosQueryUrlEnvVar, "")
  127. }
  128. // GetThanosOffset returns the environment variable value for ThanosOffsetEnvVar which represents the total
  129. // amount of time to offset all queries made to thanos.
  130. func GetThanosOffset() string {
  131. return Get(ThanosOffsetEnvVar, "3h")
  132. }
  133. // IsLogCollectionEnabled returns the environment variable value for LogCollectionEnabledEnvVar which represents
  134. // whether or not log collection has been enabled for kubecost deployments.
  135. func IsLogCollectionEnabled() bool {
  136. return GetBool(LogCollectionEnabledEnvVar, true)
  137. }
  138. // IsProductAnalyticsEnabled returns the environment variable value for ProductAnalyticsEnabledEnvVar
  139. func IsProductAnalyticsEnabled() bool {
  140. return GetBool(ProductAnalyticsEnabledEnvVar, true)
  141. }
  142. // IsErrorReportingEnabled returns the environment variable value for ErrorReportingEnabledEnvVar
  143. func IsErrorReportingEnabled() bool {
  144. return GetBool(ErrorReportingEnabledEnvVar, true)
  145. }
  146. // IsValuesReportingEnabled returns the environment variable value for ValuesReportingEnabledEnvVar
  147. func IsValuesReportingEnabled() bool {
  148. return GetBool(ValuesReportingEnabledEnvVar, true)
  149. }
  150. // GetMaxQueryConcurrency returns the environment variable value for MaxQueryConcurrencyEnvVar
  151. func GetMaxQueryConcurrency() int {
  152. return GetInt(MaxQueryConcurrencyEnvVar, 5)
  153. }
  154. func GetDBBasicAuthUsername() string {
  155. return Get(DBBasicAuthUsername, "")
  156. }
  157. func GetDBBasicAuthUserPassword() string {
  158. return Get(DBBasicAuthPassword, "")
  159. }
  160. func GetDBBearerToken() string {
  161. return Get(DBBearerToken, "")
  162. }
  163. // GetMultiClusterBasicAuthUsername returns the environemnt variable value for MultiClusterBasicAuthUsername
  164. func GetMultiClusterBasicAuthUsername() string {
  165. return Get(MultiClusterBasicAuthUsername, "")
  166. }
  167. // GetMultiClusterBasicAuthPassword returns the environemnt variable value for MultiClusterBasicAuthPassword
  168. func GetMultiClusterBasicAuthPassword() string {
  169. return Get(MultiClusterBasicAuthPassword, "")
  170. }
  171. func GetMultiClusterBearerToken() string {
  172. return Get(MultiClusterBearerToken, "")
  173. }
  174. // GetKubeConfigPath returns the environment variable value for KubeConfigPathEnvVar
  175. func GetKubeConfigPath() string {
  176. return Get(KubeConfigPathEnvVar, "")
  177. }