diff --git a/api/resources.go b/api/resources.go index 4430560d91d..cc229b217e4 100644 --- a/api/resources.go +++ b/api/resources.go @@ -111,6 +111,17 @@ type NetworkResource struct { MBits *int } +// COMPAT(0.13) +// XXX Deprecated. Please do not use. The method will be removed in Nomad +// 0.13 and is only being kept to allow any references to be removed before +// then. +func (n *NetworkResource) Megabits() int { + if n == nil || n.MBits == nil { + return 0 + } + return *n.MBits +} + func (n *NetworkResource) Canonicalize() { // COMPAT(0.13) // Noop to maintain backwards compatibility diff --git a/command/agent/job_endpoint.go b/command/agent/job_endpoint.go index 98a7a9bb941..bcd3d8ae92d 100644 --- a/command/agent/job_endpoint.go +++ b/command/agent/job_endpoint.go @@ -1193,7 +1193,7 @@ func ApiNetworkResourceToStructs(in []*api.NetworkResource) []*structs.NetworkRe Mode: nw.Mode, CIDR: nw.CIDR, IP: nw.IP, - MBits: *nw.MBits, + MBits: nw.Megabits(), } if nw.DNS != nil { diff --git a/vendor/github.com/hashicorp/nomad/api/resources.go b/vendor/github.com/hashicorp/nomad/api/resources.go index 4430560d91d..cc229b217e4 100644 --- a/vendor/github.com/hashicorp/nomad/api/resources.go +++ b/vendor/github.com/hashicorp/nomad/api/resources.go @@ -111,6 +111,17 @@ type NetworkResource struct { MBits *int } +// COMPAT(0.13) +// XXX Deprecated. Please do not use. The method will be removed in Nomad +// 0.13 and is only being kept to allow any references to be removed before +// then. +func (n *NetworkResource) Megabits() int { + if n == nil || n.MBits == nil { + return 0 + } + return *n.MBits +} + func (n *NetworkResource) Canonicalize() { // COMPAT(0.13) // Noop to maintain backwards compatibility