@@ -66,7 +66,7 @@ type Node struct {
6666type ClusterSync struct {
6767 cfg * Configuration
6868 certFetch chan struct {}
69- cli * client_native.HAProxyClient
69+ cli client_native.HAProxyClient
7070 Context context.Context
7171 ReloadAgent haproxy.IReloadAgent
7272}
@@ -76,7 +76,7 @@ var expectedResponseCodes = map[string]int{
7676 "PUT" : 200 ,
7777}
7878
79- func (c * ClusterSync ) Monitor (cfg * Configuration , cli * client_native.HAProxyClient ) {
79+ func (c * ClusterSync ) Monitor (cfg * Configuration , cli client_native.HAProxyClient ) {
8080 c .cfg = cfg
8181 c .cli = cli
8282
@@ -144,7 +144,7 @@ func (c *ClusterSync) issueRefreshRequest(url, port, basePath string, nodesPath
144144 Status : cfg .Status .Load (),
145145 Type : DataplaneAPIType ,
146146 }
147- var json = jsoniter .ConfigCompatibleWithStandardLibrary
147+ json : = jsoniter .ConfigCompatibleWithStandardLibrary
148148 bytesRepresentation , _ := json .Marshal (nodeData )
149149
150150 req , err := http .NewRequest ("PATCH" , url , bytes .NewBuffer (bytesRepresentation ))
@@ -344,7 +344,7 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
344344 }
345345 nodeData .Facts = c .getNodeFacts ()
346346
347- var json = jsoniter .ConfigCompatibleWithStandardLibrary
347+ json : = jsoniter .ConfigCompatibleWithStandardLibrary
348348 bytesRepresentation , _ := json .Marshal (nodeData )
349349
350350 req , err := http .NewRequest (registerMethod , url , bytes .NewBuffer (bytesRepresentation ))
@@ -375,22 +375,23 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
375375 return err
376376 }
377377 if c .cfg .HAProxy .NodeIDFile != "" {
378+ configuration := c .cli .Configuration ()
378379 // write id to file
379380 errFID := ioutil .WriteFile (c .cfg .HAProxy .NodeIDFile , []byte (responseData .ID ), 0644 ) // nolint:gosec
380381 if errFID != nil {
381382 return errFID
382383 }
383- version , errVersion := c . cli . Configuration .GetVersion ("" )
384+ version , errVersion := configuration .GetVersion ("" )
384385 if errVersion != nil || version < 1 {
385386 // silently fallback to 1
386387 version = 1
387388 }
388- t , err1 := c . cli . Configuration .StartTransaction (version )
389+ t , err1 := configuration .StartTransaction (version )
389390 if err1 != nil {
390391 return err1
391392 }
392393 // write id to peers
393- _ , peerSections , errorGet := c . cli . Configuration .GetPeerSections (t .ID )
394+ _ , peerSections , errorGet := configuration .GetPeerSections (t .ID )
394395 if errorGet != nil {
395396 return errorGet
396397 }
@@ -400,27 +401,27 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
400401 dataplaneID = "localhost"
401402 }
402403 for _ , section := range peerSections {
403- _ , peerEntries , err1 := c . cli . Configuration .GetPeerEntries (section .Name , t .ID )
404+ _ , peerEntries , err1 := configuration .GetPeerEntries (section .Name , t .ID )
404405 if err1 != nil {
405406 return err1
406407 }
407408 for _ , peer := range peerEntries {
408409 if peer .Name == dataplaneID {
409410 peerFound = true
410411 peer .Name = responseData .ID
411- errEdit := c . cli . Configuration .EditPeerEntry (dataplaneID , section .Name , peer , t .ID , 0 )
412+ errEdit := configuration .EditPeerEntry (dataplaneID , section .Name , peer , t .ID , 0 )
412413 if errEdit != nil {
413- _ = c . cli . Configuration .DeleteTransaction (t .ID )
414+ _ = configuration .DeleteTransaction (t .ID )
414415 return err
415416 }
416417 }
417418 }
418419 }
419420 if ! peerFound {
420- _ = c . cli . Configuration .DeleteTransaction (t .ID )
421+ _ = configuration .DeleteTransaction (t .ID )
421422 return fmt .Errorf ("peer [%s] not found in HAProxy config" , dataplaneID )
422423 }
423- _ , err = c . cli . Configuration .CommitTransaction (t .ID )
424+ _ , err = configuration .CommitTransaction (t .ID )
424425 if err != nil {
425426 return err
426427 }
@@ -520,7 +521,7 @@ func (c *ClusterSync) fetchCert() {
520521 break
521522 }
522523 var responseData Node
523- var json = jsoniter .ConfigCompatibleWithStandardLibrary
524+ json : = jsoniter .ConfigCompatibleWithStandardLibrary
524525 err = json .Unmarshal (body , & responseData )
525526 if err != nil {
526527 c .activateFetchCert (err )
0 commit comments