// ExecutePlanItem executes a particular item in a deployment plan
ExecutePlanItem executes a particular item in a deployment plan
// ExecutePlanItem executes a particular item in a deployment plan
func (api *RestApi) ExecutePlanItem(plan types.Plan, targetDir string, verbose bool) (*io.ReadCloser, error) {
	var planResult *io.ReadCloser
	bufDeploy := new(bytes.Buffer)
	err := ziputils.Archive(targetDir, bufDeploy, &plan.Metadata)
	if err != nil {
		log.Print("Error creating deployment ZIP archive")
		log.Fatal(err)
	}
	deployStart := time.Now()
	if plan.Host == "" {
		if verbose {
			fmt.Println(fmt.Sprintf("Making Deploy Request: URL: [%s] Type: [%s]", plan.URL, plan.Type))
		}
		planResult, err = api.Connection.MakeRequest(
			http.MethodPost,
			plan.URL,
			bufDeploy,
			"application/zip",
		)
		if err != nil {
			return nil, err
		}
	} else {
		url := fmt.Sprintf("%s:%s/api/v2%s", plan.Host, plan.Port, plan.URL)
		if verbose {
			fmt.Println(fmt.Sprintf("Making Deploy Request: URL: [%s] Type: [%s]", url, plan.Type))
		}
		planResult, err = api.Connection.MakeJWTRequest(
			http.MethodPost,
			url,
			bufDeploy,
			"application/zip",
		)
		if err != nil {
			return nil, err
		}
	}
	if verbose {
		fmt.Println(text.SuccessWithTime("Success Deploying to Source", deployStart))
	}
	defer (*planResult).Close()
	return planResult, nil
}
func ( api * RestApi ) ExecutePlanItem ( plan types . Plan , targetDir string , verbose bool ) ( * io . ReadCloser , error ) { var planResult * io . ReadCloser bufDeploy := new ( bytes . Buffer ) err := ziputils . Archive ( targetDir , bufDeploy , & plan . Metadata ) if err != nil { log . Print ( " " ) log . Fatal ( err ) } deployStart := time . Now ( ) if plan . Host == " " { if verbose { fmt . Println ( fmt . Sprintf ( " " , plan . URL , plan . Type ) ) } planResult , err = api . Connection . MakeRequest ( http . MethodPost , plan . URL , bufDeploy , " " , ) if err != nil { return nil , err } } else { url := fmt . Sprintf ( " " , plan . Host , plan . Port , plan . URL ) if verbose { fmt . Println ( fmt . Sprintf ( " " , url , plan . Type ) ) } planResult , err = api . Connection . MakeJWTRequest ( http . MethodPost , url , bufDeploy , " " , ) if err != nil { return nil , err } } if verbose { fmt . Println ( text . SuccessWithTime ( " " , deployStart ) ) } defer ( * planResult ) . Close ( ) return planResult , nil }
ExecutePlanItem executes a particular item in a deployment plan
ExecutePlanItem executes a particular item in a deployment plan
// Create a buffer to write our archive to.