1
0
mirror of https://github.com/go-task/task.git synced 2026-10-23 11:48:55 +03:00
Files
task/taskfile/node_base.go
2026-09-26 16:09:27 +00:00

51 lines
1.0 KiB
Go

package taskfile
type (
NodeOption interface {
ApplyToBaseNode(n *baseNode)
}
// baseNode is a generic node that implements the Parent() methods of the
// NodeReader interface. It does not implement the Read() method and it
// 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
checksum string
caCert string
cert string
certKey string
headersByHost HeadersByHost
}
)
func NewBaseNode(dir string, opts ...NodeOption) *baseNode {
node := &baseNode{
parent: nil,
dir: dir,
}
// Apply options
for _, opt := range opts {
opt.ApplyToBaseNode(node)
}
return node
}
func (node *baseNode) Parent() Node {
return node.parent
}
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
}