2
0
Эх сурвалжийг харах

add support for waitForJob in porter.yaml

Mohammed Nafees 4 жил өмнө
parent
commit
242e5a76c7
1 өөрчлөгдсөн 20 нэмэгдсэн , 0 устгасан
  1. 20 0
      cli/cmd/apply.go

+ 20 - 0
cli/cmd/apply.go

@@ -132,6 +132,8 @@ type Target struct {
 }
 
 type ApplicationConfig struct {
+	WaitForJob bool
+
 	Build struct {
 		Method     string
 		Context    string
@@ -315,6 +317,19 @@ func (d *Driver) applyApplication(resource *models.Resource, client *api.Client,
 		return nil, err
 	}
 
+	if d.source.Name == "job" && appConfig.WaitForJob {
+		color.New(color.FgYellow).Printf("Waiting for job '%s' to finish\n", resource.Name)
+
+		name = resource.Name
+		namespace = d.target.Namespace
+
+		err = waitForJob(nil, client, []string{})
+
+		if err != nil {
+			return nil, err
+		}
+	}
+
 	return resource, err
 }
 
@@ -623,6 +638,11 @@ func (d *Driver) getApplicationConfig(resource *models.Resource) (*ApplicationCo
 		return nil, err
 	}
 
+	if _, ok := resource.Config["waitForJob"]; !ok && d.source.Name == "job" {
+		// default to true and wait for the job to finish
+		config.WaitForJob = true
+	}
+
 	return config, nil
 }