feat: checksum pinning (#2223)

This commit is contained in:
Pete Davison
2025-05-24 14:00:02 +01:00
committed by GitHub
parent 68ce8b1d84
commit 71eb8cdeea
17 changed files with 196 additions and 15 deletions

View File

@@ -7,8 +7,9 @@ type (
// designed to be embedded in other node types so that this boilerplate code
// does not need to be repeated.
baseNode struct {
parent Node
dir string
parent Node
dir string
checksum string
}
)
@@ -32,6 +33,12 @@ func WithParent(parent Node) NodeOption {
}
}
func WithChecksum(checksum string) NodeOption {
return func(node *baseNode) {
node.checksum = checksum
}
}
func (node *baseNode) Parent() Node {
return node.parent
}
@@ -39,3 +46,11 @@ func (node *baseNode) Parent() Node {
func (node *baseNode) Dir() string {
return node.dir
}
func (node *baseNode) Checksum() string {
return node.checksum
}
func (node *baseNode) Verify(checksum string) bool {
return node.checksum == "" || node.checksum == checksum
}