Skip to content

Commit

Permalink
parse_network: use native hcl decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekStrickland committed May 6, 2022
1 parent 66d4eec commit f0eb2df
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions jobspec/parse_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,12 @@ func parsePorts(networkObj *ast.ObjectList, nw *api.NetworkResource) error {
if knownPortLabels[l] {
return fmt.Errorf("found a port label collision: %s", label)
}
var p map[string]interface{}

var res api.Port
if err := hcl.DecodeObject(&p, port.Val); err != nil {
return err
}
if err := mapstructure.WeakDecode(p, &res); err != nil {
if err := hcl.DecodeObject(&res, port.Val); err != nil {
return err
}

res.Label = label
if res.Value > 0 {
nw.ReservedPorts = append(nw.ReservedPorts, res)
Expand Down

0 comments on commit f0eb2df

Please sign in to comment.