Example #1
0
// Decode - Decodes an action from a reader.
func (d *Decoder) Decode() (a *action.Action, err error) {
	node, err := yaml.Parse(d.Reader)
	if err != nil {
		return nil, err
	}
	return nodeToAction(node), nil
}
Example #2
0
func Parse(reader io.Reader) (config *Config, err error) {
	root, err := yaml.Parse(reader)
	if err != nil {
		return
	}
	return parseConfigRootNode(root)
}
Example #3
0
// UnmarshalMany - Unmarshals YAML actions into a Map.
func UnmarshalMany(body []byte) (map[string]*action.Action, error) {
	buffer := bytes.NewBuffer(body)
	node, err := yaml.Parse(buffer)
	if err != nil {
		return nil, err
	}
	return nodeToActions(node), nil
}
Example #4
0
// ParseYamlString parses a YAML string. This is similar but different to
// ParseYaml that parses an external file.
//
// Params:
//	- yaml (string): YAML as a string.
//
// Returns:
//	- *Config: The configuration.
func ParseYamlString(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
	yamlString := p.Get("yaml", "").(string)

	// Unfortunately, this does not wrap the root in a YAML file object.
	root, err := yaml.Parse(bytes.NewBufferString(yamlString))
	if err != nil {
		return nil, err
	}

	return FromYaml(root)
}
Example #5
0
func RemoteFileInfo(path string) *FileInfo {
	resp, err := http.Get(bucket_url + path)
	if err != nil {
		return nil
	}

	parts := strings.Split(path, "/")
	defer resp.Body.Close()
	result, err := yaml.Parse(resp.Body)
	if err != nil {
		return nil
	}
	return yamlToInfo(parts[0], parts[1], result)
}