Просмотр исходного кода

fix infra responses + quick billing fix

Alexander Belanger 4 лет назад
Родитель
Сommit
9c86af4193
2 измененных файлов с 16 добавлено и 28 удалено
  1. 4 3
      ee/billing/ironplans.go
  2. 12 25
      internal/models/infra.go

+ 4 - 3
ee/billing/ironplans.go

@@ -239,9 +239,10 @@ func (c *Client) GetIDToken(projectID uint, user *cemodels.User) (token string,
 			Model: &gorm.Model{
 				ID: userBilling.ID,
 			},
-			ProjectID: projectID,
-			UserID:    user.ID,
-			Token:     []byte(token),
+			ProjectID:  projectID,
+			UserID:     user.ID,
+			Token:      []byte(token),
+			TeammateID: userBilling.TeammateID,
 		})
 
 		if err != nil {

+ 12 - 25
internal/models/infra.go

@@ -9,7 +9,6 @@ import (
 	"gorm.io/gorm"
 
 	"github.com/porter-dev/porter/api/types"
-	"github.com/porter-dev/porter/internal/kubernetes/provisioner/input"
 )
 
 // Infra represents the metadata for an infrastructure type provisioned on
@@ -72,70 +71,58 @@ func (i *Infra) SafelyGetLastApplied() map[string]string {
 
 	switch i.Kind {
 	case types.InfraECR:
-		lastApplied := &input.ECR{}
+		lastApplied := &types.CreateECRInfraRequest{}
 
 		if err := json.Unmarshal(i.LastApplied, lastApplied); err != nil {
 			return resp
 		}
 
-		resp["region"] = lastApplied.AWSRegion
+		resp["ecr_name"] = lastApplied.ECRName
 
 		return resp
 	case types.InfraEKS:
-		lastApplied := &input.EKS{}
+		lastApplied := &types.CreateEKSInfraRequest{}
 
 		if err := json.Unmarshal(i.LastApplied, lastApplied); err != nil {
 			return resp
 		}
 
-		resp["region"] = lastApplied.AWSRegion
-		resp["cluster_name"] = lastApplied.ClusterName
+		resp["eks_name"] = lastApplied.EKSName
 		resp["machine_type"] = lastApplied.MachineType
 
 		return resp
 	case types.InfraGCR:
-		lastApplied := &input.GCR{}
-
-		if err := json.Unmarshal(i.LastApplied, lastApplied); err != nil {
-			return resp
-		}
-
-		resp["project_id"] = lastApplied.GCPProjectID
-		resp["region"] = lastApplied.GCPRegion
-
 		return resp
 	case types.InfraGKE:
-		lastApplied := &input.GKE{}
+		lastApplied := &types.CreateGKEInfraRequest{}
 
 		if err := json.Unmarshal(i.LastApplied, lastApplied); err != nil {
 			return resp
 		}
 
-		resp["project_id"] = lastApplied.GCPProjectID
-		resp["region"] = lastApplied.GCPRegion
-		resp["cluster_name"] = lastApplied.ClusterName
+		resp["gke_name"] = lastApplied.GKEName
 
 		return resp
 	case types.InfraDOCR:
-		lastApplied := &input.DOCR{}
+		lastApplied := &types.CreateDOCRInfraRequest{}
 
 		if err := json.Unmarshal(i.LastApplied, lastApplied); err != nil {
 			return resp
 		}
 
-		resp["name"] = lastApplied.DOCRName
-		resp["subscription_tier"] = lastApplied.DOCRSubscriptionTier
+		resp["docr_name"] = lastApplied.DOCRName
+		resp["docr_subscription_tier"] = lastApplied.DOCRSubscriptionTier
 
 		return resp
 	case types.InfraDOKS:
-		lastApplied := &input.DOKS{}
+		lastApplied := &types.CreateDOKSInfraRequest{}
 
 		if err := json.Unmarshal(i.LastApplied, lastApplied); err != nil {
 			return resp
 		}
 
-		resp["cluster_name"] = lastApplied.ClusterName
-		resp["region"] = lastApplied.DORegion
+		resp["cluster_name"] = lastApplied.DOKSName
+		resp["do_region"] = lastApplied.DORegion
 
 		return resp
 	}