27 lines
450 B
Go
27 lines
450 B
Go
|
package wazuh
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
|
||
|
"forge.cadoles.com/cadoles/wazuh-agent-k8s-autoadd/internal/config"
|
||
|
)
|
||
|
|
||
|
func AddAgent(cfg Config) (error) {
|
||
|
// Craft jwt
|
||
|
|
||
|
resp, err := http.DefaultClient.Post(cfg.BaseURL + "/agents")
|
||
|
if err != nil {
|
||
|
return false, err
|
||
|
}
|
||
|
defer resp.Body.Close()
|
||
|
|
||
|
switch resp.StatusCode {
|
||
|
case http.StatusOK:
|
||
|
return nil
|
||
|
default:
|
||
|
return false, fmt.Errorf("Bad status: %d", resp.StatusCode)
|
||
|
}
|
||
|
}
|