Ver código fonte

fix project update check, add prometheus url env

Mauricio Araujo 2 anos atrás
pai
commit
7d0db89b6a

+ 8 - 5
api/server/handlers/project/create.go

@@ -3,6 +3,7 @@ package project
 import (
 	"net/http"
 
+	"github.com/google/uuid"
 	"github.com/porter-dev/porter/api/server/handlers"
 	"github.com/porter-dev/porter/api/server/shared"
 	"github.com/porter-dev/porter/api/server/shared/apierrors"
@@ -110,11 +111,13 @@ func (p *ProjectCreateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 		)
 	}
 
-	_, err = p.Repo().Project().UpdateProject(proj)
-	if err != nil {
-		err := telemetry.Error(ctx, span, err, "error updating project")
-		p.HandleAPIError(w, r, apierrors.NewErrInternal(err))
-		return
+	if proj.BillingID != "" || proj.UsageID != uuid.Nil {
+		_, err = p.Repo().Project().UpdateProject(proj)
+		if err != nil {
+			err := telemetry.Error(ctx, span, err, "error updating project")
+			p.HandleAPIError(w, r, apierrors.NewErrInternal(err))
+			return
+		}
 	}
 
 	// create default project usage restriction

+ 4 - 0
api/server/shared/config/env/envconfs.go

@@ -74,6 +74,10 @@ type ServerConf struct {
 	MetronomeAPIKey      string `env:"METRONOME_API_KEY"`
 	PorterCloudPlanID    string `env:"PORTER_CLOUD_PLAN_ID"`
 
+	// This endpoint will be passed to the porter-agent so that
+	// the billing manager can query Prometheus.
+	PrometheusUrl string `env:"PROMETHEUS_URL"`
+
 	SlackClientID     string `env:"SLACK_CLIENT_ID"`
 	SlackClientSecret string `env:"SLACK_CLIENT_SECRET"`