Ejemplo n.º 1
1
func getConfiguredFormFieldNames(formName string, v *viper.Viper) []string {
	configuredFields := v.GetStringMapString("stormpath.web." + formName + ".form.fields")
	fieldOrder := v.GetStringSlice("stormpath.web." + formName + ".form.fieldOrder")

	for fieldName := range configuredFields {
		if !contains(fieldOrder, fieldName) {
			fieldOrder = append(fieldOrder, fieldName)
		}
	}
	return fieldOrder
}
Ejemplo n.º 2
0
// gets the required gun prefixes accepted by this server
func getRequiredGunPrefixes(configuration *viper.Viper) ([]string, error) {
	prefixes := configuration.GetStringSlice("repositories.gun_prefixes")
	for _, prefix := range prefixes {
		p := path.Clean(strings.TrimSpace(prefix))
		if p+"/" != prefix || strings.HasPrefix(p, "/") || strings.HasPrefix(p, "..") {
			return nil, fmt.Errorf("invalid GUN prefix %s", prefix)
		}
	}
	return prefixes, nil
}
Ejemplo n.º 3
-1
func loadConfig(v *viper.Viper) *runnerConf {
	v.SetDefault("check_timeout", 10)
	v.SetDefault("host_window", 60)
	v.SetDefault("host_threshold", 5)
	v.SetDefault("flood_window", 120)
	v.SetDefault("flood_threshold", 100)
	v.SetDefault("flap_window", 1200)
	v.SetDefault("flap_threshold", 5)
	v.SetDefault("alert_threshold", 3)
	v.SetDefault("worker_id", "worker1")
	v.SetDefault("check_key", "canhazstatus")
	conf := &runnerConf{}
	conf.checkTimeout = v.GetDuration("check_timeout")
	conf.hostWindow = int64(v.GetInt("host_window"))
	conf.hostThreshold = v.GetInt("host_threshold")
	conf.floodWindow = int64(v.GetInt("flood_window"))
	conf.floodThreshold = v.GetInt("flood_threshold")
	conf.flapWindow = v.GetInt("flap_window")
	conf.flapThreshold = v.GetInt("flap_threshold")
	conf.alertThreshold = v.GetInt("alert_threshold")
	conf.workerQueue = v.GetString("worker_id")
	conf.checkKey = v.GetString("check_key")

	//twilio config
	v.SetDefault("twilio_enable", false)
	conf.twilioEnabled = v.GetBool("twilio_enable")
	conf.twsid = v.GetString("twiliosid")
	conf.twtoken = v.GetString("twiliotoken")
	conf.twfrom = v.GetString("twiliofrom")
	conf.twdest = v.GetStringSlice("twiliodest")

	//pagerduty config
	v.SetDefault("pagerduty_enable", false)
	conf.pagerDutyEnabled = v.GetBool("pagerduty_enable")
	conf.pagerDutyPriOneKey = v.GetString("pagerduty_priority_one_key")
	conf.pagerDutyPriTwoKey = v.GetString("pagerduty_priority_two_key")
	conf.pagerDutyIncidentKeyPrefix = v.GetString("pagerduty_incident_key_prefix")

	return conf
}