// CAConfig is used to get the current CA configuration.
329912
func (s *Store) CAConfig() (uint64, *structs.CAConfiguration, error) {
	tx := s.db.Txn(false)
	defer tx.Abort()

	// Get the CA config
	c, err := tx.First(caConfigTableName, "id")
	if err != nil {
		return 0, nil, fmt.Errorf("failed CA config lookup: %s", err)
	}

	config, ok := c.(*structs.CAConfiguration)
	if !ok {
		return 0, nil, nil
	}

	return config.ModifyIndex, config, nil
}
633818
func (s *Service) Config(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	config, err := s.Store.Config(ctx).Get(ctx)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	if config == nil {
		Error(w, http.StatusBadRequest, "Configuration object was nil", s.Logger)
		return
	}
	res := newConfigResponse(*config)

	encodeJSON(w, http.StatusOK, res, s.Logger)
}
1007091
func (c *agentConf) CurrentConfig() agent.Config {
	c.mu.Lock()
	defer c.mu.Unlock()
	return c._config.Clone()
}
960720
func (c *Pre140) Config() *Config {
	sc := StoreConfig{
		AskForMore:  c.AskForMore,
		AutoImport:  c.AutoImport,
		AutoSync:    c.AutoSync,
		ClipTimeout: c.ClipTimeout,
		NoConfirm:   c.NoConfirm,
		Path:        backend.FromPath(c.Path),
		SafeContent: c.SafeContent,
	}
	cfg := &Config{
		Root:   &sc,
		Mounts: make(map[string]*StoreConfig, len(c.Mounts)),
	}
	for k, v := range c.Mounts {
		subSc := sc
		subSc.Path = backend.FromPath(v)
		cfg.Mounts[k] = &subSc
	}
	return cfg
}
1021681
func getConfig(c context.Context) *Config {
	cfg := Config{}
	switch err := settings.Get(c, baseName, &cfg); err {
	case nil:
		break
	case settings.ErrNoSettings:
		// Defaults.
		cfg = defaultConfig
	default:
		panic(fmt.Errorf("could not fetch Tumble settings - %s", err))
	}
	return &cfg
}
1158905
func GenerateConfig(client bool, keyPairName string, caCertNames []string) (config *tls.Config, err error) {
	config = &tls.Config{
		InsecureSkipVerify: _insecure,
		MinVersion:         tls.VersionTLS12,
	}

	label := "server"
	if client {
		label = "client"
	}

	var keyPair tls.Certificate
	var cFile, kFile string
	if keyPairName != "" {
		keyPair, cFile, kFile, err = LoadPackagedKeypair(keyPairName)
		if err != nil {
			return
		}

		vlog.VLogf("Loaded packaged %s keypair from %s and %s", label, cFile, kFile)
		config.Certificates = []tls.Certificate{keyPair}
	}

	if len(caCertNames) > 0 {
		caPool := x509.NewCertPool()
		if client {
			config.RootCAs = caPool
		} else {
			config.ClientCAs = caPool
			if _insecure {
				config.ClientAuth = tls.RequestClientCert
			} else {
				config.ClientAuth = tls.RequireAndVerifyClientCert
			}
		}

		for _, name := range caCertNames {
			n := name
			if strings.Index(name, "/") < 0 {
				n = name + "-cert"
			}
			var file string
			if file, err = LocatePackagedPEMFile(n); err != nil {
				return nil, fmt.Errorf("Failed to find cert named %q: %s", name, err)
			}
			var b []byte
			if b, err = ioutil.ReadFile(file); err != nil {
				return nil, fmt.Errorf("Can't read cert from %s: %s", file, err)
			}

			vlog.VLogf("Allowing %s CA cert from %s", label, file)
			if ok := caPool.AppendCertsFromPEM(b); !ok {
				return nil, fmt.Errorf("No cert could be found in %s", file)
			}
		}
	}
	return
}
979529
func (s *Storage) Config(c context.Context, cfg storage.Config) error {
	if err := s.getIface().setMaxLogAge(c, cfg.MaxLogAge); err != nil {
		log.WithError(err).Errorf(c, "Failed to set 'log' GC policy.")
		return err
	}
	log.Fields{
		"maxLogAge": cfg.MaxLogAge,
	}.Infof(c, "Set maximum log age.")
	return nil
}
201168
func EnvConfig() *Config {
	config := &Config{}

	if envPluginCacheDir := os.Getenv(pluginCacheDirEnvVar); envPluginCacheDir != "" {
		// No Expandenv here, because expanding environment variables inside
		// an environment variable would be strange and seems unnecessary.
		// (User can expand variables into the value while setting it using
		// standard shell features.)
		config.PluginCacheDir = envPluginCacheDir
	}

	return config
}
998084
func (c *Pre182) Config() *Config {
	cfg := &Config{
		Root:   c.Root.StoreConfig(),
		Mounts: make(map[string]*StoreConfig, len(c.Mounts)),
	}
	for k, v := range c.Mounts {
		cfg.Mounts[k] = v.StoreConfig()
	}
	return cfg
}
1280704
func getConfig(t *testing.T) *cfg.Config {
	c := cfg.ResetTestRoot(t.Name())

	// and we use random ports to run in parallel
	tm, rpc, grpc := makeAddrs()
	c.P2P.ListenAddress = tm
	c.RPC.ListenAddress = rpc
	c.RPC.GRPCListenAddress = grpc
	return c
}
348391
func GetConfig(c *caddy.Controller) *Config {
	ctx := c.Context().(*dnsContext)
	if cfg, ok := ctx.keysToConfigs[c.Key]; ok {
		return cfg
	}
	// we should only get here during tests because directive
	// actions typically skip the server blocks where we make
	// the configs.
	ctx.saveConfig(c.Key, &Config{})
	return GetConfig(c)
}
601030
func (c *MockConfig) CAConfig(org string) (*msp.CAConfig, bool) {
	caConfig := msp.CAConfig{
		CAName: "org1",
	}

	return &caConfig, true
}
145350
func (a *modelAgent) CurrentConfig() agent.Config {
	return &modelAgentConfig{
		Config:         a.Agent.CurrentConfig(),
		modelUUID:      a.modelUUID,
		controllerUUID: a.controllerUUID,
	}
}
377405
func (api *APIBase) getConfig(
	args params.ApplicationGet,
	describe func(settings charm.Settings, config *charm.Config) map[string]interface{},
) (params.ApplicationGetResults, error) {
	if err := api.checkCanRead(); err != nil {
		return params.ApplicationGetResults{}, err
	}

	app, err := api.backend.Application(args.ApplicationName)
	if err != nil {
		return params.ApplicationGetResults{}, err
	}

	// We need a guard on the API server-side for direct API callers such as
	// python-libjuju. Always default to the master branch.
	if args.BranchName == "" {
		args.BranchName = model.GenerationMaster
	}
	settings, err := app.CharmConfig(args.BranchName)
	if err != nil {
		return params.ApplicationGetResults{}, err
	}

	ch, _, err := app.Charm()
	if err != nil {
		return params.ApplicationGetResults{}, err
	}
	configInfo := describe(settings, ch.Config())
	appConfig, err := app.ApplicationConfig()
	if err != nil {
		return params.ApplicationGetResults{}, err
	}

	providerSchema, providerDefaults, err := applicationConfigSchema(api.modelType)
	if err != nil {
		return params.ApplicationGetResults{}, err
	}
	appConfigInfo := describeAppConfig(appConfig, providerSchema, caas.ConfigDefaults(providerDefaults))
	var cons constraints.Value
	if app.IsPrincipal() {
		cons, err = app.Constraints()
		if err != nil {
			return params.ApplicationGetResults{}, err
		}
	}
	return params.ApplicationGetResults{
		Application:       args.ApplicationName,
		Charm:             ch.Meta().Name,
		CharmConfig:       configInfo,
		ApplicationConfig: appConfigInfo,
		Constraints:       cons,
		Series:            app.Series(),
		Channel:           string(app.Channel()),
	}, nil
}
39015
func (c *RemoteClient) GetConfig(ctx context.Context) (*plan.Conf, error) {
	req := api.RequestV1{
		Method: api.GetConfig,
	}
	resp := api.ResponseV1{}
	if err := c.transp.Request(ctx, req, &resp); err != nil {
		return nil, err
	}
	return resp.GetConfig, nil
}
813621
func getConfig(c context.Context) config.ConfigurationServer {
	return c.Value(&cfgKey).(config.ConfigurationServer)
}
890627
func (c *Config) Config() *Config {
	// Guard against nil pointer dereference
	if c == nil {
		return NewConfig()
	}

	// Return a clone of the config so that this is immutable for the receiver
	c2 := *c
	return &c2
}