cloudcost.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package env
  2. import (
  3. "github.com/opencost/opencost/core/pkg/env"
  4. )
  5. const (
  6. CloudCostConfigControllerStateFile = "cloud-configurations.json"
  7. CloudIntegrationConfigFile = "cloud-integration.json"
  8. AzureBillingDataDownloadPath = "db/cloudcost"
  9. )
  10. const (
  11. CloudCostEnabledEnvVar = "CLOUD_COST_ENABLED"
  12. CloudCostMonthToDateIntervalVar = "CLOUD_COST_MONTH_TO_DATE_INTERVAL"
  13. CloudCostRefreshRateHoursEnvVar = "CLOUD_COST_REFRESH_RATE_HOURS"
  14. CloudCostQueryWindowDaysEnvVar = "CLOUD_COST_QUERY_WINDOW_DAYS"
  15. CloudCostRunWindowDaysEnvVar = "CLOUD_COST_RUN_WINDOW_DAYS"
  16. CustomCostEnabledEnvVar = "CUSTOM_COST_ENABLED"
  17. CustomCostQueryWindowDaysEnvVar = "CUSTOM_COST_QUERY_WINDOW_DAYS"
  18. PluginConfigDirEnvVar = "PLUGIN_CONFIG_DIR"
  19. PluginExecutableDirEnvVar = "PLUGIN_EXECUTABLE_DIR"
  20. AzureDownloadBillingDataToDiskEnvVar = "AZURE_DOWNLOAD_BILLING_DATA_TO_DISK"
  21. )
  22. func IsCloudCostEnabled() bool {
  23. return env.GetBool(CloudCostEnabledEnvVar, false)
  24. }
  25. func IsCustomCostEnabled() bool {
  26. return env.GetBool(CustomCostEnabledEnvVar, false)
  27. }
  28. func GetCloudCostConfigPath() string {
  29. return env.GetPathFromConfig(CloudIntegrationConfigFile)
  30. }
  31. func GetCloudCostMonthToDateInterval() int {
  32. return env.GetInt(CloudCostMonthToDateIntervalVar, 6)
  33. }
  34. func GetCloudCostRefreshRateHours() int64 {
  35. return env.GetInt64(CloudCostRefreshRateHoursEnvVar, 6)
  36. }
  37. func GetCloudCostQueryWindowDays() int64 {
  38. return env.GetInt64(CloudCostQueryWindowDaysEnvVar, 7)
  39. }
  40. func GetCustomCostQueryWindowHours() int64 {
  41. return env.GetInt64(CustomCostQueryWindowDaysEnvVar, 1)
  42. }
  43. func GetCustomCostQueryWindowDays() int64 {
  44. return env.GetInt64(CustomCostQueryWindowDaysEnvVar, 7)
  45. }
  46. func GetCloudCostRunWindowDays() int64 {
  47. return env.GetInt64(CloudCostRunWindowDaysEnvVar, 3)
  48. }
  49. func GetPluginConfigDir() string {
  50. return env.Get(PluginConfigDirEnvVar, "/opt/opencost/plugin/config")
  51. }
  52. func GetPluginExecutableDir() string {
  53. return env.Get(PluginExecutableDirEnvVar, "/opt/opencost/plugin/bin")
  54. }
  55. func GetAzureDownloadBillingDataPath() string {
  56. return env.GetPathFromConfig(AzureBillingDataDownloadPath)
  57. }
  58. func GetCloudCostConfigControllerStateFile() string {
  59. return env.GetPathFromConfig(CloudCostConfigControllerStateFile)
  60. }