func ReadConfig(r io.Reader) (*Config, error) {
	data, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}
	var config *Config
	if err := yaml.Unmarshal(data, &config); err != nil {
		return nil, err
	}
	if config == nil {
		return nil, fmt.Errorf("invalid config: empty configuration")
	}
	if config.Options == nil {
		// We are allowed an empty configuration if the options
		// field is explicitly specified, but there is no easy way
		// to tell if it was specified or not without unmarshaling
		// into interface{} and explicitly checking the field.
		var configInterface interface{}
		if err := yaml.Unmarshal(data, &configInterface); err != nil {
			return nil, err
		}
		m, _ := configInterface.(map[interface{}]interface{})
		if _, ok := m["options"]; !ok {
			return nil, fmt.Errorf("invalid config: empty configuration")
		}
	}
	for name, option := range config.Options {
		switch option.Type {
		case "string", "int", "float", "boolean":
		case "":
			// Missing type is valid in python.
			option.Type = "string"
		default:
			return nil, fmt.Errorf("invalid config: option %q has unknown type %q", name, option.Type)
		}
		def := option.Default
		if def == "" && option.Type == "string" {
			// Skip normal validation for compatibility with pyjuju.
		} else if option.Default, err = option.validate(name, def); err != nil {
			option.error(&err, name, def)
			return nil, fmt.Errorf("invalid config default: %v", err)
		}
		config.Options[name] = option
	}
	return config, nil
}
// ReadConfig reads a Config in YAML format.
ReadConfig reads a Config in YAML format.
// ReadConfig reads a Config in YAML format .
func ReadConfig(r io.Reader) (*Config, error) {
	data, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}
	var config *Config
	if err := yaml.Unmarshal(data, &config); err != nil {
		return nil, err
	}
	if config == nil {
		return nil, fmt.Errorf("invalid config: empty configuration")
	}
	if config.Options == nil {
		var configInterface interface{}
		if err := yaml.Unmarshal(data, &configInterface); err != nil {
			return nil, err
		}
		m, _ := configInterface.(map[interface{}]interface{})
		if _, ok := m["options"]; !ok {
			return nil, fmt.Errorf("invalid config: empty configuration")
		}
	}
	for name, option := range config.Options {
		switch option.Type {
		case "string", "int", "float", "boolean":
		case "":
			option.Type = "string"
		default:
			return nil, fmt.Errorf("invalid config: option %q has unknown type %q", name, option.Type)
		}
		def := option.Default
		if def == "" && option.Type == "string" {
		} else if option.Default, err = option.validate(name, def); err != nil {
			option.error(&err, name, def)
			return nil, fmt.Errorf("invalid config default: %v", err)
		}
		config.Options[name] = option
	}
	return config, nil
}
func ReadConfig ( r io . Reader ) ( * Config , error ) { data , err := ioutil . ReadAll ( r ) if err != nil { return nil , err } var config * Config if err := yaml . Unmarshal ( data , & config ) ; err != nil { return nil , err } if config == nil { return nil , fmt . Errorf ( " " ) } if config . Options == nil { var configInterface interface { } if err := yaml . Unmarshal ( data , & configInterface ) ; err != nil { return nil , err } m , _ := configInterface . ( map [ interface { } ] interface { } ) if _ , ok := m [ " " ] ; ! ok { return nil , fmt . Errorf ( " " ) } } for name , option := range config . Options { switch option . Type { case " " , " " , " " , " " : case " " : option . Type = " " default : return nil , fmt . Errorf ( " " , name , option . Type ) } def := option . Default if def == " " && option . Type == " " { } else if option . Default , err = option . validate ( name , def ) ; err != nil { option . error ( & err , name , def ) return nil , fmt . Errorf ( " " , err ) } config . Options [ name ] = option } return config , nil }
ReadConfig reads a Config in YAML format.
ReadConfig reads a Config in YAML format .
// We are allowed an empty configuration if the options // field is explicitly specified, but there is no easy way // to tell if it was specified or not without unmarshaling // into interface{} and explicitly checking the field. // Missing type is valid in python. // Skip normal validation for compatibility with pyjuju.