debug statements
All checks were successful
Pipeline was successful

This commit is contained in:
Tobias Trabelsi 2023-11-13 20:50:33 +01:00
parent c431131d5f
commit 09c85fc3bd
Signed by: lerentis
GPG Key ID: FF0C2839718CAF2E

View File

@ -106,6 +106,9 @@ func CreateWoodpeckerAgent(cfg *config.Config) (*models.Agent, error) {
bodyReader := bytes.NewReader(jsonBody) bodyReader := bytes.NewReader(jsonBody)
apiRoute := fmt.Sprintf("%s/api/agents", cfg.WoodpeckerInstance) apiRoute := fmt.Sprintf("%s/api/agents", cfg.WoodpeckerInstance)
log.WithFields(log.Fields{
"Caller": "CreateWoodpeckerAgent",
}).Debugf("Sending the following data to %s: %s", apiRoute, jsonBody)
req, err := http.NewRequest(http.MethodPost, apiRoute, bodyReader) req, err := http.NewRequest(http.MethodPost, apiRoute, bodyReader)
if err != nil { if err != nil {
return nil, errors.New(fmt.Sprintf("Could not create agent request: %s", err.Error())) return nil, errors.New(fmt.Sprintf("Could not create agent request: %s", err.Error()))
@ -114,6 +117,9 @@ func CreateWoodpeckerAgent(cfg *config.Config) (*models.Agent, error) {
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", cfg.WoodpeckerApiToken)) req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", cfg.WoodpeckerApiToken))
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
log.WithFields(log.Fields{
"Caller": "CreateWoodpeckerAgent",
}).Debugf("Response from woodpecker: %s", resp.Body)
if err != nil { if err != nil {
return nil, errors.New(fmt.Sprintf("Could not create new Agent: %s", err.Error())) return nil, errors.New(fmt.Sprintf("Could not create new Agent: %s", err.Error()))
} }