@@ -26,7 +26,7 @@ import (
26
26
"encoding/asn1"
27
27
"encoding/pem"
28
28
"fmt"
29
- "io/ioutil "
29
+ "io"
30
30
"net/http"
31
31
"path"
32
32
"strconv"
@@ -146,7 +146,7 @@ func (c *ClusterSync) issueRefreshRequest(url, port, basePath string, nodesPath
146
146
json := jsoniter .ConfigCompatibleWithStandardLibrary
147
147
bytesRepresentation , _ := json .Marshal (nodeData )
148
148
149
- req , err := http .NewRequest ("PATCH" , url , bytes .NewBuffer (bytesRepresentation ))
149
+ req , err := http .NewRequest (http . MethodPatch , url , bytes .NewBuffer (bytesRepresentation ))
150
150
if err != nil {
151
151
return fmt .Errorf ("error creating new POST request for cluster comunication" )
152
152
}
@@ -160,11 +160,11 @@ func (c *ClusterSync) issueRefreshRequest(url, port, basePath string, nodesPath
160
160
}
161
161
defer resp .Body .Close ()
162
162
163
- body , err := ioutil .ReadAll (resp .Body )
163
+ body , err := io .ReadAll (resp .Body )
164
164
if err != nil {
165
165
return err
166
166
}
167
- if resp .StatusCode != 202 {
167
+ if resp .StatusCode != http . StatusAccepted {
168
168
return fmt .Errorf ("status code not proper [%d] %s" , resp .StatusCode , string (body ))
169
169
}
170
170
var responseData Node
@@ -366,7 +366,7 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
366
366
}
367
367
defer resp .Body .Close ()
368
368
369
- body , err := ioutil .ReadAll (resp .Body )
369
+ body , err := io .ReadAll (resp .Body )
370
370
if err != nil {
371
371
return err
372
372
}
@@ -385,7 +385,7 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
385
385
return errCfg
386
386
}
387
387
// 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 )
389
389
if errFID != nil {
390
390
return errFID
391
391
}
@@ -501,7 +501,7 @@ func (c *ClusterSync) fetchCert() {
501
501
apiNodesPath := c .cfg .Cluster .APINodesPath .Load ()
502
502
id := c .cfg .Cluster .ID .Load ()
503
503
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 )
505
505
if err != nil {
506
506
c .activateFetchCert (err )
507
507
break
@@ -514,13 +514,13 @@ func (c *ClusterSync) fetchCert() {
514
514
c .activateFetchCert (err )
515
515
break
516
516
}
517
- body , err := ioutil .ReadAll (resp .Body )
517
+ body , err := io .ReadAll (resp .Body )
518
518
resp .Body .Close ()
519
519
if err != nil {
520
520
c .activateFetchCert (err )
521
521
break
522
522
}
523
- if resp .StatusCode != 200 {
523
+ if resp .StatusCode != http . StatusOK {
524
524
c .activateFetchCert (fmt .Errorf ("status code not proper [%d] %s" , resp .StatusCode , string (body )))
525
525
break
526
526
}
@@ -605,7 +605,6 @@ func createHTTPClient() *http.Client {
605
605
Transport : & http.Transport {
606
606
MaxIdleConnsPerHost : 20 ,
607
607
TLSClientConfig : & tls.Config {
608
- //nolint
609
608
InsecureSkipVerify : true , // this is deliberate, might only have self signed certificate
610
609
},
611
610
},
0 commit comments