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

add backend support for https issuer

Alexander Belanger 4 лет назад
Родитель
Сommit
2c35fe9cea

+ 1 - 0
api/server/handlers/provision/provision_doks.go

@@ -112,6 +112,7 @@ func (c *ProvisionDOKSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 	opts.DOKS = &doks.Conf{
 		DORegion:        request.DORegion,
 		DOKSClusterName: request.DOKSName,
+		IssuerEmail:     request.IssuerEmail,
 	}
 
 	opts.OperationKind = provisioner.Apply

+ 1 - 0
api/server/handlers/provision/provision_eks.go

@@ -113,6 +113,7 @@ func (c *ProvisionEKSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 		AWSRegion:   awsInt.AWSRegion,
 		ClusterName: request.EKSName,
 		MachineType: request.MachineType,
+		IssuerEmail: request.IssuerEmail,
 	}
 	opts.OperationKind = provisioner.Apply
 

+ 1 - 0
api/server/handlers/provision/provision_gke.go

@@ -111,6 +111,7 @@ func (c *ProvisionGKEHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 	opts.CredentialExchange.VaultToken = vaultToken
 	opts.GKE = &gke.Conf{
 		ClusterName: request.GKEName,
+		IssuerEmail: request.IssuerEmail,
 	}
 
 	opts.OperationKind = provisioner.Apply

+ 3 - 0
api/types/provision.go

@@ -9,6 +9,7 @@ type CreateECRInfraRequest struct {
 type CreateEKSInfraRequest struct {
 	EKSName          string `json:"eks_name" form:"required"`
 	MachineType      string `json:"machine_type"`
+	IssuerEmail      string `json:"issuer_email" form:"required"`
 	ProjectID        uint   `json:"-" form:"required"`
 	AWSIntegrationID uint   `json:"aws_integration_id" form:"required"`
 }
@@ -20,6 +21,7 @@ type CreateGCRInfraRequest struct {
 
 type CreateGKEInfraRequest struct {
 	GKEName          string `json:"gke_name" form:"required"`
+	IssuerEmail      string `json:"issuer_email" form:"required"`
 	ProjectID        uint   `json:"-" form:"required"`
 	GCPIntegrationID uint   `json:"gcp_integration_id" form:"required"`
 }
@@ -33,6 +35,7 @@ type CreateDOCRInfraRequest struct {
 
 type CreateDOKSInfraRequest struct {
 	DORegion        string `json:"do_region" form:"required"`
+	IssuerEmail     string `json:"issuer_email" form:"required"`
 	DOKSName        string `json:"doks_name" form:"required"`
 	ProjectID       uint   `json:"-" form:"required"`
 	DOIntegrationID uint   `json:"do_integration_id" form:"required"`

+ 6 - 0
internal/kubernetes/provisioner/aws/eks/eks.go

@@ -7,6 +7,7 @@ type Conf struct {
 	AWSRegion   string
 	ClusterName string
 	MachineType string
+	IssuerEmail string
 }
 
 // AttachEKSEnv adds the relevant EKS env for the provisioner
@@ -26,5 +27,10 @@ func (conf *Conf) AttachEKSEnv(env []v1.EnvVar) []v1.EnvVar {
 		Value: conf.MachineType,
 	})
 
+	env = append(env, v1.EnvVar{
+		Name:  "ISSUER_EMAIL",
+		Value: conf.IssuerEmail,
+	})
+
 	return env
 }

+ 6 - 1
internal/kubernetes/provisioner/do/doks/doks.go

@@ -6,7 +6,7 @@ import (
 
 // Conf is just a DO token
 type Conf struct {
-	DORegion, DOKSClusterName string
+	DORegion, DOKSClusterName, IssuerEmail string
 }
 
 // AttachDOKSEnv adds the relevant DO env for the provisioner
@@ -21,5 +21,10 @@ func (conf *Conf) AttachDOKSEnv(env []v1.EnvVar) []v1.EnvVar {
 		Value: conf.DOKSClusterName,
 	})
 
+	env = append(env, v1.EnvVar{
+		Name:  "ISSUER_EMAIL",
+		Value: conf.IssuerEmail,
+	})
+
 	return env
 }

+ 6 - 1
internal/kubernetes/provisioner/gcp/gke/gke.go

@@ -4,7 +4,7 @@ import v1 "k8s.io/api/core/v1"
 
 // Conf is the GKE cluster config required for the provisioner
 type Conf struct {
-	ClusterName string
+	ClusterName, IssuerEmail string
 }
 
 // AttachGKEEnv adds the relevant GKE env for the provisioner
@@ -14,5 +14,10 @@ func (conf *Conf) AttachGKEEnv(env []v1.EnvVar) []v1.EnvVar {
 		Value: conf.ClusterName,
 	})
 
+	env = append(env, v1.EnvVar{
+		Name:  "ISSUER_EMAIL",
+		Value: conf.IssuerEmail,
+	})
+
 	return env
 }

+ 0 - 22
internal/kubernetes/provisioner/input/docr.go

@@ -1,22 +0,0 @@
-package input
-
-import (
-	"encoding/json"
-)
-
-type DOCR struct {
-	DOCRName             string `json:"docr_name"`
-	DOCRSubscriptionTier string `json:"docr_subscription_tier"`
-}
-
-func (docr *DOCR) GetInput() ([]byte, error) {
-	return json.Marshal(docr)
-}
-
-func GetDOCRInput(bytes []byte) (*DOCR, error) {
-	res := &DOCR{}
-
-	err := json.Unmarshal(bytes, res)
-
-	return res, err
-}

+ 0 - 22
internal/kubernetes/provisioner/input/doks.go

@@ -1,22 +0,0 @@
-package input
-
-import (
-	"encoding/json"
-)
-
-type DOKS struct {
-	DORegion    string `json:"do_region"`
-	ClusterName string `json:"cluster_name"`
-}
-
-func (doks *DOKS) GetInput() ([]byte, error) {
-	return json.Marshal(doks)
-}
-
-func GetDOKSInput(bytes []byte) (*DOKS, error) {
-	res := &DOKS{}
-
-	err := json.Unmarshal(bytes, res)
-
-	return res, err
-}

+ 0 - 22
internal/kubernetes/provisioner/input/ecr.go

@@ -1,22 +0,0 @@
-package input
-
-import (
-	"encoding/json"
-)
-
-type ECR struct {
-	AWSRegion string `json:"aws_region"`
-	ECRName   string `json:"ecr_name"`
-}
-
-func (ecr *ECR) GetInput() ([]byte, error) {
-	return json.Marshal(ecr)
-}
-
-func GetECRInput(bytes []byte) (*ECR, error) {
-	res := &ECR{}
-
-	err := json.Unmarshal(bytes, res)
-
-	return res, err
-}

+ 0 - 23
internal/kubernetes/provisioner/input/eks.go

@@ -1,23 +0,0 @@
-package input
-
-import (
-	"encoding/json"
-)
-
-type EKS struct {
-	AWSRegion   string `json:"aws_region"`
-	ClusterName string `json:"cluster_name"`
-	MachineType string `json:"machine_type"`
-}
-
-func (eks *EKS) GetInput() ([]byte, error) {
-	return json.Marshal(eks)
-}
-
-func GetEKSInput(bytes []byte) (*EKS, error) {
-	res := &EKS{}
-
-	err := json.Unmarshal(bytes, res)
-
-	return res, err
-}

+ 0 - 22
internal/kubernetes/provisioner/input/gcr.go

@@ -1,22 +0,0 @@
-package input
-
-import (
-	"encoding/json"
-)
-
-type GCR struct {
-	GCPRegion    string `json:"gcp_region"`
-	GCPProjectID string `json:"gcp_project_id"`
-}
-
-func (gcr *GCR) GetInput() ([]byte, error) {
-	return json.Marshal(gcr)
-}
-
-func GetGCRInput(bytes []byte) (*GCR, error) {
-	res := &GCR{}
-
-	err := json.Unmarshal(bytes, res)
-
-	return res, err
-}

+ 0 - 23
internal/kubernetes/provisioner/input/gke.go

@@ -1,23 +0,0 @@
-package input
-
-import (
-	"encoding/json"
-)
-
-type GKE struct {
-	GCPRegion    string `json:"gcp_region"`
-	GCPProjectID string `json:"gcp_project_id"`
-	ClusterName  string `json:"cluster_name"`
-}
-
-func (gke *GKE) GetInput() ([]byte, error) {
-	return json.Marshal(gke)
-}
-
-func GetGKEInput(bytes []byte) (*GKE, error) {
-	res := &GKE{}
-
-	err := json.Unmarshal(bytes, res)
-
-	return res, err
-}