mirror of
https://github.com/hanzoai/volume.git
synced 2026-10-01 00:48:00 +00:00
A fork of Rancher's local-path-provisioner at v0.0.36. The behaviour is unchanged and deliberately so — a directory on the node a pod lands on is the right thing for a disk. What changes is identity. The provisioner answers to hanzo.ai/volume rather than rancher.io/local-path. That is not branding: two provisioners sharing one name race for the same claims, and a stock k3s carries the upstream one, so a cluster running both would settle our storage by chance. Data lives at /var/lib/hanzo/volume, so reading a Hanzo cluster does not mean learning another vendor's directory. Apache-2.0 as published, unaltered, with Rancher's attribution in NOTICE. The README says what this is not: durability. A volume here dies with its node. That is hanzoai/replicate's question, one layer up, and keeping the two apart is what lets the disk stay this simple.
32 lines
875 B
Go
32 lines
875 B
Go
package dns
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto"
|
|
"hash"
|
|
)
|
|
|
|
// identityHash will not hash, it only buffers the data written into it and returns it as-is.
|
|
type identityHash struct {
|
|
b *bytes.Buffer
|
|
}
|
|
|
|
// Implement the hash.Hash interface.
|
|
|
|
func (i identityHash) Write(b []byte) (int, error) { return i.b.Write(b) }
|
|
func (i identityHash) Size() int { return i.b.Len() }
|
|
func (i identityHash) BlockSize() int { return 1024 }
|
|
func (i identityHash) Reset() { i.b.Reset() }
|
|
func (i identityHash) Sum(b []byte) []byte { return append(b, i.b.Bytes()...) }
|
|
|
|
func hashFromAlgorithm(alg uint8) (hash.Hash, crypto.Hash, error) {
|
|
hashnumber, ok := AlgorithmToHash[alg]
|
|
if !ok {
|
|
return nil, 0, ErrAlg
|
|
}
|
|
if hashnumber == 0 {
|
|
return identityHash{b: &bytes.Buffer{}}, hashnumber, nil
|
|
}
|
|
return hashnumber.New(), hashnumber, nil
|
|
}
|