Пример #1
0
func buildHealthCheckWithDefaults(params map[string]interface{}) *framework.HealthCheck {
	return &framework.HealthCheck{
		GracePeriod:            utils.ExtractNaturalNumberOrDefault(params, "health-check-grace-period", 60),
		Interval:               utils.ExtractNaturalNumberOrDefault(params, "health-check-interval", 10),
		Timeout:                utils.ExtractNaturalNumberOrDefault(params, "health-check-timeout", 2),
		MaxConsecutiveFailures: utils.ExtractNaturalNumberOrDefault(params, "health-check-max-consecutive-failures", 5),
	}
}
Пример #2
0
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")
	}
	if authUser == "" && authPwd != "" {
		return nil, framework.NewInvalidFrameworkParameterError("basic-auth-user")
	}

	logFields, ok := params["log-metadata"].(map[string]interface{})
	if !ok {
		logFields = log.Fields{}
	}

	defaultHc := buildHealthCheckWithDefaults(params)

	parameters := &Parameters{
		EndpointUrl:            fmt.Sprint(address),
		DeployTimeout:          deployTimeout,
		RetryTimes:             utils.ExtractNaturalNumberOrDefault(params, "retry-times", 3),
		HTTPBasicAuthUser:      authUser,
		HTTPBasicAuthPassword:  authPwd,
		DockerCfg:              utils.ExtractString(params, "docker-cfg"),
		LogMetadata:            logFields,
		defaultHealthCheckConf: defaultHc,
	}

	return newMarathon(parameters)
}