Pārlūkot izejas kodu

create deployment for each preview run

Alexander Belanger 4 gadi atpakaļ
vecāks
revīzija
b0d17cb7e0
1 mainītis faili ar 6 papildinājumiem un 21 dzēšanām
  1. 6 21
      cli/cmd/apply.go

+ 6 - 21
cli/cmd/apply.go

@@ -666,32 +666,17 @@ func NewDeploymentHook(client *api.Client, resourceGroup *switchboardTypes.Resou
 }
 
 func (t *DeploymentHook) PreApply() error {
-	// attempt to read the deployment -- if it doesn't exist, create it
-	_, err := t.client.GetDeployment(
+	_, err := t.client.CreateDeployment(
 		context.Background(),
 		t.projectID, t.gitInstallationID, t.clusterID,
-		&types.GetDeploymentRequest{
-			Namespace: t.namespace,
+		&types.CreateDeploymentRequest{
+			Namespace:     t.namespace,
+			PullRequestID: t.prID,
+			Branch:        t.branch,
+			ActionID:      t.actionID,
 		},
 	)
 
-	// TODO: case this on the response status code rather than text
-	if err != nil && strings.Contains(err.Error(), "deployment not found") {
-		// in this case, create the deployment
-		_, err = t.client.CreateDeployment(
-			context.Background(),
-			t.projectID, t.gitInstallationID, t.clusterID,
-			&types.CreateDeploymentRequest{
-				Namespace:     t.namespace,
-				PullRequestID: t.prID,
-				Branch:        t.branch,
-				ActionID:      t.actionID,
-			},
-		)
-
-		return err
-	}
-
 	return err
 }