func Out(input InputJSON, appJSONPath string, apiclient marathon.Marathoner) (IOOutput, error) {
	jsondata, err := parsePayload(input.Params, appJSONPath)
	if err != nil {
		return IOOutput{}, err
	}
	var marathonAPP gomarathon.Application
	if err = json.NewDecoder(jsondata).Decode(&marathonAPP); err != nil {
		return IOOutput{}, err
	}
	did, err := apiclient.UpdateApp(marathonAPP)
	if err != nil {
		return IOOutput{}, err
	}
	if err = checkDeploymentLoop(
		did.DeploymentID,
		time.Duration(input.Params.TimeOut),
		apiclient,
	); err != nil {
		return IOOutput{}, err
	}
	versions, err := apiclient.LatestVersions(marathonAPP.ID, "")
	if err != nil {
		return IOOutput{}, err
	}
	if versions[len(versions)-1] != did.Version {
		if !input.Params.RestartIfNoUpdate {
			return IOOutput{Version: Version{Ref: versions[len(versions)-1]}}, nil
		}
		if did, err = apiclient.RestartApp(marathonAPP.ID); err != nil {
			return IOOutput{}, err
		}
		if err = checkDeploymentLoop(
			did.DeploymentID,
			time.Duration(input.Params.TimeOut),
			apiclient,
		); err != nil {
			return IOOutput{}, err
		}
	}
	return IOOutput{Version: Version{Ref: did.Version}}, nil
}
Out shall deploy an APP to marathon based on marathon.json file.
package behaviors
import (
	"encoding/json"
	"errors"
	"time"
	"github.com/ckaznocha/marathon-resource/cmd/marathon-resource/marathon"
	gomarathon "github.com/gambol99/go-marathon"
)
type Params struct {
	AppJSON           string     `json:"app_json"`
	TimeOut           int        `json:"time_out"`
	Replacements      []Metadata `json:"replacements"`
	ReplacementFiles  []Metadata `json:"replacement_files"`
	RestartIfNoUpdate bool       `json:"restart_if_no_update"`
}
type Source struct {
	AppID     string              `json:"app_id"`
	URI       string              `json:"uri"`
	BasicAuth *marathon.AuthCreds `json:"basic_auth"`
	APIToken  string              `json:"api_token"`
}
type Version struct {
	Ref string `json:"ref"`
}
type InputJSON struct {
	Params  Params  `json:"params"`
	Source  Source  `json:"source"`
	Version Version `json:"version"`
}
type CheckOutput []Version
type Metadata struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}
type IOOutput struct {
	Version  Version    `json:"version"`
	Metadata []Metadata `json:"metadata"`
}