verify.go

v1.4.0
Doc Versions Source
1
package store
2
3
import (
4
	"fmt"
5
	"regexp"
6
7
	"github.com/go-git/go-git/v6/plumbing/transport"
8
9
	"go.bigb.es/curator/internal/git"
10
)
11
12
// VerifyModule checks that a git repository is accessible.
13
// If auth is non-nil, it is used for authentication.
14
func VerifyModule(repo string, auth transport.AuthMethod) error {
15
	if err := git.LsRemote(repo, auth); err != nil {
16
		return fmt.Errorf("git ls-remote failed for %s: %w", repo, err)
17
	}
18
	return nil
19
}
20
21
// VerifyPattern checks that a regex pattern compiles.
22
func VerifyPattern(pattern string) error {
23
	_, err := regexp.Compile("^" + pattern + "$")
24
	if err != nil {
25
		return fmt.Errorf("invalid regex pattern %q: %w", pattern, err)
26
	}
27
	return nil
28
}
29

Source Files