// FanConfig is the configuration of FAN network running in the model.
968747
func (c *Config) FanConfig() (network.FanConfig, error) {
	// At this point we are sure that the line is valid.
	return network.ParseFanConfig(c.asString(FanConfig))
}
1246764
func Config() stats.ResourceMetricsConfig {
	return stats.ResourceMetricsConfig{
		NodeMetrics: []stats.NodeResourceMetric{
			{
				Name:        "node_cpu_usage_seconds_total",
				Description: "Cumulative cpu time consumed by the node in core-seconds",
				ValueFn: func(s summary.NodeStats) (*float64, time.Time) {
					if s.CPU == nil {
						return nil, time.Time{}
					}
					v := float64(*s.CPU.UsageCoreNanoSeconds) / float64(time.Second)
					return &v, s.CPU.Time.Time
				},
			},
			{
				Name:        "node_memory_working_set_bytes",
				Description: "Current working set of the node in bytes",
				ValueFn: func(s summary.NodeStats) (*float64, time.Time) {
					if s.Memory == nil {
						return nil, time.Time{}
					}
					v := float64(*s.Memory.WorkingSetBytes)
					return &v, s.Memory.Time.Time
				},
			},
		},
		ContainerMetrics: []stats.ContainerResourceMetric{
			{
				Name:        "container_cpu_usage_seconds_total",
				Description: "Cumulative cpu time consumed by the container in core-seconds",
				ValueFn: func(s summary.ContainerStats) (*float64, time.Time) {
					if s.CPU == nil {
						return nil, time.Time{}
					}
					v := float64(*s.CPU.UsageCoreNanoSeconds) / float64(time.Second)
					return &v, s.CPU.Time.Time
				},
			},
			{
				Name:        "container_memory_working_set_bytes",
				Description: "Current working set of the container in bytes",
				ValueFn: func(s summary.ContainerStats) (*float64, time.Time) {
					if s.Memory == nil {
						return nil, time.Time{}
					}
					v := float64(*s.Memory.WorkingSetBytes)
					return &v, s.Memory.Time.Time
				},
			},
		},
	}
}
859545
func Config() (*DefaultConfig, error) {
	var err error
	config, err := LoadConfig("")
	if err != nil {
		return nil, err
	}

	return config, nil
}
977112
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config == nil {
		return nil, errors.New("dreamhost: the configuration of the DNS provider is nil")
	}

	if config.APIKey == "" {
		return nil, errors.New("dreamhost: credentials missing")
	}

	if config.BaseURL == "" {
		config.BaseURL = defaultBaseURL
	}

	return &DNSProvider{config: config}, nil
}
1293301
func NewConfig() *Config {
	return &Config{
		Preferences: *NewPreferences(),
		Clusters:    make(map[string]*Cluster),
		AuthInfos:   make(map[string]*AuthInfo),
		Contexts:    make(map[string]*Context),
		Extensions:  make(map[string]runtime.Object),
	}
}
97446
func (s *DiscoverySupport) Config(channel string) (*discovery.ConfigResult, error) {
	block := s.GetCurrConfigBlock(channel)
	if block == nil {
		return nil, errors.Errorf("could not get last config block for channel %s", channel)
	}
	if block.Data == nil || len(block.Data.Data) == 0 {
		return nil, errors.Errorf("no transactions in block")
	}
	env := &common.Envelope{}
	if err := proto.Unmarshal(block.Data.Data[0], env); err != nil {
		return nil, errors.Wrap(err, "failed unmarshaling envelope")
	}
	pl := &common.Payload{}
	if err := proto.Unmarshal(env.Payload, pl); err != nil {
		return nil, errors.Wrap(err, "failed unmarshaling payload")
	}
	ce := &common.ConfigEnvelope{}
	if err := proto.Unmarshal(pl.Data, ce); err != nil {
		return nil, errors.Wrap(err, "failed unmarshaling config envelope")
	}

	if err := ValidateConfigEnvelope(ce); err != nil {
		return nil, errors.Wrap(err, "config envelope is invalid")
	}

	res := &discovery.ConfigResult{
		Msps:     make(map[string]*msp.FabricMSPConfig),
		Orderers: make(map[string]*discovery.Endpoints),
	}
	ordererGrp := ce.Config.ChannelGroup.Groups[channelconfig.OrdererGroupKey].Groups
	appGrp := ce.Config.ChannelGroup.Groups[channelconfig.ApplicationGroupKey].Groups

	ordererAddresses := &common.OrdererAddresses{}
	if err := proto.Unmarshal(ce.Config.ChannelGroup.Values[channelconfig.OrdererAddressesKey].Value, ordererAddresses); err != nil {
		return nil, errors.Wrap(err, "failed unmarshaling orderer addresses")
	}

	ordererEndpoints, err := computeOrdererEndpoints(ordererGrp, ordererAddresses)
	if err != nil {
		return nil, errors.Wrap(err, "failed computing orderer addresses")
	}
	res.Orderers = ordererEndpoints

	if err := appendMSPConfigs(ordererGrp, appGrp, res.Msps); err != nil {
		return nil, errors.WithStack(err)
	}
	return res, nil

}
1190861
func (c *CHA2DS2VAScPlugin) Config() plugin.RiskServicePluginConfig {
	return plugin.RiskServicePluginConfig{
		Name: "CHA2DS2–VASc score",
		Method: models.CodeableConcept{
			Coding: []models.Coding{{System: "http://interventionengine.org/risk-assessments", Code: "CHADS"}},
			Text:   "CHA2DS2–VASc score",
		},
		PredictedOutcome: models.CodeableConcept{Text: "Stroke"},
		DefaultPieSlices: []plugin.Slice{
			{Name: "Congestive Heart Failure", Weight: 11, MaxValue: 1},
			{Name: "Hypertension", Weight: 11, MaxValue: 1},
			{Name: "Diabetes", Weight: 11, MaxValue: 1},
			{Name: "Stroke", Weight: 22, MaxValue: 2},
			{Name: "Vascular Disease", Weight: 11, MaxValue: 1},
			{Name: "Age", Weight: 22, MaxValue: 2},
			{Name: "Gender", Weight: 11, MaxValue: 1},
		},
		RequiredResourceTypes: []string{"Condition"},
		SignificantBirthdays:  []int{65, 75},
	}
}
651375
func (s *Store) Config(service string) *discoverd.ServiceConfig {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.data.Services[service]
}
22573
func (api *NetworkConfigAPI) fixUpFanSubnets(networkConfig []params.NetworkConfig) ([]params.NetworkConfig, error) {
	subnets, err := api.st.AllSubnets()
	if err != nil {
		return nil, errors.Trace(err)
	}

	var fanSubnets []*state.Subnet
	var fanCIDRs []*net.IPNet
	for _, subnet := range subnets {
		if subnet.FanOverlay() != "" {
			fanSubnets = append(fanSubnets, subnet)
			_, net, err := net.ParseCIDR(subnet.CIDR())
			if err != nil {
				return nil, errors.Trace(err)
			}
			fanCIDRs = append(fanCIDRs, net)
		}
	}
	for i := range networkConfig {
		localIP := net.ParseIP(networkConfig[i].Address)
		for j, fanSubnet := range fanSubnets {
			if fanCIDRs[j].Contains(localIP) {
				networkConfig[i].CIDR = fanSubnet.CIDR()
				networkConfig[i].ProviderId = string(fanSubnet.ProviderId())
				networkConfig[i].ProviderSubnetId = string(fanSubnet.ProviderNetworkId())
				break
			}
		}
	}
	logger.Tracef("Final network config after fixing up FAN subnets %+v", networkConfig)
	return networkConfig, nil
}
36838
func (m *Model) Config() map[string]interface{} {
	m.mu.Lock()
	cfg := make(map[string]interface{}, len(m.details.Config))
	for k, v := range m.details.Config {
		cfg[k] = v
	}
	m.mu.Unlock()
	m.metrics.ModelConfigReads.Inc()
	return cfg
}
175311
func DefaultConfig() Config {
	return Config{
		Filters:        make(map[string]FilterFunction),
		Globals:        make(map[string]interface{}, 0),
		DebugTemplates: false,
	}
}
587823
func NetworkingEnvironFromModelConfig(configGetter environs.EnvironConfigGetter) (environs.NetworkingEnviron, error) {
	modelConfig, err := configGetter.ModelConfig()
	if err != nil {
		return nil, errors.Annotate(err, "failed to get model config")
	}
	cloudSpec, err := configGetter.CloudSpec()
	if err != nil {
		return nil, errors.Annotate(err, "failed to get cloudspec")
	}
	if cloudSpec.Type == cloud.CloudTypeCAAS {
		return nil, errors.NotSupportedf("CAAS model %q networking", modelConfig.Name())
	}

	env, err := environs.GetEnviron(configGetter, environs.New)
	if err != nil {
		return nil, errors.Annotate(err, "failed to construct a model from config")
	}
	netEnviron, supported := environs.SupportsNetworking(env)
	if !supported {
		// " not supported" will be appended to the message below.
		return nil, errors.NotSupportedf("model %q networking", modelConfig.Name())
	}
	return netEnviron, nil
}
955225
func (c *Configs) setConfig(confName configName, value *ConfigSettings) {
	assert(len(confName) == len(c.ConfigVariables))
	assert(value != nil)
	key := confName.key()
	pair, ok := c.byConfig[key]
	assert(!ok, "setConfig must not override existing keys (%s => %v)", key, pair.value)
	c.byConfig[key] = configPair{confName, value}
}
598499
func DefaultConfig() Config {
	return Config{
		Status:   true,
		IP:       true,
		Method:   true,
		Path:     true,
		Query:    false,
		Columns:  false,
		LogFunc:  nil,
		Skippers: nil,
		skip:     nil,
	}
}
436506
func defaultConfig(transportFn func() *http.Transport) *Config {
	config := &Config{
		Address:   "127.0.0.1:8500",
		Scheme:    "http",
		Transport: transportFn(),
	}

	if addr := os.Getenv(HTTPAddrEnvName); addr != "" {
		config.Address = addr
	}

	if tokenFile := os.Getenv(HTTPTokenFileEnvName); tokenFile != "" {
		config.TokenFile = tokenFile
	}

	if token := os.Getenv(HTTPTokenEnvName); token != "" {
		config.Token = token
	}

	if auth := os.Getenv(HTTPAuthEnvName); auth != "" {
		var username, password string
		if strings.Contains(auth, ":") {
			split := strings.SplitN(auth, ":", 2)
			username = split[0]
			password = split[1]
		} else {
			username = auth
		}

		config.HttpAuth = &HttpBasicAuth{
			Username: username,
			Password: password,
		}
	}

	if ssl := os.Getenv(HTTPSSLEnvName); ssl != "" {
		enabled, err := strconv.ParseBool(ssl)
		if err != nil {
			log.Printf("[WARN] client: could not parse %s: %s", HTTPSSLEnvName, err)
		}

		if enabled {
			config.Scheme = "https"
		}
	}

	if v := os.Getenv(HTTPTLSServerName); v != "" {
		config.TLSConfig.Address = v
	}
	if v := os.Getenv(HTTPCAFile); v != "" {
		config.TLSConfig.CAFile = v
	}
	if v := os.Getenv(HTTPCAPath); v != "" {
		config.TLSConfig.CAPath = v
	}
	if v := os.Getenv(HTTPClientCert); v != "" {
		config.TLSConfig.CertFile = v
	}
	if v := os.Getenv(HTTPClientKey); v != "" {
		config.TLSConfig.KeyFile = v
	}
	if v := os.Getenv(HTTPSSLVerifyEnvName); v != "" {
		doVerify, err := strconv.ParseBool(v)
		if err != nil {
			log.Printf("[WARN] client: could not parse %s: %s", HTTPSSLVerifyEnvName, err)
		}
		if !doVerify {
			config.TLSConfig.InsecureSkipVerify = true
		}
	}

	return config
}
197187
func (s *HTTPServer) Config(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
	switch req.Method {
	case "GET":
		return s.configGet(resp, req)

	case "DELETE":
		return s.configDelete(resp, req)

	default:
		return nil, MethodNotAllowedError{req.Method, []string{"GET", "DELETE"}}
	}
}
1091818
func NetworkPeerConfig(cfg fab.EndpointConfig, key string) (*fab.NetworkPeer, error) {
	peerCfg, ok := cfg.PeerConfig(key)
	if !ok {
		return nil, errors.Errorf("peer [%s] not found", key)
	}

	// find MSP ID
	networkPeers := cfg.NetworkPeers()

	var mspID string
	for _, peer := range networkPeers {
		if peer.URL == peerCfg.URL { // need to use the looked-up URL due to matching
			mspID = peer.MSPID
			break
		}
	}

	np := fab.NetworkPeer{
		PeerConfig: *peerCfg,
		MSPID:      mspID,
	}

	return &np, nil
}