// NewAppConfig returns a new AppConfig, but you must set your typer, mapper, and clientMapper after the command has been run
// and flags have been parsed.
511067
func NewAppConfig() *AppConfig {
	return &AppConfig{
		Resolvers: Resolvers{
			Detector: app.SourceRepositoryEnumerator{
				Detectors:         source.DefaultDetectors,
				DockerfileTester:  dockerfile.NewTester(),
				JenkinsfileTester: jenkinsfile.NewTester(),
			},
		},
		EnvironmentClassificationErrors: map[string]ArgumentClassificationError{},
		SourceClassificationErrors:      map[string]ArgumentClassificationError{},
		TemplateClassificationErrors:    map[string]ArgumentClassificationError{},
		ComponentClassificationErrors:   map[string]ArgumentClassificationError{},
		ClassificationWinners:           map[string]ArgumentClassificationWinner{},
	}
}
1051752
func NewApp(options MockupOptions) (app.App, error) {
	mapp := &MockupApp{
		options: options,
	}
	if err := mapp.initEngineScope(); err != nil {
		return nil, err
	}
	if err := mapp.initArgsScope(); err != nil {
		return nil, err
	}
	if err := mapp.initFilespaceScope(); err != nil {
		return nil, err
	}
	if err := mapp.initConfigScope(); err != nil {
		return nil, err
	}
	if err := mapp.initDependencyScope(); err != nil {
		return nil, err
	}
	if err := mapp.initAppScope(); err != nil {
		return nil, err
	}
	if err := mapp.initCommandScope(); err != nil {
		return nil, err
	}
	mapp.options.DP.SetDefault(app.EngineScope, mapp.options.EngineScope)
	mapp.options.DP.SetDefault(app.ArgsScope, mapp.options.ArgsScope)
	mapp.options.DP.SetDefault(app.FilespaceScope, mapp.options.FilespaceScope)
	mapp.options.DP.SetDefault(app.ConfigScope, mapp.options.ConfigScope)
	mapp.options.DP.SetDefault(app.DependencyScope, mapp.options.DependencyScope)
	mapp.options.DP.SetDefault(app.AppScope, mapp.options.AppScope)
	mapp.options.DP.SetDefault(app.CommandScope, mapp.options.CommandScope)
	mapp.options.DP.SetDefault(app.InputService, mapp.options.Input)
	mapp.options.DP.SetDefault(app.OutputService, mapp.options.Output)
	mapp.options.DP.AddInjectors([]dependency.Injector{
		mapp.options.CommandScope,
		mapp.options.AppScope,
		mapp.options.ConfigScope,
		mapp.options.FilespaceScope,
		mapp.options.ArgsScope,
		mapp.options.EngineScope,
	})
	return mapp, nil
}
1212726
func (p *provider) NewConfig() (*osincli.ClientConfig, error) {
	config := &osincli.ClientConfig{
		ClientId:                 p.clientID,
		ClientSecret:             p.clientSecret,
		ErrorsInStatusCode:       true,
		SendClientSecretInParams: true,
		AuthorizeUrl:             p.authorizeURL,
		TokenUrl:                 p.tokenURL,
		Scope:                    gitlabOAuthScope,
	}
	return config, nil
}
776348
func NewConfig() (c *Config) {

	c = &Config{
		LocalStoreParams:     storage.NewDefaultLocalStoreParams(),
		FileStoreParams:      storage.NewFileStoreParams(),
		HiveParams:           network.NewHiveParams(),
		Swap:                 swap.NewDefaultSwapParams(),
		Pss:                  pss.NewPssParams(),
		ListenAddr:           DefaultHTTPListenAddr,
		Port:                 DefaultHTTPPort,
		Path:                 node.DefaultDataDir(),
		EnsAPIs:              nil,
		EnsRoot:              ens.TestNetAddress,
		NetworkID:            network.DefaultNetworkID,
		SwapEnabled:          false,
		SyncEnabled:          true,
		SyncingSkipCheck:     false,
		MaxStreamPeerServers: 10000,
		DeliverySkipCheck:    true,
		SyncUpdateDelay:      15 * time.Second,
		SwapAPI:              "",
	}

	return
}
1021414
func NewForConfig(baseConfig *rest.Config, mapper meta.RESTMapper, availableAPIs AvailableAPIsGetter) CustomMetricsClient {
	return &multiClient{
		clients:       make(map[schema.GroupVersion]CustomMetricsClient),
		availableAPIs: availableAPIs,

		newClient: func(ver schema.GroupVersion) (CustomMetricsClient, error) {
			return NewForVersionForConfig(rest.CopyConfig(baseConfig), mapper, ver)
		},
	}
}
602375
func NewAppClient(serverURL, userID, appID, appVersion string) (*AppClient, error) {
	c, err := New(serverURL, userID)
	if err != nil {
		return nil, err
	}

	ac, err := c.NewAppClient(appID, appVersion)
	if err := ac.SetVersion(appVersion); err != nil {
		return nil, err
	}

	return ac, nil
}
104575
func NewAgentConfig(configParams AgentConfigParams) (ConfigSetterWriter, error) {
	if configParams.Paths.DataDir == "" {
		return nil, errors.Trace(requiredError("data directory"))
	}
	if configParams.Tag == nil {
		return nil, errors.Trace(requiredError("entity tag"))
	}
	switch configParams.Tag.(type) {
	case names.MachineTag, names.UnitTag, names.ApplicationTag:
		// These are the only three type of tags that can represent an agent
		// IAAS - machine and unit
		// CAAS - application
	default:
		return nil, errors.Errorf("entity tag must be MachineTag, UnitTag or ApplicationTag, got %T", configParams.Tag)
	}
	if configParams.UpgradedToVersion == version.Zero {
		return nil, errors.Trace(requiredError("upgradedToVersion"))
	}
	if configParams.Password == "" {
		return nil, errors.Trace(requiredError("password"))
	}
	if uuid := configParams.Controller.Id(); uuid == "" {
		return nil, errors.Trace(requiredError("controller"))
	} else if !names.IsValidController(uuid) {
		return nil, errors.Errorf("%q is not a valid controller uuid", uuid)
	}
	if uuid := configParams.Model.Id(); uuid == "" {
		return nil, errors.Trace(requiredError("model"))
	} else if !names.IsValidModel(uuid) {
		return nil, errors.Errorf("%q is not a valid model uuid", uuid)
	}
	if len(configParams.CACert) == 0 {
		return nil, errors.Trace(requiredError("CA certificate"))
	}
	// Note that the password parts of the state and api information are
	// blank.  This is by design: we want to generate a secure password
	// for new agents. So, we create this config without a current password
	// which signals to apicaller worker that it should try to connect using old password.
	// When/if this connection is successful, apicaller worker will generate
	// a new secure password and update this agent's config.
	config := &configInternal{
		paths:              NewPathsWithDefaults(configParams.Paths),
		jobs:               configParams.Jobs,
		upgradedToVersion:  configParams.UpgradedToVersion,
		tag:                configParams.Tag,
		nonce:              configParams.Nonce,
		controller:         configParams.Controller,
		model:              configParams.Model,
		caCert:             configParams.CACert,
		oldPassword:        configParams.Password,
		values:             configParams.Values,
		mongoVersion:       configParams.MongoVersion.String(),
		mongoMemoryProfile: configParams.MongoMemoryProfile.String(),
	}
	if len(configParams.APIAddresses) > 0 {
		config.apiDetails = &apiDetails{
			addresses: configParams.APIAddresses,
		}
	}
	if err := config.check(); err != nil {
		return nil, err
	}
	if config.values == nil {
		config.values = make(map[string]string)
	}
	config.configFilePath = ConfigPath(config.paths.DataDir, config.tag)
	return config, nil
}
336593
func NewWithAppInsightsConfig(name string, conf *appinsights.TelemetryConfiguration) (*AppInsightsHook, error) {
	if conf == nil {
		return nil, fmt.Errorf("Nil configuration provided")
	}
	if conf.InstrumentationKey == "" {
		return nil, fmt.Errorf("InstrumentationKey is required in configuration")
	}
	telemetryClient := appinsights.NewTelemetryClientFromConfig(conf)
	if name != "" {
		telemetryClient.Context().Cloud().SetRoleName(name)
	}
	return &AppInsightsHook{
		client:       telemetryClient,
		levels:       defaultLevels,
		ignoreFields: make(map[string]struct{}),
		filters:      make(map[string]func(interface{}) interface{}),
	}, nil
}
897187
func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource) (*storagebackend.Config, error) {
	chosenStorageResource := s.getStorageGroupResource(groupResource)

	// operate on copy
	storageConfig := s.StorageConfig
	codecConfig := StorageCodecConfig{
		StorageMediaType:  s.DefaultMediaType,
		StorageSerializer: s.DefaultSerializer,
	}

	if override, ok := s.Overrides[getAllResourcesAlias(chosenStorageResource)]; ok {
		override.Apply(&storageConfig, &codecConfig)
	}
	if override, ok := s.Overrides[chosenStorageResource]; ok {
		override.Apply(&storageConfig, &codecConfig)
	}

	var err error
	codecConfig.StorageVersion, err = s.ResourceEncodingConfig.StorageEncodingFor(chosenStorageResource)
	if err != nil {
		return nil, err
	}
	codecConfig.MemoryVersion, err = s.ResourceEncodingConfig.InMemoryEncodingFor(groupResource)
	if err != nil {
		return nil, err
	}
	codecConfig.Config = storageConfig

	storageConfig.Codec, storageConfig.EncodeVersioner, err = s.newStorageCodecFn(codecConfig)
	if err != nil {
		return nil, err
	}
	klog.V(3).Infof("storing %v in %v, reading as %v from %#v", groupResource, codecConfig.StorageVersion, codecConfig.MemoryVersion, codecConfig.Config)

	return &storageConfig, nil
}
1178615
func (s *CreateApplicationInput) SetApplicationConfiguration(v *ApplicationConfiguration) *CreateApplicationInput {
	s.ApplicationConfiguration = v
	return s
}
476509
func NewAppWithConfig(config AppConfig) (*App, error) {

	if err := applyDefaults(&config); err != nil {
		return nil, errors.Wrap(err, "while applying config defaults")
	}

	// Connect to etcd and fetch registration config
	if err := fetchEtcdConfig(&config); err != nil {
		return nil, errors.Wrap(err, "while fetching etcd config")
	}

	app := App{Config: config}

	if LogRequest == nil {
		LogRequest = logRequest
	}

	app.router = config.Router
	if app.router == nil {
		app.router = mux.NewRouter()
		app.router.UseEncodedPath()
	}
	app.router.HandleFunc("/_ping", handlePing).Methods("GET")

	if config.Vulcand != nil {
		var err error
		app.vulcandReg, err = vulcand.NewRegistry(*config.Vulcand, config.Name, config.ListenIP, config.ListenPort)
		if err != nil {
			return nil, err
		}
	}

	app.stats = newAppStats(config.Client)
	return &app, nil
}
397692
func NewConfig(log logging.Logger) *Config {

	cfg := &Config{
		Logger:       log,
		Config:       cluster.NewConfig(),
		Partition:    -1,
		Partitioner:  sarama.NewHashPartitioner,
		RequiredAcks: AcksUnset,
	}

	return cfg
}
1356794
func NewConfig() *Config {
	c := new(Config)
	c.Incoming.Port = defaultPort
	return c
}
919188
func NewConfig() *Config {
	c := &Config{
		configHandlers: []configHandler{&structTagsConfig{}, &tlsConfig{}},
		initialized:    true,
	}
	if err := c.setDefaults(); err != nil {
		panic(err.Error())
	}
	return c
}
1331729
func NewConfig(server, origin string) (config *Config, err error) {
	config = new(Config)
	config.Version = ProtocolVersionHybi13
	config.Location, err = url.ParseRequestURI(server)
	if err != nil {
		return
	}
	config.Origin, err = url.ParseRequestURI(origin)
	if err != nil {
		return
	}
	config.Header = http.Header(make(map[string][]string))
	return
}
335066
func NewDBConfig(dsn string, memory bool) *DBConfig {
	return &DBConfig{DSN: dsn, Memory: memory}
}
701945
func NewConfig() *Config {
	cfg := &Config{}
	cfg.FlagSet = flag.NewFlagSet("importer", flag.ContinueOnError)
	fs := cfg.FlagSet

	fs.StringVar(&cfg.configFile, "config", "", "Config file")

	fs.StringVar(&cfg.DDLCfg.TableSQL, "t", "", "create table sql")
	fs.StringVar(&cfg.DDLCfg.IndexSQL, "i", "", "create index sql")

	fs.StringVar(&cfg.StatsCfg.Path, "s", "", "load stats file path")

	fs.IntVar(&cfg.SysCfg.WorkerCount, "c", 2, "parallel worker count")
	fs.IntVar(&cfg.SysCfg.JobCount, "n", 10000, "total job count")
	fs.IntVar(&cfg.SysCfg.Batch, "b", 1000, "insert batch commit count")

	fs.StringVar(&cfg.DBCfg.Host, "h", "127.0.0.1", "set the database host ip")
	fs.StringVar(&cfg.DBCfg.User, "u", "root", "set the database user")
	fs.StringVar(&cfg.DBCfg.Password, "p", "", "set the database password")
	fs.StringVar(&cfg.DBCfg.Name, "D", "test", "set the database name")
	fs.IntVar(&cfg.DBCfg.Port, "P", 3306, "set the database host port")

	fs.StringVar(&cfg.SysCfg.LogLevel, "L", "info", "log level: debug, info, warn, error, fatal")

	return cfg
}