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

Merge pull request #1863 from porter-dev/master

Require subdomain for preview -> staging
abelanger5 4 лет назад
Родитель
Сommit
f9a8e795c4
3 измененных файлов с 31 добавлено и 6 удалено
  1. 1 1
      api/types/environment.go
  2. 3 3
      cli/cmd/job.go
  3. 27 2
      cli/cmd/preview/update_config_driver.go

+ 1 - 1
api/types/environment.go

@@ -63,7 +63,7 @@ type CreateDeploymentRequest struct {
 
 
 type FinalizeDeploymentRequest struct {
 type FinalizeDeploymentRequest struct {
 	Namespace string `json:"namespace" form:"required"`
 	Namespace string `json:"namespace" form:"required"`
-	Subdomain string `json:"subdomain"`
+	Subdomain string `json:"subdomain" form:"required"`
 }
 }
 
 
 type UpdateDeploymentRequest struct {
 type UpdateDeploymentRequest struct {

+ 3 - 3
cli/cmd/job.go

@@ -168,7 +168,7 @@ func waitForJob(_ *types.GetAuthenticatedUserResponse, client *api.Client, args
 
 
 	// attempt to parse out the timeout value for the job, given by `sidecar.timeout`
 	// attempt to parse out the timeout value for the job, given by `sidecar.timeout`
 	// if it does not exist, we set the default to 30 minutes
 	// if it does not exist, we set the default to 30 minutes
-	timeoutVal := getJobTimeoutValue(jobRelease.Release.Config)
+	timeoutVal := GetJobTimeoutValue(jobRelease.Release.Config)
 
 
 	color.New(color.FgYellow).Printf("Waiting for timeout seconds %.1f\n", timeoutVal.Seconds())
 	color.New(color.FgYellow).Printf("Waiting for timeout seconds %.1f\n", timeoutVal.Seconds())
 
 
@@ -229,7 +229,7 @@ func getJobMatchingRevision(revision uint, jobs []v1.Job) *v1.Job {
 	return nil
 	return nil
 }
 }
 
 
-func getJobTimeoutValue(values map[string]interface{}) time.Duration {
+func GetJobTimeoutValue(values map[string]interface{}) time.Duration {
 	defaultTimeout := time.Minute * 60
 	defaultTimeout := time.Minute * 60
 	sidecarInter, ok := values["sidecar"]
 	sidecarInter, ok := values["sidecar"]
 
 
@@ -249,7 +249,7 @@ func getJobTimeoutValue(values map[string]interface{}) time.Duration {
 		return defaultTimeout
 		return defaultTimeout
 	}
 	}
 
 
-	timeoutVal, ok := timeoutInter.(int64)
+	timeoutVal, ok := timeoutInter.(float64)
 
 
 	if !ok {
 	if !ok {
 		return defaultTimeout
 		return defaultTimeout

+ 27 - 2
cli/cmd/preview/update_config_driver.go

@@ -8,9 +8,11 @@ import (
 	"github.com/cli/cli/git"
 	"github.com/cli/cli/git"
 	"github.com/fatih/color"
 	"github.com/fatih/color"
 	"github.com/mitchellh/mapstructure"
 	"github.com/mitchellh/mapstructure"
+	api "github.com/porter-dev/porter/api/client"
 	"github.com/porter-dev/porter/api/types"
 	"github.com/porter-dev/porter/api/types"
 	"github.com/porter-dev/porter/cli/cmd/config"
 	"github.com/porter-dev/porter/cli/cmd/config"
 	"github.com/porter-dev/porter/cli/cmd/deploy"
 	"github.com/porter-dev/porter/cli/cmd/deploy"
+	"github.com/porter-dev/porter/internal/templater/utils"
 	"github.com/porter-dev/switchboard/pkg/drivers"
 	"github.com/porter-dev/switchboard/pkg/drivers"
 	"github.com/porter-dev/switchboard/pkg/models"
 	"github.com/porter-dev/switchboard/pkg/models"
 )
 )
@@ -118,13 +120,12 @@ func (d *UpdateConfigDriver) Apply(resource *models.Resource) (*models.Resource,
 			},
 			},
 		}
 		}
 
 
-		subdomain, err := createAgent.CreateFromRegistry(d.config.UpdateConfig.Image, d.config.Values)
+		_, err := createAgent.CreateFromRegistry(d.config.UpdateConfig.Image, d.config.Values)
 
 
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err
 		}
 		}
 
 
-		d.output["live_url"] = subdomain
 	} else {
 	} else {
 		updateAgent, err := deploy.NewDeployAgent(client, d.target.AppName, &deploy.DeployOpts{
 		updateAgent, err := deploy.NewDeployAgent(client, d.target.AppName, &deploy.DeployOpts{
 			SharedOpts: sharedOpts,
 			SharedOpts: sharedOpts,
@@ -142,6 +143,12 @@ func (d *UpdateConfigDriver) Apply(resource *models.Resource) (*models.Resource,
 		}
 		}
 	}
 	}
 
 
+	err = d.assignOutput(resource, client)
+
+	if err != nil {
+		return nil, err
+	}
+
 	return resource, nil
 	return resource, nil
 }
 }
 
 
@@ -170,3 +177,21 @@ func (d *UpdateConfigDriver) getConfig(resource *models.Resource) (*UpdateConfig
 
 
 	return config, nil
 	return config, nil
 }
 }
+
+func (d *UpdateConfigDriver) assignOutput(resource *models.Resource, client *api.Client) error {
+	release, err := client.GetRelease(
+		context.Background(),
+		d.target.Project,
+		d.target.Cluster,
+		d.target.Namespace,
+		d.target.AppName,
+	)
+
+	if err != nil {
+		return err
+	}
+
+	d.output = utils.CoalesceValues(d.source.SourceValues, release.Config)
+
+	return nil
+}