Skip to content

Commit 3e74d51

Browse files
rmaticevicmjuraga
authored andcommitted
MINOR: cluster: read register method from boostrap key if set
1 parent 8872c14 commit 3e74d51

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

configuration/cluster_sync.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ func (c *ClusterSync) monitorBootstrapKey() {
252252
if err != nil {
253253
log.Panic(err)
254254
}
255-
err = c.issueJoinRequest(url, data["port"], data["api-base-path"], c.cfg.Cluster.APIRegisterPath.Load(), csr, key)
255+
registerMerhod := "POST"
256+
if method, ok := data["register-method"]; ok {
257+
registerMerhod = method
258+
}
259+
err = c.issueJoinRequest(url, data["port"], data["api-base-path"], c.cfg.Cluster.APIRegisterPath.Load(), registerMerhod, csr, key)
256260
if err != nil {
257261
log.Warning(err)
258262
break
@@ -266,7 +270,7 @@ func (c *ClusterSync) monitorBootstrapKey() {
266270
}
267271
}
268272

269-
func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath string, csr, key string) error {
273+
func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath string, registerMethod string, csr, key string) error {
270274
url = fmt.Sprintf("%s:%s/%s", url, port, strings.TrimLeft(path.Join(basePath, registerPath), "/"))
271275
apiCfg := c.cfg.APIOptions
272276
userStore := GetUsersStore()
@@ -340,9 +344,9 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
340344

341345
bytesRepresentation, _ := json.Marshal(nodeData)
342346

343-
req, err := http.NewRequest("POST", url, bytes.NewBuffer(bytesRepresentation))
347+
req, err := http.NewRequest(registerMethod, url, bytes.NewBuffer(bytesRepresentation))
344348
if err != nil {
345-
return fmt.Errorf("error creating new POST request for cluster comunication")
349+
return fmt.Errorf("error creating new %s request for cluster comunication", registerMethod)
346350
}
347351
req.Header.Add("X-Bootstrap-Key", c.cfg.Cluster.BootstrapKey.Load())
348352
req.Header.Add("Content-Type", "application/json")

0 commit comments

Comments
 (0)