From e180d2fa7b3e3f83cf8b1e6324019c8b1dc027d6 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Thu, 20 May 2021 11:11:25 -0400 Subject: [PATCH] Fix updating terminators when cost is omitted --- controller/internal/routes/terminator_api_model.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/controller/internal/routes/terminator_api_model.go b/controller/internal/routes/terminator_api_model.go index 1afb091dc..500734b0a 100644 --- a/controller/internal/routes/terminator_api_model.go +++ b/controller/internal/routes/terminator_api_model.go @@ -44,7 +44,6 @@ func MapCreateTerminatorToModel(terminator *rest_model.TerminatorCreate) *networ Identity: terminator.Identity, IdentitySecret: terminator.IdentitySecret, Precedence: xt.GetPrecedenceForName(string(terminator.Precedence)), - Cost: 0, } if terminator.Cost != nil { @@ -65,8 +64,12 @@ func MapUpdateTerminatorToModel(id string, terminator *rest_model.TerminatorUpda Binding: stringz.OrEmpty(terminator.Binding), Address: stringz.OrEmpty(terminator.Address), Precedence: xt.GetPrecedenceForName(string(terminator.Precedence)), - Cost: uint16(*terminator.Cost), } + + if terminator.Cost != nil { + ret.Cost = uint16(*terminator.Cost) + } + return ret } @@ -81,8 +84,12 @@ func MapPatchTerminatorToModel(id string, terminator *rest_model.TerminatorPatch Binding: terminator.Binding, Address: terminator.Address, Precedence: xt.GetPrecedenceForName(string(terminator.Precedence)), - Cost: uint16(*terminator.Cost), } + + if terminator.Cost != nil { + ret.Cost = uint16(*terminator.Cost) + } + return ret }