Procházet zdrojové kódy

initial provisioner gcp setup

Alexander Belanger před 5 roky
rodič
revize
f2f4146691

+ 4 - 0
cli/cmd/connect/ecr.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"context"
 	"fmt"
 	"fmt"
 	"strings"
 	"strings"
+	"time"
 
 
 	"github.com/fatih/color"
 	"github.com/fatih/color"
 	"github.com/porter-dev/porter/cli/cmd/api"
 	"github.com/porter-dev/porter/cli/cmd/api"
@@ -50,6 +51,9 @@ Would you like to proceed? %s `,
 			return ecrManual(client, projectID, region)
 			return ecrManual(client, projectID, region)
 		}
 		}
 
 
+		// sleep for a few seconds to allow aws to reconfigure
+		time.Sleep(3 * time.Second)
+
 		integration, err := client.CreateAWSIntegration(
 		integration, err := client.CreateAWSIntegration(
 			context.Background(),
 			context.Background(),
 			projectID,
 			projectID,

+ 2 - 0
internal/forms/integration.go

@@ -11,6 +11,7 @@ type CreateGCPIntegrationForm struct {
 	ProjectID    uint   `json:"project_id" form:"required"`
 	ProjectID    uint   `json:"project_id" form:"required"`
 	GCPKeyData   string `json:"gcp_key_data" form:"required"`
 	GCPKeyData   string `json:"gcp_key_data" form:"required"`
 	GCPProjectID string `json:"gcp_project_id"`
 	GCPProjectID string `json:"gcp_project_id"`
+	GCPRegion    string `json:"gcp_region"`
 }
 }
 
 
 // ToGCPIntegration converts the project to a gorm project model
 // ToGCPIntegration converts the project to a gorm project model
@@ -20,6 +21,7 @@ func (cgf *CreateGCPIntegrationForm) ToGCPIntegration() (*ints.GCPIntegration, e
 		ProjectID:    cgf.ProjectID,
 		ProjectID:    cgf.ProjectID,
 		GCPKeyData:   []byte(cgf.GCPKeyData),
 		GCPKeyData:   []byte(cgf.GCPKeyData),
 		GCPProjectID: cgf.GCPProjectID,
 		GCPProjectID: cgf.GCPProjectID,
+		GCPRegion:    cgf.GCPRegion,
 	}, nil
 	}, nil
 }
 }
 
 

+ 30 - 0
internal/kubernetes/provisioner/gcp/gcp.go

@@ -0,0 +1,30 @@
+package aws
+
+import (
+	v1 "k8s.io/api/core/v1"
+)
+
+// Conf wraps the GCP integration model
+type Conf struct {
+	GCPRegion, GCPProjectID, GCPKeyData string
+}
+
+// AttachGCPEnv adds the relevant AWS env for the provisioner
+func (conf *Conf) AttachGCPEnv(env []v1.EnvVar) []v1.EnvVar {
+	env = append(env, v1.EnvVar{
+		Name:  "GCP_REGION",
+		Value: conf.GCPRegion,
+	})
+
+	env = append(env, v1.EnvVar{
+		Name:  "GCP_CREDENTIALS",
+		Value: conf.GCPKeyData,
+	})
+
+	env = append(env, v1.EnvVar{
+		Name:  "GCP_PROJECT_ID",
+		Value: conf.GCPProjectID,
+	})
+
+	return env
+}

+ 4 - 1
internal/models/integrations/gcp.go

@@ -19,11 +19,14 @@ type GCPIntegration struct {
 	ProjectID uint `json:"project_id"`
 	ProjectID uint `json:"project_id"`
 
 
 	// The GCP project id where the service account for this auth mechanism persists
 	// The GCP project id where the service account for this auth mechanism persists
-	GCPProjectID string `json:"gcp-project-id"`
+	GCPProjectID string `json:"gcp_project_id"`
 
 
 	// The GCP user email that linked this service account
 	// The GCP user email that linked this service account
 	GCPUserEmail string `json:"gcp-user-email"`
 	GCPUserEmail string `json:"gcp-user-email"`
 
 
+	// The GCP region, which may or may not be used by the integration
+	GCPRegion string `json:"gcp_region"`
+
 	// ------------------------------------------------------------------
 	// ------------------------------------------------------------------
 	// All fields encrypted before storage.
 	// All fields encrypted before storage.
 	// ------------------------------------------------------------------
 	// ------------------------------------------------------------------