mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
api: safely access legacy MBits field
This commit is contained in:
@@ -111,6 +111,17 @@ type NetworkResource struct {
|
||||
MBits *int `hcl:"mbits,optional"`
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
@@ -1211,7 +1211,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 {
|
||||
|
||||
11
vendor/github.com/hashicorp/nomad/api/resources.go
generated
vendored
11
vendor/github.com/hashicorp/nomad/api/resources.go
generated
vendored
@@ -111,6 +111,17 @@ type NetworkResource struct {
|
||||
MBits *int `hcl:"mbits,optional"`
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user