// FromConfigString creates a config from the given YAML, JSON or TOML config. This is useful in tests.
494529
func FromConfigString(config, configType string) (Provider, error) {
	v := newViper()
	m, err := readConfig(metadecoders.FormatFromString(configType), []byte(config))
	if err != nil {
		return nil, err
	}

	v.MergeConfigMap(m)

	return v, nil
}
984963
func FromStringDict(constructor skylark.Value, d skylark.StringDict) *Struct {
	if constructor == nil {
		panic("nil constructor")
	}
	s := &Struct{
		constructor: constructor,
		entries:     make(entries, 0, len(d)),
	}
	for k, v := range d {
		s.entries = append(s.entries, entry{k, v})
	}
	sort.Sort(s.entries)
	return s
}
401765
func VersionString() string {
	name := path.Base(os.Args[0])
	return fmt.Sprintf("Versions: %s=(%s %s) Golang=(%s) BuildHost=(%s)", name, core.GetBuildID(), core.GetBuildTime(), runtime.Version(), core.GetBuildHost())
}
376564
func (config *Config) GetString(key string, defaultValue string) (string, error) {
	value, err := config.Get(key, defaultValue)
	if err != nil {
		return defaultValue, err
	}
	if result, ok := value.(string); ok {
		return result, nil
	}
	return defaultValue, &ValueTypeError{key: key, value: value, message: "Value is not a string."}
}
954645
func applicationSetSettingsStrings(
	application Application, gen string, settings map[string]string,
) error {
	ch, _, err := application.Charm()
	if err != nil {
		return errors.Trace(err)
	}
	// Parse config in a compatible way (see function comment).
	changes, err := parseSettingsCompatible(ch.Config(), settings)
	if err != nil {
		return errors.Trace(err)
	}
	return application.UpdateCharmConfig(gen, changes)
}
336068
func (s *SearchSource) From(from int) *SearchSource {
	s.from = from
	return s
}
59958
func (c Config) GetString(key string) (string, error) {
	var (
		strout string
		val    interface{}
		ok     bool
	)

	if val, ok = c[key]; !ok {
		return strout, ErrConfigNotFound
	}
	if strout, ok = val.(string); !ok {
		return strout, ErrNotAString
	}
	return strout, nil
}
1158703
func (s *SubnetKey) FromString(str string) error {
	if str == "" || !strings.Contains(str, "/") {
		return types.BadRequestErrorf("invalid string form for subnetkey: %s", str)
	}

	p := strings.Split(str, "/")
	if len(p) != 3 && len(p) != 5 {
		return types.BadRequestErrorf("invalid string form for subnetkey: %s", str)
	}
	s.AddressSpace = p[0]
	s.Subnet = fmt.Sprintf("%s/%s", p[1], p[2])
	if len(p) == 5 {
		s.ChildSubnet = fmt.Sprintf("%s/%s", p[3], p[4])
	}

	return nil
}
754051
func (c *ConfigParser) ReadString(s string) (err error) {
	r := strings.NewReader(s)
	return c.Read(r)
}
1311981
func FromString(templ string) (*ImportHelper, error) {
	var s ImportHelper
	if err := yaml.Unmarshal([]byte(templ), &s); err != nil {
		log.Info(nil, map[string]interface{}{
			"template": templ,
			"err":      err,
		}, "failed to unmarshal YAML space template")
		return nil, errs.Wrapf(err, "failed to parse YAML space template: \n%s", templ)
	}
	// If the space template has no ID, create one on the fly
	if uuid.Equal(s.Template.ID, uuid.Nil) {
		s.Template.ID = uuid.NewV4()
	}
	// update all refs to this ID
	s.SetID(s.Template.ID)
	if err := s.Validate(); err != nil {
		return nil, errs.Wrap(err, "failed to validate space template")
	}
	return &s, nil
}
1053776
func ParseString(cfg API, input string) *Iterator {
	return ParseBytes(cfg, []byte(input))
}
62100
func (c *JSONConfigContainer) Strings(key string) []string {
	stringVal := c.String(key)
	if stringVal == "" {
		return nil
	}
	return strings.Split(c.String(key), ";")
}
860782
func (f *File) FromArg(read bool) error {
	// (length - 1)
	arg := os.Args[len(os.Args)-1:][0]

	// get extension
	ext := path.Ext(arg)
	if len(ext) > 1 {
		ext = ext[1:] // remove dot
	}

	// when json/yaml/toml file isn't found on last arg
	// it searches for a ".json", ".yaml", ".yml" or ".toml" string in all args
	if ext != "json" && ext != "yaml" && ext != "yml" && ext != "toml" {
		// loop through args
		for _, a := range os.Args {
			// get extension
			ext := path.Ext(a)

			// check for valid extensions
			if ext == ".json" || ext == ".yaml" || ext == ".yml" || ext == ".toml" {
				f.Mode = ext[1:] // remove dot
				ext = f.Mode
				arg = a
				break
			}
		}
	} else {
		f.Mode = ext
	}

	// check if extension is json, yaml or toml
	// then get it's absolute path
	if ext == "json" || ext == "yaml" || ext == "yml" || ext == "toml" {
		f.FilePath = arg

		// so we can test without reading a file
		if read {
			if !utils.Exists(f.FilePath) {
				return errors.New("Error: I Can't find the config file at [" + f.FilePath + "]")
			}
		}
	} else {
		return errors.New("Error: You must specify a json, yaml or toml file")
	}

	return nil
}
1065260
func (c *Config) GetString(key string) (string, error) {
	val, ok := (*c)[key]
	if !ok {
		return "", ErrNoSuchKey
	}
	s, ok := val.(string)
	if !ok {
		return s, fmt.Errorf("Wrong type for %s (Type:%T Expecting:%T)", key, val, s)
	}
	return val.(string), nil
}
849481
func (c Config) GetString(key string) string {
	i, ok := c[key]
	if !ok {
		return ""
	}
	s, ok := i.(string)
	if !ok {
		return ""
	}
	return s
}
558861
func (p *Project) Config() (string, error) {
	cfg := ExportedConfig{
		Version:  "2.0",
		Services: p.ServiceConfigs.All(),
		Volumes:  p.VolumeConfigs,
		Networks: p.NetworkConfigs,
	}

	bytes, err := yaml.Marshal(cfg)
	return string(bytes), err
}
871053
func FromParameters(parameters map[string]interface{}) (*Driver, error) {
	params, err := fromParametersImpl(parameters)
	if err != nil || params == nil {
		return nil, err
	}
	return New(*params), nil
}