2023-03-10 18:27:30 +00:00
|
|
|
package fingerprint
|
|
|
|
|
|
2026-08-10 16:12:18 +02:00
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"github.com/go-task/task/v3/errors"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ErrInvalidMethod lets callers that only need a fingerprint value tell a bad
|
|
|
|
|
// method name apart from a checker failing on the sources themselves.
|
|
|
|
|
var ErrInvalidMethod = errors.New("invalid method")
|
2023-03-10 18:27:30 +00:00
|
|
|
|
|
|
|
|
func NewSourcesChecker(method, tempDir string, dry bool) (SourcesCheckable, error) {
|
|
|
|
|
switch method {
|
|
|
|
|
case "timestamp":
|
|
|
|
|
return NewTimestampChecker(tempDir, dry), nil
|
|
|
|
|
case "checksum":
|
|
|
|
|
return NewChecksumChecker(tempDir, dry), nil
|
|
|
|
|
case "none":
|
|
|
|
|
return NoneChecker{}, nil
|
|
|
|
|
default:
|
2026-08-10 16:12:18 +02:00
|
|
|
return nil, fmt.Errorf(`task: %w "%s"`, ErrInvalidMethod, method)
|
2023-03-10 18:27:30 +00:00
|
|
|
}
|
|
|
|
|
}
|