refactor: move from io/ioutil to io and os packages (#5266)
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. [1]: https://golang.org/doc/go1.16#ioutil Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@ package fake
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -113,7 +113,7 @@ func (d *Devops) DeleteDevOpsProject(projectId string) error {
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Body: io.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
},
|
||||
Message: "",
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func (d *Devops) GetDevOpsProject(projectId string) (string, error) {
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Body: io.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
@@ -211,7 +211,7 @@ func (d *Devops) SubmitInputStep(projectName, pipelineName, runId, nodeId, stepI
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
//BranchPipelinne operator interface
|
||||
// BranchPipelinne operator interface
|
||||
func (d *Devops) GetBranchPipeline(projectName, pipelineName, branchName string, httpParameters *devops.HttpParameters) (*devops.BranchPipeline, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -283,7 +283,7 @@ func (d *Devops) Validate(scmId string, httpParameters *devops.HttpParameters) (
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
//Webhook operator interface
|
||||
// Webhook operator interface
|
||||
func (d *Devops) GetNotifyCommit(httpParameters *devops.HttpParameters) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -327,7 +327,7 @@ func (d *Devops) UpdateCredentialInProject(projectId string, credential *v1.Secr
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Body: io.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
@@ -365,7 +365,7 @@ func (d *Devops) GetCredentialInProject(projectId, id string) (*devops.Credentia
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Body: io.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
@@ -404,7 +404,7 @@ func (d *Devops) DeleteCredentialInProject(projectId, id string) (string, error)
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Body: io.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
@@ -460,7 +460,7 @@ func (d *Devops) DeleteProjectPipeline(projectId string, pipelineId string) (str
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Body: io.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
@@ -498,7 +498,7 @@ func (d *Devops) UpdateProjectPipeline(projectId string, pipeline *devopsv1alpha
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Body: io.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
@@ -536,7 +536,7 @@ func (d *Devops) GetProjectPipelineConfig(projectId, pipelineId string) (*devops
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Body: io.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -849,7 +848,7 @@ func (j *Jenkins) CheckCron(projectName string, httpParameters *devops.HttpParam
|
||||
|
||||
reader = httpParameters.Body
|
||||
//nolint:ineffassign,staticcheck
|
||||
cronData, err := ioutil.ReadAll(reader)
|
||||
cronData, err := io.ReadAll(reader)
|
||||
err = json.Unmarshal(cronData, cron)
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -185,7 +184,8 @@ func (r *Requester) SetClient(client *http.Client) *Requester {
|
||||
return r
|
||||
}
|
||||
|
||||
//Add auth on redirect if required.
|
||||
// Add auth on redirect if required.
|
||||
//
|
||||
//nolint:unused
|
||||
func (r *Requester) redirectPolicyFunc(req *http.Request, via []*http.Request) error {
|
||||
if r.BasicAuth != nil {
|
||||
@@ -448,7 +448,7 @@ func (r *Requester) DoPostForm(ar *APIRequest, responseStruct interface{}, form
|
||||
func (r *Requester) ReadRawResponse(response *http.Response, responseStruct interface{}) (*http.Response, error) {
|
||||
defer response.Body.Close()
|
||||
|
||||
content, err := ioutil.ReadAll(response.Body)
|
||||
content, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -478,7 +478,7 @@ func CheckResponse(r *http.Response) error {
|
||||
}
|
||||
defer r.Body.Close()
|
||||
errorResponse := &devops.ErrorResponse{Response: r}
|
||||
data, err := ioutil.ReadAll(r.Body)
|
||||
data, err := io.ReadAll(r.Body)
|
||||
if err == nil && data != nil {
|
||||
errorResponse.Body = data
|
||||
errorResponse.Message = string(data)
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"compress/gzip"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -64,7 +63,7 @@ func getRespBody(resp *http.Response) ([]byte, error) {
|
||||
} else {
|
||||
reader = resp.Body
|
||||
}
|
||||
resBody, err := ioutil.ReadAll(reader)
|
||||
resBody, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user