costmodelenv.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. package env
  2. import (
  3. "time"
  4. "github.com/opencost/opencost/core/pkg/env"
  5. "github.com/opencost/opencost/core/pkg/log"
  6. "github.com/opencost/opencost/core/pkg/util/timeutil"
  7. )
  8. const (
  9. APIPortEnvVar = "API_PORT"
  10. NetworkCostsPortEnvVar = "NETWORK_COSTS_PORT"
  11. AWSAccessKeyIDEnvVar = "AWS_ACCESS_KEY_ID"
  12. AWSAccessKeySecretEnvVar = "AWS_SECRET_ACCESS_KEY"
  13. AWSClusterIDEnvVar = "AWS_CLUSTER_ID"
  14. AWSPricingURL = "AWS_PRICING_URL"
  15. AlibabaAccessKeyIDEnvVar = "ALIBABA_ACCESS_KEY_ID"
  16. AlibabaAccessKeySecretEnvVar = "ALIBABA_SECRET_ACCESS_KEY"
  17. AzureOfferIDEnvVar = "AZURE_OFFER_ID"
  18. AzureBillingAccountEnvVar = "AZURE_BILLING_ACCOUNT"
  19. AzureDownloadBillingDataToDiskEnvVar = "AZURE_DOWNLOAD_BILLING_DATA_TO_DISK"
  20. ReleaseNameEnvVar = "RELEASE_NAME"
  21. PodNameEnvVar = "POD_NAME"
  22. ClusterIDEnvVar = "CLUSTER_ID"
  23. ClusterProfileEnvVar = "CLUSTER_PROFILE"
  24. RemoteEnabledEnvVar = "REMOTE_WRITE_ENABLED"
  25. RemotePWEnvVar = "REMOTE_WRITE_PASSWORD"
  26. SQLAddressEnvVar = "SQL_ADDRESS"
  27. UseCSVProviderEnvVar = "USE_CSV_PROVIDER"
  28. UseCustomProviderEnvVar = "USE_CUSTOM_PROVIDER"
  29. CSVRegionEnvVar = "CSV_REGION"
  30. CSVEndpointEnvVar = "CSV_ENDPOINT"
  31. CSVPathEnvVar = "CSV_PATH"
  32. ConfigPathEnvVar = "CONFIG_PATH"
  33. CloudProviderAPIKeyEnvVar = "CLOUD_PROVIDER_API_KEY"
  34. CollectorDataSourceEnabledEnvVar = "COLLECTOR_DATA_SOURCE_ENABLED"
  35. PVMountPath = "PV_MOUNT_PATH"
  36. EmitPodAnnotationsMetricEnvVar = "EMIT_POD_ANNOTATIONS_METRIC"
  37. EmitNamespaceAnnotationsMetricEnvVar = "EMIT_NAMESPACE_ANNOTATIONS_METRIC"
  38. EmitDeprecatedMetrics = "EMIT_DEPRECATED_METRICS"
  39. EmitKsmV1MetricsEnvVar = "EMIT_KSM_V1_METRICS"
  40. EmitKsmV1MetricsOnly = "EMIT_KSM_V1_METRICS_ONLY"
  41. PProfEnabledEnvVar = "PPROF_ENABLED"
  42. LogCollectionEnabledEnvVar = "LOG_COLLECTION_ENABLED"
  43. ProductAnalyticsEnabledEnvVar = "PRODUCT_ANALYTICS_ENABLED"
  44. ErrorReportingEnabledEnvVar = "ERROR_REPORTING_ENABLED"
  45. ValuesReportingEnabledEnvVar = "VALUES_REPORTING_ENABLED"
  46. KubeRbacProxyEnabled = "KUBE_RBAC_PROXY_ENABLED"
  47. KubeConfigPathEnvVar = "KUBECONFIG_PATH"
  48. UTCOffsetEnvVar = "UTC_OFFSET"
  49. ETLEnabledEnvVar = "ETL_ENABLED"
  50. ETLResolutionSeconds = "ETL_RESOLUTION_SECONDS"
  51. PricingConfigmapName = "PRICING_CONFIGMAP_NAME"
  52. MetricsConfigmapName = "METRICS_CONFIGMAP_NAME"
  53. ClusterInfoFileEnabledEnvVar = "CLUSTER_INFO_FILE_ENABLED"
  54. ClusterCacheFileEnabledEnvVar = "CLUSTER_CACHE_FILE_ENABLED"
  55. IngestPodUIDEnvVar = "INGEST_POD_UID"
  56. ETLReadOnlyMode = "ETL_READ_ONLY"
  57. AllocationNodeLabelsEnabled = "ALLOCATION_NODE_LABELS_ENABLED"
  58. AssetIncludeLocalDiskCostEnvVar = "ASSET_INCLUDE_LOCAL_DISK_COST"
  59. regionOverrideList = "REGION_OVERRIDE_LIST"
  60. ExportCSVFile = "EXPORT_CSV_FILE"
  61. ExportCSVLabelsList = "EXPORT_CSV_LABELS_LIST"
  62. ExportCSVLabelsAll = "EXPORT_CSV_LABELS_ALL"
  63. ExportCSVMaxDays = "EXPORT_CSV_MAX_DAYS"
  64. ExportBucketConfigFileEnvVar = "EXPORT_BUCKET_CONFIG_FILE"
  65. DataRetentionDailyResolutionDaysEnvVar = "DATA_RETENTION_DAILY_RESOLUTION_DAYS"
  66. DataRetentionHourlyResolutionHoursEnvVar = "DATA_RETENTION_HOURLY_RESOLUTION_HOURS"
  67. // We assume that Kubernetes is enabled if there is a KUBERNETES_PORT environment variable present
  68. KubernetesEnabledEnvVar = "KUBERNETES_PORT"
  69. CloudCostEnabledEnvVar = "CLOUD_COST_ENABLED"
  70. CloudCostConfigPath = "CLOUD_COST_CONFIG_PATH"
  71. CloudCostMonthToDateIntervalVar = "CLOUD_COST_MONTH_TO_DATE_INTERVAL"
  72. CloudCostRefreshRateHoursEnvVar = "CLOUD_COST_REFRESH_RATE_HOURS"
  73. CloudCostQueryWindowDaysEnvVar = "CLOUD_COST_QUERY_WINDOW_DAYS"
  74. CloudCostRunWindowDaysEnvVar = "CLOUD_COST_RUN_WINDOW_DAYS"
  75. CustomCostEnabledEnvVar = "CUSTOM_COST_ENABLED"
  76. CustomCostQueryWindowDaysEnvVar = "CUSTOM_COST_QUERY_WINDOW_DAYS"
  77. CustomCostRefreshRateHoursEnvVar = "CUSTOM_COST_REFRESH_RATE_HOURS"
  78. PluginConfigDirEnvVar = "PLUGIN_CONFIG_DIR"
  79. PluginExecutableDirEnvVar = "PLUGIN_EXECUTABLE_DIR"
  80. OCIPricingURL = "OCI_PRICING_URL"
  81. CarbonEstimatesEnabledEnvVar = "CARBON_ESTIMATES_ENABLED"
  82. UseCacheV1 = "USE_CACHE_V1"
  83. InstallNamespaceEnvVar = "INSTALL_NAMESPACE"
  84. ConfigBucketEnvVar = "CONFIG_BUCKET"
  85. // Node Stats Client Configuration
  86. NodeStatsForceKubeProxyEnvVar = "NODESTATS_FORCE_KUBE_PROXY"
  87. NodeStatsLocalProxyEnvVar = "NODESTATS_LOCAL_PROXY"
  88. NodeStatsInsecureEnvVar = "NODESTATS_INSECURE"
  89. NodeStatsCertFileEnvVar = "NODESTATS_CERT_FILE"
  90. NodeStatsKeyFileEnvVar = "NODESTATS_KEY_FILE"
  91. // Deprecated
  92. KubecostNamespaceEnvVar = "KUBECOST_NAMESPACE"
  93. KubecostConfigBucketEnvVar = "KUBECOST_CONFIG_BUCKET"
  94. )
  95. const DefaultConfigMountPath = "/var/configs"
  96. func IsETLReadOnlyMode() bool {
  97. return env.GetBool(ETLReadOnlyMode, false)
  98. }
  99. func GetExportCSVFile() string {
  100. return env.Get(ExportCSVFile, "")
  101. }
  102. func GetExportCSVLabelsAll() bool {
  103. return env.GetBool(ExportCSVLabelsAll, false)
  104. }
  105. func GetExportCSVLabelsList() []string {
  106. return env.GetList(ExportCSVLabelsList, ",")
  107. }
  108. func IsPProfEnabled() bool {
  109. return env.GetBool(PProfEnabledEnvVar, false)
  110. }
  111. func GetExportCSVMaxDays() int {
  112. return env.GetInt(ExportCSVMaxDays, 90)
  113. }
  114. // GetAPIPort returns the environment variable value for APIPortEnvVar which
  115. // is the port number the API is available on.
  116. func GetAPIPort() int {
  117. return env.GetInt(APIPortEnvVar, 9003)
  118. }
  119. // GetConfigBucketFile returns a file location for a mounted bucket configuration which is used to store
  120. // a subset of configurations that require sharing via remote storage.
  121. func GetConfigBucketFile() string {
  122. return env.Get(ConfigBucketEnvVar, env.Get(KubecostConfigBucketEnvVar, ""))
  123. }
  124. // IsClusterInfoFileEnabled returns true if the cluster info is read from a file or pulled from the local
  125. // cloud provider and kubernetes.
  126. func IsClusterInfoFileEnabled() bool {
  127. return env.GetBool(ClusterInfoFileEnabledEnvVar, false)
  128. }
  129. // IsClusterCacheFileEnabled returns true if the kubernetes cluster data is read from a file or pulled from the local
  130. // kubernetes API.
  131. func IsClusterCacheFileEnabled() bool {
  132. return env.GetBool(ClusterCacheFileEnabledEnvVar, false)
  133. }
  134. func GetPricingConfigmapName() string {
  135. return env.Get(PricingConfigmapName, "pricing-configs")
  136. }
  137. func GetMetricsConfigmapName() string {
  138. return env.Get(MetricsConfigmapName, "metrics-config")
  139. }
  140. // IsEmitNamespaceAnnotationsMetric returns true if cost-model is configured to emit the kube_namespace_annotations metric
  141. // containing the namespace annotations
  142. func IsEmitNamespaceAnnotationsMetric() bool {
  143. return env.GetBool(EmitNamespaceAnnotationsMetricEnvVar, false)
  144. }
  145. // IsEmitPodAnnotationsMetric returns true if cost-model is configured to emit the kube_pod_annotations metric containing
  146. // pod annotations.
  147. func IsEmitPodAnnotationsMetric() bool {
  148. return env.GetBool(EmitPodAnnotationsMetricEnvVar, false)
  149. }
  150. // IsEmitKsmV1Metrics returns true if cost-model is configured to emit all necessary KSM v1
  151. // metrics that were removed in KSM v2
  152. func IsEmitKsmV1Metrics() bool {
  153. return env.GetBool(EmitKsmV1MetricsEnvVar, true)
  154. }
  155. func IsEmitKsmV1MetricsOnly() bool {
  156. return env.GetBool(EmitKsmV1MetricsOnly, false)
  157. }
  158. func IsEmitDeprecatedMetrics() bool {
  159. return env.GetBool(EmitDeprecatedMetrics, false)
  160. }
  161. // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
  162. // the AWS access key for authentication
  163. func GetAWSAccessKeyID() string {
  164. awsAccessKeyID := env.Get(AWSAccessKeyIDEnvVar, "")
  165. // If the sample nil service key name is set, zero it out so that it is not
  166. // misinterpreted as a real service key.
  167. if awsAccessKeyID == "AKIXXX" {
  168. awsAccessKeyID = ""
  169. }
  170. return awsAccessKeyID
  171. }
  172. // GetAWSAccessKeySecret returns the environment variable value for AWSAccessKeySecretEnvVar which represents
  173. // the AWS access key secret for authentication
  174. func GetAWSAccessKeySecret() string {
  175. return env.Get(AWSAccessKeySecretEnvVar, "")
  176. }
  177. // GetAWSClusterID returns the environment variable value for AWSClusterIDEnvVar which represents
  178. // an AWS specific cluster identifier.
  179. func GetAWSClusterID() string {
  180. return env.Get(AWSClusterIDEnvVar, "")
  181. }
  182. // GetAWSPricingURL returns an optional alternative URL to fetch AWS pricing data from; for use in airgapped environments
  183. func GetAWSPricingURL() string {
  184. return env.Get(AWSPricingURL, "")
  185. }
  186. // GetAlibabaAccessKeyID returns the environment variable value for AlibabaAccessKeyIDEnvVar which represents
  187. // the Alibaba access key for authentication
  188. func GetAlibabaAccessKeyID() string {
  189. return env.Get(AlibabaAccessKeyIDEnvVar, "")
  190. }
  191. // GetAlibabaAccessKeySecret returns the environment variable value for AlibabaAccessKeySecretEnvVar which represents
  192. // the Alibaba access key secret for authentication
  193. func GetAlibabaAccessKeySecret() string {
  194. return env.Get(AlibabaAccessKeySecretEnvVar, "")
  195. }
  196. // GetAzureOfferID returns the environment variable value for AzureOfferIDEnvVar which represents
  197. // the Azure offer ID for determining prices.
  198. func GetAzureOfferID() string {
  199. return env.Get(AzureOfferIDEnvVar, "")
  200. }
  201. // GetAzureBillingAccount returns the environment variable value for
  202. // AzureBillingAccountEnvVar which represents the Azure billing
  203. // account for determining prices. If this is specified
  204. // customer-specific prices will be downloaded from the consumption
  205. // price sheet API.
  206. func GetAzureBillingAccount() string {
  207. return env.Get(AzureBillingAccountEnvVar, "")
  208. }
  209. // IsAzureDownloadBillingDataToDisk returns the environment variable value for
  210. // AzureDownloadBillingDataToDiskEnvVar which indicates whether the Azure
  211. // Billing Data should be held in memory or written to disk.
  212. func IsAzureDownloadBillingDataToDisk() bool {
  213. return env.GetBool(AzureDownloadBillingDataToDiskEnvVar, true)
  214. }
  215. // GetInstallNamespace returns the environment variable value that is set for the kubernetes namespace
  216. // this service is installed in.
  217. func GetInstallNamespace() string {
  218. return env.Get(InstallNamespaceEnvVar, env.Get(KubecostNamespaceEnvVar, "opencost"))
  219. }
  220. // GetPodName returns the name of the current running pod. If this environment variable is not set,
  221. // empty string is returned.
  222. func GetPodName() string {
  223. return env.Get(PodNameEnvVar, "")
  224. }
  225. // GetClusterProfile returns the environment variable value for ClusterProfileEnvVar which
  226. // represents the cluster profile configured for
  227. func GetClusterProfile() string {
  228. return env.Get(ClusterProfileEnvVar, "development")
  229. }
  230. // GetClusterID returns the environment variable value for ClusterIDEnvVar which represents the
  231. // configurable identifier used for multi-cluster metric emission.
  232. func GetClusterID() string {
  233. return env.Get(ClusterIDEnvVar, "")
  234. }
  235. func IsKubeRbacProxyEnabled() bool {
  236. return env.GetBool(KubeRbacProxyEnabled, false)
  237. }
  238. // IsRemoteEnabled returns the environment variable value for RemoteEnabledEnvVar which represents whether
  239. // or not remote write is enabled for prometheus for use with SQL backed persistent storage.
  240. func IsRemoteEnabled() bool {
  241. return env.GetBool(RemoteEnabledEnvVar, false)
  242. }
  243. // GetRemotePW returns the environment variable value for RemotePWEnvVar which represents the remote
  244. // persistent storage password.
  245. func GetRemotePW() string {
  246. return env.Get(RemotePWEnvVar, "")
  247. }
  248. // GetSQLAddress returns the environment variable value for SQLAddressEnvVar which represents the SQL
  249. // database address used with remote persistent storage.
  250. func GetSQLAddress() string {
  251. return env.Get(SQLAddressEnvVar, "")
  252. }
  253. // IsUseCSVProvider returns the environment variable value for UseCSVProviderEnvVar which represents
  254. // whether or not the use of a CSV cost provider is enabled.
  255. func IsUseCSVProvider() bool {
  256. return env.GetBool(UseCSVProviderEnvVar, false)
  257. }
  258. // IsUseCustomProvider returns the environment variable value for UseCustomProviderEnvVar which represents
  259. // whether or not the use of a custom cost provider is enabled.
  260. func IsUseCustomProvider() bool {
  261. return env.GetBool(UseCustomProviderEnvVar, false)
  262. }
  263. // GetCSVRegion returns the environment variable value for CSVRegionEnvVar which represents the
  264. // region configured for a CSV provider.
  265. func GetCSVRegion() string {
  266. return env.Get(CSVRegionEnvVar, "")
  267. }
  268. // GetCSVEndpoint returns the environment variable value for CSVEndpointEnvVar which represents the
  269. // endpoint configured for a S3 CSV provider another than AWS S3.
  270. func GetCSVEndpoint() string {
  271. return env.Get(CSVEndpointEnvVar, "")
  272. }
  273. // GetCSVPath returns the environment variable value for CSVPathEnvVar which represents the key path
  274. // configured for a CSV provider.
  275. func GetCSVPath() string {
  276. return env.Get(CSVPathEnvVar, "")
  277. }
  278. // GetCostAnalyzerVolumeMountPath is an alias of GetConfigPath, which returns the mount path for the
  279. // Cost Analyzer volume, which stores configs, persistent data, etc.
  280. func GetCostAnalyzerVolumeMountPath() string {
  281. return GetConfigPathWithDefault(DefaultConfigMountPath)
  282. }
  283. // GetConfigPath returns the environment variable value for ConfigPathEnvVar which represents the cost
  284. // model configuration path
  285. func GetConfigPathWithDefault(defaultValue string) string {
  286. return env.Get(ConfigPathEnvVar, defaultValue)
  287. }
  288. // GetCloudProviderAPI returns the environment variable value for CloudProviderAPIEnvVar which represents
  289. // the API key provided for the cloud provider.
  290. func GetCloudProviderAPIKey() string {
  291. return env.Get(CloudProviderAPIKeyEnvVar, "")
  292. }
  293. func GetPVMountPath() string {
  294. return env.Get(PVMountPath, "")
  295. }
  296. // IsCollectorDataSourceEnabeled returns the environment variable which enables a source.OpencostDatasource which does not use uses Prometheus
  297. func IsCollectorDataSourceEnabled() bool {
  298. return env.GetBool(CollectorDataSourceEnabledEnvVar, false)
  299. }
  300. // IsLogCollectionEnabled returns the environment variable value for LogCollectionEnabledEnvVar which represents
  301. // whether or not log collection has been enabled for kubecost deployments.
  302. func IsLogCollectionEnabled() bool {
  303. return env.GetBool(LogCollectionEnabledEnvVar, true)
  304. }
  305. // IsProductAnalyticsEnabled returns the environment variable value for ProductAnalyticsEnabledEnvVar
  306. func IsProductAnalyticsEnabled() bool {
  307. return env.GetBool(ProductAnalyticsEnabledEnvVar, true)
  308. }
  309. // IsErrorReportingEnabled returns the environment variable value for ErrorReportingEnabledEnvVar
  310. func IsErrorReportingEnabled() bool {
  311. return env.GetBool(ErrorReportingEnabledEnvVar, true)
  312. }
  313. // IsValuesReportingEnabled returns the environment variable value for ValuesReportingEnabledEnvVar
  314. func IsValuesReportingEnabled() bool {
  315. return env.GetBool(ValuesReportingEnabledEnvVar, true)
  316. }
  317. // GetKubeConfigPath returns the environment variable value for KubeConfigPathEnvVar
  318. func GetKubeConfigPath() string {
  319. return env.Get(KubeConfigPathEnvVar, "")
  320. }
  321. // GetUTCOffset returns the environment variable value for UTCOffset
  322. func GetUTCOffset() string {
  323. return env.Get(UTCOffsetEnvVar, "")
  324. }
  325. // GetParsedUTCOffset returns the duration of the configured UTC offset
  326. func GetParsedUTCOffset() time.Duration {
  327. offset, err := timeutil.ParseUTCOffset(GetUTCOffset())
  328. if err != nil {
  329. log.Warnf("Failed to parse UTC offset: %s", err)
  330. return time.Duration(0)
  331. }
  332. return offset
  333. }
  334. func IsETLEnabled() bool {
  335. return env.GetBool(ETLEnabledEnvVar, true)
  336. }
  337. // GetETLResolution determines the resolution of ETL queries. The smaller the
  338. // duration, the higher the resolution; the higher the resolution, the more
  339. // accurate the query results, but the more computationally expensive.
  340. func GetETLResolution() time.Duration {
  341. // Use the configured ETL resolution, or default to
  342. // 5m (i.e. 300s)
  343. secs := time.Duration(env.GetInt64(ETLResolutionSeconds, 300))
  344. return secs * time.Second
  345. }
  346. // IsIngestingPodUID returns the env variable from ingestPodUID, which alters the
  347. // contents of podKeys in Allocation
  348. func IsIngestingPodUID() bool {
  349. return env.GetBool(IngestPodUIDEnvVar, false)
  350. }
  351. func IsAllocationNodeLabelsEnabled() bool {
  352. return env.GetBool(AllocationNodeLabelsEnabled, true)
  353. }
  354. func IsAssetIncludeLocalDiskCost() bool {
  355. return env.GetBool(AssetIncludeLocalDiskCostEnvVar, true)
  356. }
  357. func GetRegionOverrideList() []string {
  358. regionList := env.GetList(regionOverrideList, ",")
  359. if regionList == nil {
  360. return []string{}
  361. }
  362. return regionList
  363. }
  364. func GetDataRetentionDailyResolutionDays() int64 {
  365. return env.GetInt64(DataRetentionDailyResolutionDaysEnvVar, 30)
  366. }
  367. func GetDataRetentionHourlyResolutionHours() int64 {
  368. return env.GetInt64(DataRetentionHourlyResolutionHoursEnvVar, 49)
  369. }
  370. func IsKubernetesEnabled() bool {
  371. return env.Get(KubernetesEnabledEnvVar, "") != ""
  372. }
  373. func IsCloudCostEnabled() bool {
  374. return env.GetBool(CloudCostEnabledEnvVar, false)
  375. }
  376. func IsCustomCostEnabled() bool {
  377. return env.GetBool(CustomCostEnabledEnvVar, false)
  378. }
  379. func GetCloudCostConfigPath() string {
  380. return env.Get(CloudCostConfigPath, "cloud-integration.json")
  381. }
  382. func GetCloudCostMonthToDateInterval() int {
  383. return env.GetInt(CloudCostMonthToDateIntervalVar, 6)
  384. }
  385. func GetCloudCostRefreshRateHours() int64 {
  386. return env.GetInt64(CloudCostRefreshRateHoursEnvVar, 6)
  387. }
  388. func GetCloudCostQueryWindowDays() int64 {
  389. return env.GetInt64(CloudCostQueryWindowDaysEnvVar, 7)
  390. }
  391. func GetCustomCostQueryWindowHours() int64 {
  392. return env.GetInt64(CustomCostQueryWindowDaysEnvVar, 1)
  393. }
  394. func GetCustomCostQueryWindowDays() int64 {
  395. return env.GetInt64(CustomCostQueryWindowDaysEnvVar, 7)
  396. }
  397. func GetCloudCostRunWindowDays() int64 {
  398. return env.GetInt64(CloudCostRunWindowDaysEnvVar, 3)
  399. }
  400. func GetOCIPricingURL() string {
  401. return env.Get(OCIPricingURL, "https://apexapps.oracle.com/pls/apex/cetools/api/v1/products")
  402. }
  403. func GetPluginConfigDir() string {
  404. return env.Get(PluginConfigDirEnvVar, "/opt/opencost/plugin/config")
  405. }
  406. func GetPluginExecutableDir() string {
  407. return env.Get(PluginExecutableDirEnvVar, "/opt/opencost/plugin/bin")
  408. }
  409. func GetCustomCostRefreshRateHours() string {
  410. return env.Get(CustomCostRefreshRateHoursEnvVar, "12h")
  411. }
  412. func IsCarbonEstimatesEnabled() bool {
  413. return env.GetBool(CarbonEstimatesEnabledEnvVar, false)
  414. }
  415. func GetExportBucketConfigFile() string {
  416. return env.Get(ExportBucketConfigFileEnvVar, "")
  417. }
  418. // GetUseCacheV1 is a temporary flag to allow users to opt-in to using the old cache
  419. // Mainly for comparison purposes
  420. func GetUseCacheV1() bool {
  421. return env.GetBool(UseCacheV1, false)
  422. }
  423. func GetReleaseName() string {
  424. return env.Get(ReleaseNameEnvVar, "kubecost")
  425. }
  426. func GetNetworkCostsPort() int {
  427. return env.GetInt(NetworkCostsPortEnvVar, 3001)
  428. }
  429. // IsNodeStatsForceKubeProxy returns true if the node stats client should force the kube proxy direct end
  430. // point formatting
  431. func IsNodeStatsForceKubeProxy() bool {
  432. return env.GetBool(NodeStatsForceKubeProxyEnvVar, false)
  433. }
  434. // GetNodeStatsLocalProxy returns the fully qualified local proxy endpoint for the node stats client IFF the proxyAPI
  435. // is selected.
  436. func GetNodeStatsLocalProxy() string {
  437. return env.Get(NodeStatsLocalProxyEnvVar, "")
  438. }
  439. // IsNodeStatsInsecure returns true if the node stats client should skip TLS verification
  440. func IsNodeStatsInsecure() bool {
  441. return env.GetBool(NodeStatsInsecureEnvVar, false)
  442. }
  443. // GetNodeStatsCertFile returns the path of the cert file
  444. func GetNodeStatsCertFile() string {
  445. return env.Get(NodeStatsCertFileEnvVar, "")
  446. }
  447. // GetNodeStatsKeyFile returns the path of the key file
  448. func GetNodeStatsKeyFile() string {
  449. return env.Get(NodeStatsKeyFileEnvVar, "")
  450. }