-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Proposal Details
In the OpenTofu project, we maintain a registry of providers (zipped binaries) that are run through dirhash.HashZip(). In our pipeline, we would like to skip writing the file to disk, just to re-read it into memory again.
I propose that the core of the existing HashZip function is factored out into HashZipReader(*zip.Reader, Hash) (string,error) and the existing HashZip function is modified to call it.
func HashZip(zipfile string, hash Hash) (string, error) {
z, err := zip.OpenReader(zipfile)
if err != nil { return "", err }
defer z.Close()
return ZipHashReader(z)
}It could then be consumed by end users as:
z, err := zip.NewReader(bytes.NewReader(zipdata), int64(len(zipdata)))
if err != nil { ... }
hash, err := dirhash.HashZipReader(z)
...In practice, this is a very small addition to the API and minimal code change. It would give consumers of this package more flexible access to the existing utility function within.
I'm happy to submit this change via gerrit, but understand that this proposal needs review before I could start work on it.