func (factory *marathonCreator) Create(params map[string]interface{}) (framework.Framework, error) { address, ok := params["address"] if !ok || fmt.Sprint(address) == "" { return nil, framework.NewInvalidFrameworkParameterError("address") } deployTimeout, ok := params["deploy-timeout"].(int) if !ok { return nil, framework.NewInvalidFrameworkParameterError("deploy-timeout") } authUser := utils.ExtractString(params, "basic-auth-user") authPwd := utils.ExtractString(params, "basic-auth-pwd") if authUser != "" && authPwd == "" { return nil, framework.NewInvalidFrameworkParameterError("basic-auth-pwd") } logFields, ok := params["log-metadata"].(map[string]interface{}) if !ok { logFields = log.Fields{} } parameters := &Parameters{ EndpointUrl: fmt.Sprint(address), DeployTimeout: deployTimeout, RetryTimes: utils.ExtractNaturalNumber(params, "retry-times"), HTTPBasicAuthUser: authUser, HTTPBasicAuthPassword: authPwd, DockerCfg: utils.ExtractString(params, "docker-cfg"), LogMetadata: logFields, } helper, err := NewMarathon(parameters) if err != nil { return nil, err } helper.healthCheckConf = &framework.HealthCheck{ GracePeriod: utils.ExtractNaturalNumber(params, "health-check-grace-period"), Interval: utils.ExtractNaturalNumber(params, "health-check-interval"), Timeout: utils.ExtractNaturalNumber(params, "health-check-timeout"), MaxConsecutiveFailures: utils.ExtractNaturalNumber(params, "health-check-max-consecutive-failures"), } return helper, nil }
func (factory *marathonCreator) Create(params map[string]interface{}) (framework.Framework, error) { address, ok := params["address"] if !ok || fmt.Sprint(address) == "" { return nil, errors.New("Parameter address does not exist") } deployTimeout, ok := params["deploy-timeout"].(int) if !ok { return nil, errors.New("Parameter deploy-timeout does not exist") } authUser := utils.ExtractString(params, "basic-auth-user") authPwd := utils.ExtractString(params, "basic-auth-pwd") if authUser != "" && authPwd == "" { return nil, errors.New("Parameter basic-auth-pwd does not exist") } parameters := &Parameters{ EndpointUrl: fmt.Sprint(address), DeployTimeout: deployTimeout, HTTPBasicAuthUser: authUser, HTTPBasicAuthPassword: authPwd, DockerCfg: utils.ExtractString(params, "docker-cfg"), } helper, err := NewMarathon(parameters) if err == nil { helper.healthCheckConf = &framework.HealthCheck{ GracePeriod: utils.ExtractNaturalNumber(params, "health-check-grace-period"), Interval: utils.ExtractNaturalNumber(params, "health-check-interval"), Timeout: utils.ExtractNaturalNumber(params, "health-check-timeout"), MaxConsecutiveFailures: utils.ExtractNaturalNumber(params, "health-check-max-consecutive-failures"), } } return helper, err }