summaryrefslogtreecommitdiff
path: root/registry-scanner/pkg/image/matchfunc.go
blob: 036e6fb037b110f402e7487296ef90503b2c7630 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package image

import (
	"regexp"

	"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/log"
)

// MatchFuncAny matches any pattern, i.e. always returns true
func MatchFuncAny(tagName string, args interface{}) bool {
	return true
}

// MatchFuncNone matches no pattern, i.e. always returns false
func MatchFuncNone(tagName string, args interface{}) bool {
	return false
}

// MatchFuncRegexp matches the tagName against regexp pattern and returns the result
func MatchFuncRegexp(tagName string, args interface{}) bool {
	pattern, ok := args.(*regexp.Regexp)
	if !ok {
		log.Errorf("args is not a RegExp")
		return false
	}
	return pattern.Match([]byte(tagName))
}