Example #1
0
func FileForManifestRef(ref string) (*ManifestFile, error) {
	mf, err := data.NewManifestWithRef(ref)
	if err != nil {
		return nil, fmt.Errorf("Error loading manifest: %s", err.Error())
	}

	attempts := []string{
		"readme.md",
		"readme.txt",
		"readme",
	}

	for _, attempt := range attempts {
		attempt = strings.ToLower(attempt)

		for path, hash := range mf.Files {
			path = strings.ToLower(path)
			if path == attempt {
				return &ManifestFile{
					Path: path,
					Ref:  hash,
				}, nil
			}
		}
	}

	return nil, ErrNotFound
}
Example #2
0
func DatafileForManifestRef(ref string) (*data.Datafile, error) {
	mf, err := data.NewManifestWithRef(ref)
	if err != nil {
		return nil, fmt.Errorf("Error loading manifest: %s", err.Error())
	}

	dref := mf.HashForPath(data.DatafileName)
	df, err := data.NewDatafileWithRef(dref)
	if err != nil {
		return nil, fmt.Errorf("Error loading datafile: %s", err.Error())
	}

	return df, nil
}