tolerate Git refs prefix in version string

This commit is contained in:
Kenneth Bingham 2023-04-07 16:14:10 -04:00
parent 8b767acc62
commit f2a29865b3
No known key found for this signature in database
GPG Key ID: 31709281860130B6

View File

@ -9,7 +9,7 @@ import (
"github.com/pkg/errors"
"net/url"
"os"
"strings"
"regexp"
)
func (zrd *ZrokDir) Client() (*rest_client_zrok.Zrok, error) {
@ -27,7 +27,10 @@ func (zrd *ZrokDir) Client() (*rest_client_zrok.Zrok, error) {
if err != nil {
return nil, errors.Wrapf(err, "error getting version from api endpoint '%v': %v", apiEndpoint, err)
}
if !strings.HasPrefix(string(v.Payload), build.Series) {
// allow reported version string to be optionally prefixed with
// "refs/heads/" or "refs/tags/"
re := regexp.MustCompile(`^(refs/(heads|tags)/)?` + build.Series)
if ! re.MatchString(string(v.Payload)) {
return nil, errors.Errorf("expected a '%v' version, received: '%v'", build.Series, v.Payload)
}