// This helper turns a provider configs field into a deterministic
// string value for comparison in tests.
175177
func providerConfigsStr(pcs []*ProviderConfig) string {
	result := ""

	ns := make([]string, 0, len(pcs))
	m := make(map[string]*ProviderConfig)
	for _, n := range pcs {
		ns = append(ns, n.Name)
		m[n.Name] = n
	}
	sort.Strings(ns)

	for _, n := range ns {
		pc := m[n]

		result += fmt.Sprintf("%s\n", n)

		keys := make([]string, 0, len(pc.RawConfig.Raw))
		for k, _ := range pc.RawConfig.Raw {
			keys = append(keys, k)
		}
		sort.Strings(keys)

		for _, k := range keys {
			result += fmt.Sprintf("  %s\n", k)
		}

		if len(pc.RawConfig.Variables) > 0 {
			result += fmt.Sprintf("  vars\n")
			for _, rawV := range pc.RawConfig.Variables {
				kind := "unknown"
				str := rawV.FullKey()

				switch rawV.(type) {
				case *ResourceVariable:
					kind = "resource"
				case *UserVariable:
					kind = "user"
				}

				result += fmt.Sprintf("    %s: %s\n", kind, str)
			}
		}
	}

	return strings.TrimSpace(result)
}
307918
func (l *Literal) ToComparableString() string {
	s := ""
	switch l.t {
	case Int64:
		s = fmt.Sprintf("\"%032d\"^^type:%v", l.Interface(), l.Type())
	case Float64:
		s = fmt.Sprintf("\"%032f\"^^type:%v", l.Interface(), l.Type())
	default:
		s = l.String()
	}
	return s
}
967560
func (p provider) String() string {
	return fmt.Sprintf("&provider{\n%s,\n%s\n}",
		indent(fmt.Sprintf("constructor: %s", reflect.TypeOf(p.constructor)), 1),
		indent(fmt.Sprintf("argPtrs: %s", p.fmtArgPtrs()), 1),
	)
}
1192721
func validateConfig(config *ProviderConfig) error {
	// Validate the inputs
	if config == nil {
		return fmt.Errorf("missing config")
	}
	if config.Service == nil {
		return fmt.Errorf("missing service")
	}
	if config.Service.Service == "" {
		return fmt.Errorf("missing service name")
	}
	if config.Service.ServiceVersion == "" {
		return fmt.Errorf("missing service version")
	}
	if config.Service.ResourceType == "" {
		return fmt.Errorf("missing service resource type")
	}
	if config.Handlers == nil && len(config.Service.Capabilities) != 0 {
		return fmt.Errorf("missing handlers")
	}
	for c := range config.Service.Capabilities {
		if _, ok := config.Handlers[c]; !ok {
			return fmt.Errorf("missing handler for '%s' capability", c)
		}
	}
	if config.ResourceGroup == "" {
		return fmt.Errorf("missing resource group")
	}
	if config.Token == "" {
		config.Token = os.Getenv("ATLAS_TOKEN")
	}
	if config.Token == "" {
		return fmt.Errorf("missing token")
	}

	// Default the endpoint
	if config.Endpoint == "" {
		config.Endpoint = DefaultEndpoint
		if end := os.Getenv("SCADA_ENDPOINT"); end != "" {
			config.Endpoint = end
		}
	}
	return nil
}
804600
func (p *providerImpl) ParseConfig() (*OIDCConfiguration, error) {
	prov, err := p.provider()
	if err != nil {
		return nil, err
	}
	return ParseConfig(prov)
}
1255391
func NewConfig(name string, provider ProviderType, attrs map[string]interface{}) (*Config, error) {
	_, err := configChecker.Coerce(attrs, nil)
	if err != nil {
		return nil, errors.Annotate(err, "validating common storage config")
	}
	return &Config{
		name:     name,
		provider: provider,
		attrs:    attrs,
	}, nil
}
631678
func dumpConfig(Opts map[string]string) {
	opts := []string{}
	for k := range Opts {
		opts = append(opts, k)
	}
	sort.Strings(opts)

	for _, k := range opts {
		// XXX: Reuse the format function from *option.Library
		value = Opts[k]
		if enabled, err := option.NormalizeBool(value); err != nil {
			// If it cannot be parsed as a bool, just format the value.
			fmt.Printf("%-24s %s\n", k, color.Green(value))
		} else if enabled == option.OptionDisabled {
			fmt.Printf("%-24s %s\n", k, color.Red("Disabled"))
		} else {
			fmt.Printf("%-24s %s\n", k, color.Green("Enabled"))
		}
	}
}
245775
func CompareConfigs(old, new *ucfg.Config, opts ...ucfg.Option) Diff {
	oldKeys := old.FlattenedKeys(opts...)
	newKeys := new.FlattenedKeys(opts...)

	difference := make(map[string]Type)

	// Map for candidates check
	for _, k := range oldKeys {
		difference[k] = Remove
	}

	for _, nk := range newKeys {
		if _, ok := difference[nk]; ok {
			difference[nk] = Keep
		} else {
			difference[nk] = Add
		}
	}

	invert := make(Diff)

	for k, v := range difference {
		invert[v] = append(invert[v], k)
	}

	return invert
}
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},
	}
}
161724
func stringFieldEscape(s string) string {
	if strings.ContainsAny(s, stringFieldEscapes) {
		return stringFieldEscaper.Replace(s)
	} else {
		return s
	}
}
237031
func (n *NodeAbstractProvider) ProviderConfig() *configs.Provider {
	if n.Config == nil {
		return nil
	}

	return n.Config
}
853653
func (c *Configure) String(name string, def string, description string) *string {
	s := new(string)
	c.StringVar(s, name, def, description)

	return s
}
971468
func configValuesSet(config map[string]interface{}) map[string]interface{} {
	flatten := make(map[string]interface{})
	for k, v := range config {
		if m, isMap := v.(map[string]interface{}); isMap && !flatOptions[k] {
			for km, vm := range m {
				flatten[km] = vm
			}
			continue
		}

		flatten[k] = v
	}
	return flatten
}
1219846
func ConfigList(appID string, oneLine bool) error {
	c, appID, err := load(appID)

	if err != nil {
		return err
	}

	config, err := config.List(c, appID)

	if err != nil {
		return err
	}

	var keys []string
	for k := range config.Values {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	if oneLine {
		for _, key := range keys {
			fmt.Printf("%s=%s ", key, config.Values[key])
		}
		fmt.Println()
	} else {
		fmt.Printf("=== %s Config\n", appID)

		configMap := make(map[string]string)

		// config.Values is type interface, so it needs to be converted to a string
		for _, key := range keys {
			configMap[key] = fmt.Sprintf("%v", config.Values[key])
		}

		fmt.Print(prettyprint.PrettyTabs(configMap, 6))
	}

	return nil
}
1020377
func DecodeConfig(in interface{}) (Config, error) {
	if in == nil {
		return Config{}, errors.New("no related config provided")
	}

	m, ok := in.(map[string]interface{})
	if !ok {
		return Config{}, fmt.Errorf("expected map[string]interface {} got %T", in)
	}

	if len(m) == 0 {
		return Config{}, errors.New("empty related config provided")
	}

	var c Config

	if err := mapstructure.WeakDecode(m, &c); err != nil {
		return c, err
	}

	if c.Threshold < 0 || c.Threshold > 100 {
		return Config{}, errors.New("related threshold must be between 0 and 100")
	}

	if c.ToLower {
		for i := range c.Indices {
			c.Indices[i].ToLower = true
		}
	}

	return c, nil
}
708109
func (p autoProvider) String() string {
	return fmt.Sprintf("&autoProvider{\n%s\n}",
		indent(fmt.Sprintf("constructor: %s", reflect.TypeOf(p.constructor)), 1),
	)
}
224949
func (f *Function) GetConfigQualifier(s string) (*lambda.GetFunctionOutput, error) {
	f.Log.Debug("fetching config")
	return f.Service.GetFunction(&lambda.GetFunctionInput{
		FunctionName: &f.FunctionName,
		Qualifier:    &s,
	})
}