mirror of
https://github.com/jenkinsci/kubernetes-operator.git
synced 2026-10-05 15:41:10 +02:00
update to go 1.22 and operator-sdk 1.35 (#1094)
Co-authored-by: brokenpip3 <brokenpip3@gmail.com> Co-authored-by: Ansh Garhewal <me@anshdevs.in> Co-authored-by: xmbhasin <xmbhasin@users.noreply.github.com>
This commit is contained in:
co-authored by
brokenpip3
Ansh Garhewal
xmbhasin
parent
1ec83b9de9
commit
9c09db8031
@@ -2,6 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -9,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/bndr/gojenkins"
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/log"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -38,18 +40,19 @@ func (jenkins *jenkins) executeScript(script string, verifier string) (string, e
|
||||
data.Set("script", fullScript)
|
||||
|
||||
ar := gojenkins.NewAPIRequest("POST", "/scriptText", bytes.NewBufferString(data.Encode()))
|
||||
if err := jenkins.Requester.SetCrumb(ar); err != nil {
|
||||
if err := jenkins.Requester.SetCrumb(context.TODO(), ar); err != nil {
|
||||
return output, err
|
||||
}
|
||||
ar.SetHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||
ar.Suffix = ""
|
||||
|
||||
r, err := jenkins.Requester.Do(ar, &output, nil)
|
||||
r, err := jenkins.Requester.Do(context.TODO(), ar, &output, nil)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "couldn't execute groovy script, logs '%s'", output)
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
if err := r.Body.Close(); err != nil {
|
||||
log.Log.Error(err, "failed to close jenkins.executeScript.Requester")
|
||||
}
|
||||
if r.StatusCode != http.StatusOK {
|
||||
return output, errors.Errorf("invalid status code '%d', logs '%s'", r.StatusCode, output)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user