// Configure creates a new identity middleware and registers that to the app.
338136
func Configure(b *bootstrap.Bootstrapper) {
	h := New(b)
	b.UseGlobal(h)
}
735878
func (b *Bootstrapper) Configure(cs ...Configurator) {
	for _, c := range cs {
		c(b)
	}
}
475684
func (format *MetadataCopy) Configure(conf core.PluginConfigReader) {
	mode := conf.GetString("Mode", "replace")
	switch strings.ToLower(mode) {
	case "replace":
		format.mode = metadataCopyModeReplace
	case "append":
		format.mode = metadataCopyModeAppend
	case "prepend":
		format.mode = metadataCopyModePrepend
	default:
		conf.Errors.Pushf("mode must be one of replace, append or prepend")
	}
}
435912
func (filter *JSON) Configure(conf core.PluginConfigReader) {
	rejectValues := conf.GetStringMap("Reject", make(map[string]string))
	acceptValues := conf.GetStringMap("Accept", make(map[string]string))

	// Compile regexp from map[string]string to map[string]*regexp.Regexp
	filter.rejectValues = make(map[string]*regexp.Regexp)
	filter.acceptValues = make(map[string]*regexp.Regexp)

	for key, val := range rejectValues {
		exp, err := regexp.Compile(val)
		if !conf.Errors.Push(err) {
			filter.rejectValues[key] = exp
		}
	}

	for key, val := range acceptValues {
		exp, err := regexp.Compile(val)
		if !conf.Errors.Push(err) {
			filter.acceptValues[key] = exp
		}
	}

	applyTo := conf.GetString("ApplyTo", "")
	filter.getAppliedContent = core.GetAppliedContentGetFunction(applyTo)
}
8514
func (c *ConsulProvider) Configure(clusterID string, isRoot bool, rawConfig map[string]interface{}) error {
	// Parse the raw config and update our ID.
	config, err := ParseConsulCAConfig(rawConfig)
	if err != nil {
		return err
	}
	c.config = config
	hash := sha256.Sum256([]byte(fmt.Sprintf("%s,%s,%v", config.PrivateKey, config.RootCert, isRoot)))
	c.id = strings.Replace(fmt.Sprintf("% x", hash), " ", ":", -1)
	c.clusterID = clusterID
	c.isRoot = isRoot
	c.spiffeID = connect.SpiffeIDSigningForCluster(&structs.CAConfiguration{ClusterID: clusterID})

	// Exit early if the state store has an entry for this provider's config.
	_, providerState, err := c.Delegate.State().CAProviderState(c.id)
	if err != nil {
		return err
	}

	if providerState != nil {
		return nil
	}

	// Check if there's an entry with the old ID scheme.
	oldID := fmt.Sprintf("%s,%s", config.PrivateKey, config.RootCert)
	_, providerState, err = c.Delegate.State().CAProviderState(oldID)
	if err != nil {
		return err
	}

	// Found an entry with the old ID, so update it to the new ID and
	// delete the old entry.
	if providerState != nil {
		newState := *providerState
		newState.ID = c.id
		createReq := &structs.CARequest{
			Op:            structs.CAOpSetProviderState,
			ProviderState: &newState,
		}
		if err := c.Delegate.ApplyCARequest(createReq); err != nil {
			return err
		}

		deleteReq := &structs.CARequest{
			Op:            structs.CAOpDeleteProviderState,
			ProviderState: providerState,
		}
		if err := c.Delegate.ApplyCARequest(deleteReq); err != nil {
			return err
		}

		return nil
	}

	// Write the provider state to the state store.
	newState := structs.CAConsulProviderState{
		ID: c.id,
	}

	args := &structs.CARequest{
		Op:            structs.CAOpSetProviderState,
		ProviderState: &newState,
	}
	if err := c.Delegate.ApplyCARequest(args); err != nil {
		return err
	}

	return nil
}
943170
func (rotate *RotateConfig) Configure(conf core.PluginConfigReader) {
	rotateAt := conf.GetString("Rotation/At", "")
	if rotateAt != "" {
		parts := strings.Split(rotateAt, ":")
		rotateAtHour, _ := strconv.ParseInt(parts[0], 10, 8)
		rotateAtMin, _ := strconv.ParseInt(parts[1], 10, 8)

		rotate.AtHour = int(rotateAtHour)
		rotate.AtMinute = int(rotateAtMin)
	}
}
369521
func (router *RoundRobin) Configure(conf core.PluginConfigReader) {
	router.index = 0
	router.indexByStream = make(map[core.MessageStreamID]*int32)
	router.mapInitLock = new(sync.Mutex)
}
819736
func Configure() *Configuration {
	return &Configuration{
		buckets:        16,
		itemsToPrune:   500,
		deleteBuffer:   1024,
		getsPerPromote: 3,
		promoteBuffer:  1024,
		maxSize:        5000,
		tracking:       false,
	}
}
683254
func (cons *Profiler) Configure(conf core.PluginConfigReader) {
	numTemplates := conf.GetInt("TemplateCount", 10)
	cons.templates = make([][]byte, numTemplates)
}
1357264
func Configure(clf *CommandLineFlags, cfg *service.Config) error {
	// pass the value of --insecure flag to the runtime
	lib.SetInsecureDevMode(clf.InsecureMode)

	// load /etc/teleport.yaml and apply it's values:
	fileConf, err := ReadConfigFile(clf.ConfigFile)
	if err != nil {
		return trace.Wrap(err)
	}
	// if configuration is passed as an environment variable,
	// try to decode it and override the config file
	if clf.ConfigString != "" {
		fileConf, err = ReadFromString(clf.ConfigString)
		if err != nil {
			return trace.Wrap(err)
		}
	}

	// apply command line --debug flag to override logger severity
	if fileConf != nil && clf.Debug {
		fileConf.Logger.Severity = teleport.DebugLevel
	}

	if err = ApplyFileConfig(fileConf, cfg); err != nil {
		return trace.Wrap(err)
	}

	// Apply diagnostic address flag.
	if clf.DiagnosticAddr != "" {
		addr, err := utils.ParseAddr(clf.DiagnosticAddr)
		if err != nil {
			return trace.Wrap(err, "failed to parse diag-addr")
		}
		cfg.DiagnosticAddr = *addr
	}

	// apply --insecure-no-tls flag:
	if clf.DisableTLS {
		cfg.Proxy.DisableTLS = clf.DisableTLS
	}

	// apply --debug flag to config:
	if clf.Debug {
		cfg.Console = ioutil.Discard
		cfg.Debug = clf.Debug
	}

	// apply --roles flag:
	if clf.Roles != "" {
		if err := validateRoles(clf.Roles); err != nil {
			return trace.Wrap(err)
		}
		cfg.SSH.Enabled = strings.Index(clf.Roles, defaults.RoleNode) != -1
		cfg.Auth.Enabled = strings.Index(clf.Roles, defaults.RoleAuthService) != -1
		cfg.Proxy.Enabled = strings.Index(clf.Roles, defaults.RoleProxy) != -1
	}

	// apply --auth-server flag:
	if clf.AuthServerAddr != "" {
		if cfg.Auth.Enabled {
			log.Warnf("not starting the local auth service. --auth-server flag tells to connect to another auth server")
			cfg.Auth.Enabled = false
		}
		addr, err := utils.ParseHostPortAddr(clf.AuthServerAddr, int(defaults.AuthListenPort))
		if err != nil {
			return trace.Wrap(err)
		}
		log.Infof("Using auth server: %v", addr.FullAddress())
		cfg.AuthServers = []utils.NetAddr{*addr}
	}

	// apply --name flag:
	if clf.NodeName != "" {
		cfg.Hostname = clf.NodeName
	}

	// apply --pid-file flag
	if clf.PIDFile != "" {
		cfg.PIDFile = clf.PIDFile
	}

	// apply --token flag:
	cfg.ApplyToken(clf.AuthToken)

	// Apply flags used for the node to validate the Auth Server.
	if clf.CAPin != "" {
		cfg.CAPin = clf.CAPin
	}

	// apply --listen-ip flag:
	if clf.ListenIP != nil {
		applyListenIP(clf.ListenIP, cfg)
	}

	// --advertise-ip flag
	if clf.AdvertiseIP != "" {
		if _, _, err := utils.ParseAdvertiseAddr(clf.AdvertiseIP); err != nil {
			return trace.Wrap(err)
		}
		cfg.AdvertiseIP = clf.AdvertiseIP
	}

	// apply --labels flag
	if err = parseLabels(clf.Labels, &cfg.SSH); err != nil {
		return trace.Wrap(err)
	}

	// --pid-file:
	if clf.PIDFile != "" {
		cfg.PIDFile = clf.PIDFile
	}

	// auth_servers not configured, but the 'auth' is enabled (auth is on localhost)?
	if len(cfg.AuthServers) == 0 && cfg.Auth.Enabled {
		cfg.AuthServers = append(cfg.AuthServers, cfg.Auth.SSHAddr)
	}

	// add data_dir to the backend config:
	if cfg.Auth.StorageConfig.Params == nil {
		cfg.Auth.StorageConfig.Params = backend.Params{}
	}
	cfg.Auth.StorageConfig.Params["data_dir"] = cfg.DataDir
	// command line flag takes precedence over file config
	if clf.PermitUserEnvironment {
		cfg.SSH.PermitUserEnvironment = true
	}

	return nil
}
335921
func (s *Recipes) SetConfigure(v []*string) *Recipes {
	s.Configure = v
	return s
}
519234
func (format *TextToJSON) Configure(conf core.PluginConfigReader) {
	format.parser = tstrings.NewTransitionParser()
	format.state = jsonReadObject
	format.timeParse = time.Parse
	format.parseLock = new(sync.Mutex)

	unixRead := conf.GetString("UnixTimestampRead", "")
	if format.timeRead == "" {
		if unixRead == "" {
			// Use default when neither are specified
			format.timeRead = "20060102150405"
		} else {
			format.timeRead = unixRead
			format.timeParse = parseUnix
		}
	} else if unixRead != "" {
		format.Logger.Warning("Cannot use both TimestampRead and UnixTimestampRead, defaulting to TimestampRead")
	}

	if !conf.HasValue("Directives") {
		format.Logger.Warning("JSON formatter has no directives setting")
		return // ### return, no directives ###
	}

	directiveStrings := conf.GetStringArray("Directives", []string{})
	if len(directiveStrings) == 0 {
		conf.Errors.Pushf("JSON formatter has no directives")
	} else {
		// Parse directives
		parserFunctions := make(map[string]tstrings.ParsedFunc)
		parserFunctions["key"] = format.readKey
		parserFunctions["val"] = format.readValue
		parserFunctions["esc"] = format.readEscaped
		parserFunctions["dat"] = format.readDate
		parserFunctions["arr"] = format.readArray
		parserFunctions["obj"] = format.readObject
		parserFunctions["end"] = format.readEnd
		parserFunctions["arr+val"] = format.readArrayValue
		parserFunctions["arr+dat"] = format.readArrayDate
		parserFunctions["arr+esc"] = format.readArrayEscaped
		parserFunctions["val+end"] = format.readValueEnd
		parserFunctions["esc+end"] = format.readEscapedEnd
		parserFunctions["dat+end"] = format.readDateEnd

		directives := []tstrings.TransitionDirective{}
		for _, dirString := range directiveStrings {
			directive, err := tstrings.ParseTransitionDirective(dirString, parserFunctions)
			if err != nil {
				conf.Errors.Pushf("%s: %s", err.Error(), dirString)
				continue // ### continue, malformed directive ###
			}

			if format.initState == "" {
				format.initState = directive.State
			}
			directives = append(directives, directive)
		}

		format.parser.AddDirectives(directives)

		// Validate initstate
		initStateValid := false
		for i := 0; i < len(directives) && !initStateValid; i++ {
			initStateValid = directives[i].State == format.initState
		}
		if !initStateValid {
			conf.Errors.Pushf("JSONStartState does not exist in directives")
		}

		for _, dir := range directives {
			nextStateValid := false
			for i := 0; i < len(directives) && !nextStateValid; i++ {
				nextStateValid = dir.NextState == directives[i].State
			}
			if !nextStateValid {
				format.Logger.Warningf("State \"%s\" has a transition to \"%s\" which does not exist in directives", dir.State, dir.NextState)
			}
		}
	}
}
436301
func (format *Aggregate) Configure(conf core.PluginConfigReader) {
	applyTo := conf.GetString("ApplyTo", "")

	// init modulator array
	modulatorSettings := format.getModulatorSettings(applyTo, conf)

	config := core.NewPluginConfig("", "format.Aggregate.Modulators")
	config.Override("Modulators", modulatorSettings)
	modulatorReader := core.NewPluginConfigReaderWithError(&config)

	modulatorArray, err := modulatorReader.GetModulatorArray("Modulators", format.Logger, core.ModulatorArray{})
	if err != nil {
		conf.Errors.Push(err)
	}

	format.modulators = modulatorArray
}
654200
func Configure(
	isFrontend bool,
	serverType string,
	serverMode ServerMode,
	serverMetadata map[string]string,
	cfgs ...*viper.Viper,
) {
	if app.configured {
		logger.Log.Warn("pitaya configured twice!")
	}
	app.config = config.NewConfig(cfgs...)
	if app.heartbeat == time.Duration(0) {
		app.heartbeat = app.config.GetDuration("pitaya.heartbeat.interval")
	}
	app.server.Frontend = isFrontend
	app.server.Type = serverType
	app.serverMode = serverMode
	app.server.Metadata = serverMetadata
	app.messageEncoder = message.NewMessagesEncoder(app.config.GetBool("pitaya.handler.messages.compression"))
	configureMetrics(serverType)
	configureDefaultPipelines(app.config)
	app.configured = true
}
209838
func (r *Router) Configure(opts ...RouterOption) {
	for _, o := range opts {
		o(r)
	}
}
1081114
func (reader *PluginConfigReader) Configure(item interface{}) error {
	itemValue := reflect.ValueOf(item)
	if itemValue.Kind() != reflect.Ptr {
		panic("Configure requires reference")
	}

	var logger logrus.FieldLogger
	if loggable, isScoped := item.(ScopedLogger); isScoped {
		logger = loggable.GetLogger()
	}

	reader.configureStruct(itemValue, logger)
	if confItem, isConfigurable := item.(Configurable); isConfigurable {
		confItem.Configure(*reader)
	}

	return reader.Errors.OrNil()
}
1318725
func (v *VaultProvider) Configure(clusterId string, isRoot bool, rawConfig map[string]interface{}) error {
	config, err := ParseVaultCAConfig(rawConfig)
	if err != nil {
		return err
	}

	clientConf := &vaultapi.Config{
		Address: config.Address,
	}
	err = clientConf.ConfigureTLS(vaultTLSConfig(config))
	if err != nil {
		return err
	}
	client, err := vaultapi.NewClient(clientConf)
	if err != nil {
		return err
	}

	client.SetToken(config.Token)
	v.config = config
	v.client = client
	v.isRoot = isRoot
	v.clusterId = clusterId

	return nil
}