Adds check to make sure port is given so we avoid a nil bind address.

This commit is contained in:
James Phillips 2017-10-10 18:11:21 -07:00
parent 275e83de08
commit a16dbc0212
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
1 changed files with 3 additions and 0 deletions

View File

@ -399,6 +399,9 @@ func (b *Builder) Build() (rt RuntimeConfig, err error) {
for _, s := range c.Segments { for _, s := range c.Segments {
name := b.stringVal(s.Name) name := b.stringVal(s.Name)
port := b.portVal(fmt.Sprintf("segments[%s].port", name), s.Port) port := b.portVal(fmt.Sprintf("segments[%s].port", name), s.Port)
if port == 0 {
return RuntimeConfig{}, fmt.Errorf("Port must be specified for segment %q", s.Name)
}
bind := b.makeTCPAddr( bind := b.makeTCPAddr(
b.expandFirstIP(fmt.Sprintf("segments[%s].bind", name), s.Bind), b.expandFirstIP(fmt.Sprintf("segments[%s].bind", name), s.Bind),