summaryrefslogtreecommitdiff
path: root/cmd/podman/parse/template.go
blob: 0b80f1b3adfb3379f9e254ea5f47f776a3c48ffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package parse

import (
	"regexp"
	"strings"
)

var rangeRegex = regexp.MustCompile(`{{\s*range\s*\.\s*}}.*{{\s*end\s*}}`)

// TODO move to github.com/containers/common/pkg/report
// EnforceRange ensures that the format string contains a range
func EnforceRange(format string) string {
	if !rangeRegex.MatchString(format) {
		return "{{range .}}" + format + "{{end}}"
	}
	return format
}

// EnforceRange ensures that the format string contains a range
func HasTable(format string) bool {
	return strings.HasPrefix(format, "table ")
}