// NewModeViper creates a viper.Viper with config path and environment prefixes
// set. It also specifies a Sub of the active environment (the chosen env mode)
// and reads in the database config file section.
168793
func NewModeViper(appPath string, envAppName, env string) *viper.Viper {
	newViper := viper.New()
	newViper.SetConfigType("toml")
	newViper.SetConfigFile(filepath.Join(appPath, AppConfigFilename))
	newViper.SetEnvPrefix(envAppName)
	newViper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))

	if env == "" {
		return newViper
	}

	// Do nothing on errors here, so we can fallback to other validation
	// methods. Users can use env vars or cmd line flags if a config is not found.
	err := testHarnessViperReadConfig(newViper)
	if err != nil {
		return newViper
	}

	modeViper := newViper.Sub(fmt.Sprintf("%s.db", env))
	if modeViper == nil {
		return newViper
	}

	return modeViper
}
666186
func New(defaultConfPath, liveConfPath string, portChecker checker) *Resetter {
	return &Resetter{
		defaultConfPath: defaultConfPath,
		liveConfPath:    liveConfPath,
		portChecker:     portChecker,
		timeout:         time.Second * 30,
		Monit:           monit.New(),
		redis:           redis.New(),
	}
}
996787
func (rc *ReporterConfig) NewReporter(
	serviceName string,
	metrics *jaeger.Metrics,
	logger jaeger.Logger,
) (jaeger.Reporter, error) {
	sender, err := rc.newTransport()
	if err != nil {
		return nil, err
	}
	reporter := jaeger.NewRemoteReporter(
		sender,
		jaeger.ReporterOptions.QueueSize(rc.QueueSize),
		jaeger.ReporterOptions.BufferFlushInterval(rc.BufferFlushInterval),
		jaeger.ReporterOptions.Logger(logger),
		jaeger.ReporterOptions.Metrics(metrics))
	if rc.LogSpans && logger != nil {
		logger.Infof("Initializing logging reporter\n")
		reporter = jaeger.NewCompositeReporter(jaeger.NewLoggingReporter(logger), reporter)
	}
	return reporter, err
}
732888
func NewModelConfigAPI(backend Backend, authorizer facade.Authorizer) (*ModelConfigAPIV2, error) {
	if !authorizer.AuthClient() {
		return nil, common.ErrPerm
	}
	client := &ModelConfigAPI{
		backend: backend,
		auth:    authorizer,
		check:   common.NewBlockChecker(backend),
	}
	return &ModelConfigAPIV2{client}, nil
}
163985
func NewEFSProvisioner(client kubernetes.Interface) controller.Provisioner {
	fileSystemID := os.Getenv(fileSystemIDKey)
	if fileSystemID == "" {
		klog.Fatalf("environment variable %s is not set! Please set it.", fileSystemIDKey)
	}

	awsRegion := os.Getenv(awsRegionKey)
	if awsRegion == "" {
		klog.Fatalf("environment variable %s is not set! Please set it.", awsRegionKey)
	}

	dnsName := os.Getenv(dnsNameKey)
	klog.Errorf("%v", dnsName)
	if dnsName == "" {
		dnsName = getDNSName(fileSystemID, awsRegion)
	}

	mountpoint, source, err := getMount(dnsName)
	if err != nil {
		klog.Fatal(err)
	}

	sess, err := session.NewSession()
	if err != nil {
		klog.Warningf("couldn't create an AWS session: %v", err)
	}

	svc := efs.New(sess, &aws.Config{Region: aws.String(awsRegion)})
	params := &efs.DescribeFileSystemsInput{
		FileSystemId: aws.String(fileSystemID),
	}

	_, err = svc.DescribeFileSystems(params)
	if err != nil {
		klog.Warningf("couldn't confirm that the EFS file system exists: %v", err)
	}

	return &efsProvisioner{
		dnsName:    dnsName,
		mountpoint: mountpoint,
		source:     source,
		allocator:  gidallocator.New(client),
	}
}
441638
func readViperConfig(ctx context.Context, v *viper.Viper) error {
	v.AddConfigPath(".")
	v.AddConfigPath("/etc")
	v.SetConfigName("gddo")
	if v.GetString("config") != "" {
		v.SetConfigFile(v.GetString("config"))
	}

	if err := v.ReadInConfig(); err != nil {
		// If a config exists but could not be parsed, we should bail.
		if _, ok := err.(viper.ConfigParseError); ok {
			return fmt.Errorf("parse config: %v", err)
		}

		// If the user specified a config file location in flags or env and
		// we failed to load it, we should bail. If not, it is just a warning.
		if v.GetString("config") != "" {
			return fmt.Errorf("load config: %v", err)
		}
		log.Warn(ctx, "failed to load configuration file", "error", err)
		return nil
	}
	log.Info(ctx, "loaded configuration file successfully", "path", v.ConfigFileUsed())
	return nil
}
315841
func initConfig() {
	if cfgFile != "" { // enable ability to specify config file via flag
		viper.SetConfigFile(cfgFile)
	}

	viper.SetEnvPrefix("cilium")
	viper.SetConfigName(".cilium") // name of config file (without extension)
	viper.AddConfigPath("$HOME")   // adding home directory as first search path
	viper.AutomaticEnv()           // read in environment variables that match

	// If a config file is found, read it in.
	if err := viper.ReadInConfig(); err == nil {
		fmt.Println("Using config file:", viper.ConfigFileUsed())
	}

	if viper.GetBool("debug") {
		log.Level = logrus.DebugLevel
	} else {
		log.Level = logrus.InfoLevel
	}

	if cl, err := clientPkg.NewClient(viper.GetString("host")); err != nil {
		Fatalf("Error while creating client: %s\n", err)
	} else {
		client = cl
	}
}
331503
func NewRm(ruleConfigs []*TagMatchRuleConfig, next rmsink) (*SpanTagRemoval, error) {
	rules, err := getRules(ruleConfigs)
	if err != nil {
		return nil, err
	}

	return &SpanTagRemoval{
		rules: rules,
		next:  next,
	}, nil
}
306754
func NewFileMigrator(path string, c *Connection) (FileMigrator, error) {
	fm := FileMigrator{
		Migrator: NewMigrator(c),
		Path:     path,
	}
	fm.SchemaPath = path

	err := fm.findMigrations()
	if err != nil {
		return fm, errors.WithStack(err)
	}

	return fm, nil
}
1170148
func NewConfigurator(config Config, logger *log.Logger) (*Configurator, error) {
	c := &Configurator{logger: logger}
	err := c.Update(config)
	if err != nil {
		return nil, err
	}
	return c, nil
}
487273
func NewPrometheusProvider(namespace, subsystem string) Provider {
	return &prometheusProvider{
		namespace: namespace,
		subsystem: subsystem,
	}
}
1275677
func NewModuloSampler(mod uint64) Sampler {
	if mod < 2 {
		return AlwaysSample
	}
	return func(id uint64) bool {
		return (id % mod) == 0
	}
}
864859
func NewMockEnforcer(ctrl *gomock.Controller) *MockEnforcer {
	mock := &MockEnforcer{ctrl: ctrl}
	mock.recorder = &MockEnforcerMockRecorder{mock}
	return mock
}
640293
func newVDMVDO(s BaseSentence) (VDMVDO, error) {
	p := newParser(s)
	m := VDMVDO{
		BaseSentence:   s,
		NumFragments:   p.Int64(0, "number of fragments"),
		FragmentNumber: p.Int64(1, "fragment number"),
		MessageID:      p.Int64(2, "sequence number"),
		Channel:        p.String(3, "channel ID"),
		Payload:        p.SixBitASCIIArmour(4, int(p.Int64(5, "number of padding bits")), "payload"),
	}
	return m, p.Err()
}
676148
func NewPadder(x, y int, w Widget) *Padder {
	return &Padder{
		widget:  w,
		padding: image.Point{x, y},
	}
}
340135
func New(*SmartSampleConfig, log.Logger, dtsink) (*SmartSampler, error) {
	return nil, errors.New("you are attempting to configure a regular SignalFx Gateway with the config of a Smart Gateway. This is an unsupported configuration")
}
1096633
func (c *Characteristic) NewDescriptor(u UUID) *Descriptor {
	return c.AddDescriptor(&Descriptor{UUID: u})
}