Skip to content

Commit

Permalink
Merge pull request #604 from hashicorp/f-port-err-msg
Browse files Browse the repository at this point in the history
Throwing an error if ports are not named instead of crashing while parsing a job spec
  • Loading branch information
diptanu committed Dec 18, 2015
2 parents 9daeae7 + 6810791 commit a3af91a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jobspec/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ func parsePorts(networkObj *ast.ObjectList, nw *structs.NetworkResource) error {
portsObjList := networkObj.Filter("port")
knownPortLabels := make(map[string]bool)
for _, port := range portsObjList.Items {
if len(port.Keys) == 0 {
return fmt.Errorf("Ports must be named")
}
label := port.Keys[0].Token.Value().(string)
if !reDynamicPorts.MatchString(label) {
return errPortLabel
Expand Down

0 comments on commit a3af91a

Please sign in to comment.