Exemplo n.º 1
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:
//	- *yaml.Config: The configuration.
func ParseYamlString(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
	yamlString := p.Get("yaml", "").(string)

	cfg, err := yaml.FromYaml(string(yamlString))
	if err != nil {
		return nil, err
	}

	return cfg, nil
}
Exemplo n.º 2
0
// ParseYaml parses the glide.yaml format and returns a Configuration object.
//
// Params:
//	- filename (string): YAML filename as a string
//
// Returns:
//	- *yaml.Config: The configuration.
func ParseYaml(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
	fname := p.Get("filename", "glide.yaml").(string)
	//conf := new(Config)
	yml, err := ioutil.ReadFile(fname)
	if err != nil {
		return nil, err
	}
	cfg, err := yaml.FromYaml(string(yml))
	if err != nil {
		return nil, err
	}

	return cfg, nil
}
Exemplo n.º 3
0
func mergeGlide(dir, name string, deps map[string]*yaml.Dependency, vend string) ([]string, bool) {
	gp := path.Join(dir, "glide.yaml")
	if _, err := os.Stat(gp); err != nil {
		return []string{}, false
	}

	yml, err := ioutil.ReadFile(gp)
	if err != nil {
		Warn("Found glide file %q, but can't read: %s", gp, err)
		return []string{}, false
	}

	conf, err := yaml.FromYaml(string(yml))
	if err != nil {
		Warn("Found glide file %q, but can't use it: %s", gp, err)
		return []string{}, false
	}

	Info("Found glide.yaml in %s", gp)

	return mergeDeps(deps, conf.Imports, vend), true
}