clusterservice.go 794 B

12345678910111213141516171819202122
  1. package services
  2. import (
  3. "path"
  4. "github.com/opencost/opencost/pkg/env"
  5. "github.com/opencost/opencost/pkg/services/clusters"
  6. )
  7. // NewClusterManagerService creates a new HTTPService implementation driving cluster definition management
  8. // for the frontend
  9. func NewClusterManagerService() HTTPService {
  10. return clusters.NewClusterManagerHTTPService(newClusterManager())
  11. }
  12. // newClusterManager creates a new cluster manager instance for use in the service
  13. func newClusterManager() *clusters.ClusterManager {
  14. clustersConfigFile := path.Join(env.GetConfigPathWithDefault("/var/configs/"), "clusters/default-clusters.yaml")
  15. // Return a memory-backed cluster manager populated by configmap
  16. return clusters.NewConfiguredClusterManager(clusters.NewMapDBClusterStorage(), clustersConfigFile)
  17. }