Validate tags
This commit is contained in:
parent
9247a3c564
commit
889c89ec79
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/common"
|
"github.com/hashicorp/packer/common"
|
||||||
|
@ -125,6 +126,13 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
||||||
if c.Tags == nil {
|
if c.Tags == nil {
|
||||||
c.Tags = make([]string, 0)
|
c.Tags = make([]string, 0)
|
||||||
}
|
}
|
||||||
|
tagRe := regexp.MustCompile("^[[:alnum:]:_-]{1,255}$")
|
||||||
|
|
||||||
|
for _, t := range c.Tags {
|
||||||
|
if !tagRe.MatchString(t) {
|
||||||
|
errs = packer.MultiErrorAppend(errs, errors.New(fmt.Sprintf("invalid tag: %s", t)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if errs != nil && len(errs.Errors) > 0 {
|
if errs != nil && len(errs.Errors) > 0 {
|
||||||
return nil, nil, errs
|
return nil, nil, errs
|
||||||
|
|
Loading…
Reference in New Issue