@@ -26,7 +26,7 @@ import (
2626 "encoding/asn1"
2727 "encoding/pem"
2828 "fmt"
29- "io/ioutil "
29+ "io"
3030 "net/http"
3131 "path"
3232 "strconv"
@@ -146,7 +146,7 @@ func (c *ClusterSync) issueRefreshRequest(url, port, basePath string, nodesPath
146146 json := jsoniter .ConfigCompatibleWithStandardLibrary
147147 bytesRepresentation , _ := json .Marshal (nodeData )
148148
149- req , err := http .NewRequest ("PATCH" , url , bytes .NewBuffer (bytesRepresentation ))
149+ req , err := http .NewRequest (http . MethodPatch , url , bytes .NewBuffer (bytesRepresentation ))
150150 if err != nil {
151151 return fmt .Errorf ("error creating new POST request for cluster comunication" )
152152 }
@@ -160,11 +160,11 @@ func (c *ClusterSync) issueRefreshRequest(url, port, basePath string, nodesPath
160160 }
161161 defer resp .Body .Close ()
162162
163- body , err := ioutil .ReadAll (resp .Body )
163+ body , err := io .ReadAll (resp .Body )
164164 if err != nil {
165165 return err
166166 }
167- if resp .StatusCode != 202 {
167+ if resp .StatusCode != http . StatusAccepted {
168168 return fmt .Errorf ("status code not proper [%d] %s" , resp .StatusCode , string (body ))
169169 }
170170 var responseData Node
@@ -366,7 +366,7 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
366366 }
367367 defer resp .Body .Close ()
368368
369- body , err := ioutil .ReadAll (resp .Body )
369+ body , err := io .ReadAll (resp .Body )
370370 if err != nil {
371371 return err
372372 }
@@ -385,7 +385,7 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
385385 return errCfg
386386 }
387387 // write id to file
388- errFID := ioutil .WriteFile (c .cfg .HAProxy .NodeIDFile , []byte (responseData .ID ), 0o644 ) // nolint:gosec
388+ errFID := renameio .WriteFile (c .cfg .HAProxy .NodeIDFile , []byte (responseData .ID ), 0o644 )
389389 if errFID != nil {
390390 return errFID
391391 }
@@ -501,7 +501,7 @@ func (c *ClusterSync) fetchCert() {
501501 apiNodesPath := c .cfg .Cluster .APINodesPath .Load ()
502502 id := c .cfg .Cluster .ID .Load ()
503503 url = fmt .Sprintf ("%s:%d/%s" , url , port , strings .TrimLeft (path .Join (apiBasePath , apiNodesPath , id ), "/" ))
504- req , err := http .NewRequest ("GET" , url , nil )
504+ req , err := http .NewRequest (http . MethodGet , url , nil )
505505 if err != nil {
506506 c .activateFetchCert (err )
507507 break
@@ -514,13 +514,13 @@ func (c *ClusterSync) fetchCert() {
514514 c .activateFetchCert (err )
515515 break
516516 }
517- body , err := ioutil .ReadAll (resp .Body )
517+ body , err := io .ReadAll (resp .Body )
518518 resp .Body .Close ()
519519 if err != nil {
520520 c .activateFetchCert (err )
521521 break
522522 }
523- if resp .StatusCode != 200 {
523+ if resp .StatusCode != http . StatusOK {
524524 c .activateFetchCert (fmt .Errorf ("status code not proper [%d] %s" , resp .StatusCode , string (body )))
525525 break
526526 }
@@ -605,7 +605,6 @@ func createHTTPClient() *http.Client {
605605 Transport : & http.Transport {
606606 MaxIdleConnsPerHost : 20 ,
607607 TLSClientConfig : & tls.Config {
608- //nolint
609608 InsecureSkipVerify : true , // this is deliberate, might only have self signed certificate
610609 },
611610 },
0 commit comments