|
|
@@ -34,13 +34,22 @@ func Healthz(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
|
|
|
|
|
|
func Execute(opts *CostModelOpts) error {
|
|
|
log.Infof("Starting cost-model version %s", version.FriendlyVersion())
|
|
|
- a := costmodel.Initialize()
|
|
|
+ log.Infof("Kubernetes enabled: %t", env.IsKubernetesEnabled())
|
|
|
|
|
|
- err := StartExportWorker(context.Background(), a.Model)
|
|
|
- if err != nil {
|
|
|
- log.Errorf("couldn't start CSV export worker: %v", err)
|
|
|
+ var a *costmodel.Accesses
|
|
|
+
|
|
|
+ if env.IsKubernetesEnabled() {
|
|
|
+ a = costmodel.Initialize()
|
|
|
+ err := StartExportWorker(context.Background(), a.Model)
|
|
|
+ if err != nil {
|
|
|
+ log.Errorf("couldn't start CSV export worker: %v", err)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ a = costmodel.InitializeWithoutKubernetes()
|
|
|
+ log.Debugf("Cloud Cost config path: %s", env.GetCloudCostConfigPath())
|
|
|
}
|
|
|
|
|
|
+ log.Infof("Cloud Costs enabled: %t", env.IsCloudCostEnabled())
|
|
|
if env.IsCloudCostEnabled() {
|
|
|
repo := cloudcost.NewMemoryRepository()
|
|
|
a.CloudCostPipelineService = cloudcost.NewPipelineService(repo, a.CloudConfigController, cloudcost.DefaultIngestorConfiguration())
|
|
|
@@ -50,9 +59,12 @@ func Execute(opts *CostModelOpts) error {
|
|
|
|
|
|
rootMux := http.NewServeMux()
|
|
|
a.Router.GET("/healthz", Healthz)
|
|
|
- a.Router.GET("/allocation", a.ComputeAllocationHandler)
|
|
|
- a.Router.GET("/allocation/summary", a.ComputeAllocationHandlerSummary)
|
|
|
- a.Router.GET("/assets", a.ComputeAssetsHandler)
|
|
|
+
|
|
|
+ if env.IsKubernetesEnabled() {
|
|
|
+ a.Router.GET("/allocation", a.ComputeAllocationHandler)
|
|
|
+ a.Router.GET("/allocation/summary", a.ComputeAllocationHandlerSummary)
|
|
|
+ a.Router.GET("/assets", a.ComputeAssetsHandler)
|
|
|
+ }
|
|
|
|
|
|
a.Router.GET("/cloudCost", a.CloudCostQueryService.GetCloudCostHandler())
|
|
|
a.Router.GET("/cloudCost/view/graph", a.CloudCostQueryService.GetCloudCostViewGraphHandler())
|