Add golangci-lint workflow (#4999)
* fix lint workflow * add golang lint * close http response body
This commit is contained in:
@@ -15,9 +15,6 @@ const (
|
||||
epRules = apiPrefix + "/rules"
|
||||
statusAPIError = 422
|
||||
|
||||
statusSuccess status = "success"
|
||||
statusError status = "error"
|
||||
|
||||
ErrBadData ErrorType = "bad_data"
|
||||
ErrTimeout ErrorType = "timeout"
|
||||
ErrCanceled ErrorType = "canceled"
|
||||
@@ -84,10 +81,11 @@ func (c *ruleClient) rules(client api.Client, ctx context.Context) ([]*RuleGroup
|
||||
return nil, errors.Wrap(err, "error creating request: ")
|
||||
}
|
||||
|
||||
_, body, _, err := c.do(client, ctx, req)
|
||||
resp, body, _, err := c.do(client, ctx, req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error doing request: ")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var result struct {
|
||||
Groups []*RuleGroup
|
||||
|
||||
@@ -192,6 +192,7 @@ func (b *Build) Stop() (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return false, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -202,7 +203,8 @@ func (b *Build) Stop() (bool, error) {
|
||||
func (b *Build) GetConsoleOutput() string {
|
||||
url := b.Base + "/consoleText"
|
||||
var content string
|
||||
b.Jenkins.Requester.GetXML(url, &content, nil)
|
||||
rsp, _ := b.Jenkins.Requester.GetXML(url, &content, nil)
|
||||
rsp.Body.Close()
|
||||
return content
|
||||
}
|
||||
|
||||
@@ -224,10 +226,11 @@ func (b *Build) GetInjectedEnvVars() (map[string]string, error) {
|
||||
EnvMap map[string]string `json:"envMap"`
|
||||
}
|
||||
endpoint := b.Base + "/injectedEnvVars"
|
||||
_, err := b.Jenkins.Requester.GetJSON(endpoint, &envVars, nil)
|
||||
rsp, err := b.Jenkins.Requester.GetJSON(endpoint, &envVars, nil)
|
||||
if err != nil {
|
||||
return envVars.EnvMap, err
|
||||
}
|
||||
rsp.Body.Close()
|
||||
return envVars.EnvMap, nil
|
||||
}
|
||||
|
||||
@@ -308,13 +311,12 @@ func (b *Build) GetResultSet() (*TestResult, error) {
|
||||
url := b.Base + "/testReport"
|
||||
var report TestResult
|
||||
|
||||
_, err := b.Jenkins.Requester.GetJSON(url, &report, nil)
|
||||
rsp, err := b.Jenkins.Requester.GetJSON(url, &report, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rsp.Body.Close()
|
||||
return &report, nil
|
||||
|
||||
}
|
||||
|
||||
func (b *Build) GetTimestamp() time.Time {
|
||||
@@ -355,7 +357,10 @@ func (b *Build) IsRunning() bool {
|
||||
func (b *Build) SetDescription(description string) error {
|
||||
data := url.Values{}
|
||||
data.Set("description", description)
|
||||
_, err := b.Jenkins.Requester.Post(b.Base+"/submitDescription", bytes.NewBufferString(data.Encode()), nil, nil)
|
||||
resp, err := b.Jenkins.Requester.Post(b.Base+"/submitDescription", bytes.NewBufferString(data.Encode()), nil, nil)
|
||||
if err != nil {
|
||||
resp.Body.Close()
|
||||
}
|
||||
return err
|
||||
}
|
||||
func (b *Build) PauseToggle() error {
|
||||
@@ -363,6 +368,7 @@ func (b *Build) PauseToggle() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -395,6 +401,7 @@ func (b *Build) Poll(options ...interface{}) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
response.Body.Close()
|
||||
return response.StatusCode, nil
|
||||
}
|
||||
|
||||
@@ -403,6 +410,7 @@ func (j *Jenkins) GetProjectPipelineBuildByType(projectId, pipelineId string, st
|
||||
if err != nil {
|
||||
return nil, restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
//nolint:staticcheck
|
||||
build, err := job.getBuildByType(status)
|
||||
return build.Raw, nil
|
||||
}
|
||||
@@ -411,6 +419,7 @@ func (j *Jenkins) GetMultiBranchPipelineBuildByType(projectId, pipelineId, branc
|
||||
if err != nil {
|
||||
return nil, restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
//nolint:staticcheck
|
||||
build, err := job.getBuildByType(status)
|
||||
return build.Raw, nil
|
||||
}
|
||||
|
||||
@@ -177,6 +177,7 @@ func (j *Jenkins) GetCredentialInProject(projectId, id string) (*devops.Credenti
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -197,6 +198,7 @@ func (j *Jenkins) GetCredentialsInProject(projectId string) ([]*devops.Credentia
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -236,7 +238,7 @@ func (j *Jenkins) CreateCredentialInProject(projectId string, credential *v1.Sec
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return "", errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -272,6 +274,7 @@ func (j *Jenkins) UpdateCredentialInProject(projectId string, credential *v1.Sec
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return "", errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -285,6 +288,7 @@ func (j *Jenkins) DeleteCredentialInProject(projectId, id string) (string, error
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return "", errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ func (f *Folder) Create(name, description string) (*Folder, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.Body.Close()
|
||||
if r.StatusCode == 200 {
|
||||
f.Poll()
|
||||
return f, nil
|
||||
@@ -71,5 +72,6 @@ func (f *Folder) Poll() (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
response.Body.Close()
|
||||
return response.StatusCode, nil
|
||||
}
|
||||
|
||||
@@ -72,7 +72,6 @@ func AppendBitbucketServerSourceToEtree(source *etree.Element, gitSource *devops
|
||||
regexTraits.CreateAttr("plugin", "scm-api")
|
||||
regexTraits.CreateElement("regex").SetText(gitSource.RegexFilter)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetBitbucketServerSourceFromEtree(source *etree.Element) *devopsv1alpha3.BitbucketServerSource {
|
||||
|
||||
@@ -53,7 +53,6 @@ func AppendGitSourceToEtree(source *etree.Element, gitSource *devopsv1alpha3.Git
|
||||
regexTraits.CreateAttr("plugin", "scm-api")
|
||||
regexTraits.CreateElement("regex").SetText(gitSource.RegexFilter)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetGitSourcefromEtree(source *etree.Element) *devopsv1alpha3.GitSource {
|
||||
|
||||
@@ -71,7 +71,6 @@ func AppendGithubSourceToEtree(source *etree.Element, githubSource *devopsv1alph
|
||||
regexTraits.CreateAttr("plugin", "scm-api")
|
||||
regexTraits.CreateElement("regex").SetText(githubSource.RegexFilter)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetGithubSourcefromEtree(source *etree.Element) *devopsv1alpha3.GithubSource {
|
||||
|
||||
@@ -70,6 +70,7 @@ func AppendGitlabSourceToEtree(source *etree.Element, gitSource *devopsv1alpha3.
|
||||
regexTraits.CreateAttr("plugin", "scm-api")
|
||||
regexTraits.CreateElement("regex").SetText(gitSource.RegexFilter)
|
||||
}
|
||||
//nolint:gosimple
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ func AppendSvnSourceToEtree(source *etree.Element, svnSource *devopsv1alpha3.Svn
|
||||
if svnSource.Excludes != "" {
|
||||
source.CreateElement("excludes").SetText(svnSource.Excludes)
|
||||
}
|
||||
//nolint:gosimple
|
||||
return
|
||||
}
|
||||
|
||||
@@ -65,7 +66,7 @@ func AppendSingleSvnSourceToEtree(source *etree.Element, svnSource *devopsv1alph
|
||||
source.CreateElement("ignoreDirPropChanges").SetText("false")
|
||||
source.CreateElement("filterChangelog").SetText("false")
|
||||
source.CreateElement("quietOperation").SetText("true")
|
||||
|
||||
//nolint:gosimple
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ func (j *Jenkins) Init() (*Jenkins, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rsp.Body.Close()
|
||||
j.Version = rsp.Header.Get("X-Jenkins")
|
||||
//if j.Raw == nil {
|
||||
// return nil, errors.New("Connection Failed, Please verify that the host and credentials are correct.")
|
||||
@@ -214,6 +214,7 @@ func (j *Jenkins) Poll() (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return resp.StatusCode, nil
|
||||
}
|
||||
|
||||
@@ -233,6 +234,7 @@ func (j *Jenkins) GetGlobalRole(roleName string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return "", errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -279,6 +281,7 @@ func (j *Jenkins) AssignGlobalRole(roleName string, sid string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -301,6 +304,7 @@ func (j *Jenkins) UnAssignGlobalRole(roleName string, sid string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -321,6 +325,7 @@ func (j *Jenkins) GetProjectRole(roleName string) (*ProjectRole, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -353,6 +358,7 @@ func (j *Jenkins) AssignProjectRole(roleName string, sid string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -375,6 +381,7 @@ func (j *Jenkins) UnAssignProjectRole(roleName string, sid string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -402,6 +409,7 @@ func (j *Jenkins) AddGlobalRole(roleName string, ids devops.GlobalPermissionIds,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -419,6 +427,7 @@ func (j *Jenkins) DeleteProjectRoles(roleName ...string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
fmt.Println(responseString)
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
@@ -448,6 +457,7 @@ func (j *Jenkins) AddProjectRole(roleName string, pattern string, ids devops.Pro
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -464,6 +474,7 @@ func (j *Jenkins) DeleteUserInProject(username string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -837,6 +848,7 @@ func (j *Jenkins) CheckCron(projectName string, httpParameters *devops.HttpParam
|
||||
var path string
|
||||
|
||||
reader = httpParameters.Body
|
||||
//nolint:ineffassign,staticcheck
|
||||
cronData, err := ioutil.ReadAll(reader)
|
||||
err = json.Unmarshal(cronData, cron)
|
||||
if err != nil {
|
||||
@@ -889,6 +901,7 @@ func (j *Jenkins) ToJson(httpParameters *devops.HttpParameters) (map[string]inte
|
||||
// After creating an instance call init method.
|
||||
func CreateJenkins(client *http.Client, base string, maxConnection int, auth ...interface{}) *Jenkins {
|
||||
j := &Jenkins{}
|
||||
//nolint:gosimple
|
||||
if strings.HasSuffix(base, "/") {
|
||||
base = base[:len(base)-1]
|
||||
}
|
||||
|
||||
@@ -194,10 +194,11 @@ func (j *Job) GetAllBuildIds() ([]JobBuild, error) {
|
||||
var buildsResp struct {
|
||||
Builds []JobBuild `json:"allBuilds"`
|
||||
}
|
||||
_, err := j.Jenkins.Requester.GetJSON(j.Base, &buildsResp, map[string]string{"tree": "allBuilds[number,url]"})
|
||||
rsp, err := j.Jenkins.Requester.GetJSON(j.Base, &buildsResp, map[string]string{"tree": "allBuilds[number,url]"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rsp.Body.Close()
|
||||
return buildsResp.Builds, nil
|
||||
}
|
||||
|
||||
@@ -205,10 +206,11 @@ func (j *Job) GetAllBuildStatus() ([]JobBuildStatus, error) {
|
||||
var buildsResp struct {
|
||||
Builds []JobBuildStatus `json:"allBuilds"`
|
||||
}
|
||||
_, err := j.Jenkins.Requester.GetJSON(j.Base, &buildsResp, map[string]string{"tree": "allBuilds[number,building,result]"})
|
||||
resp, err := j.Jenkins.Requester.GetJSON(j.Base, &buildsResp, map[string]string{"tree": "allBuilds[number,building,result]"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return buildsResp.Builds, nil
|
||||
}
|
||||
|
||||
@@ -277,6 +279,7 @@ func (j *Job) Enable() (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return false, errors.New(strconv.Itoa(resp.StatusCode))
|
||||
}
|
||||
@@ -288,6 +291,7 @@ func (j *Job) Disable() (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return false, errors.New(strconv.Itoa(resp.StatusCode))
|
||||
}
|
||||
@@ -299,6 +303,7 @@ func (j *Job) Delete() (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return false, errors.New(strconv.Itoa(resp.StatusCode))
|
||||
}
|
||||
@@ -308,10 +313,11 @@ func (j *Job) Delete() (bool, error) {
|
||||
func (j *Job) Rename(name string) (bool, error) {
|
||||
data := url.Values{}
|
||||
data.Set("newName", name)
|
||||
_, err := j.Jenkins.Requester.Post(j.Base+"/doRename", bytes.NewBufferString(data.Encode()), nil, nil)
|
||||
resp, err := j.Jenkins.Requester.Post(j.Base+"/doRename", bytes.NewBufferString(data.Encode()), nil, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
j.Base = "/job/" + name
|
||||
j.Poll()
|
||||
return true, nil
|
||||
@@ -326,6 +332,7 @@ func (j *Job) Create(config string, qr ...interface{}) (*Job, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode == 200 {
|
||||
j.Poll()
|
||||
return j, nil
|
||||
@@ -339,6 +346,7 @@ func (j *Job) Copy(destinationName string) (*Job, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode == 200 {
|
||||
newJob := &Job{Jenkins: j.Jenkins, Raw: new(JobResponse), Base: "/job/" + destinationName}
|
||||
_, err := newJob.Poll()
|
||||
@@ -358,6 +366,7 @@ func (j *Job) UpdateConfig(config string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode == 200 {
|
||||
j.Poll()
|
||||
return nil
|
||||
@@ -368,10 +377,11 @@ func (j *Job) UpdateConfig(config string) error {
|
||||
|
||||
func (j *Job) GetConfig() (string, error) {
|
||||
var data string
|
||||
_, err := j.Jenkins.Requester.GetXML(j.Base+"/config.xml", &data, nil)
|
||||
resp, err := j.Jenkins.Requester.GetXML(j.Base+"/config.xml", &data, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -433,7 +443,7 @@ func (j *Job) InvokeSimple(params map[string]string) (int64, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != 200 && resp.StatusCode != 201 {
|
||||
return 0, errors.New("Could not invoke job " + j.GetName())
|
||||
}
|
||||
@@ -490,6 +500,7 @@ func (j *Job) Invoke(files []string, skipIfRunning bool, params map[string]strin
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode == 200 || resp.StatusCode == 201 {
|
||||
return true, nil
|
||||
}
|
||||
@@ -501,5 +512,6 @@ func (j *Job) Poll() (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
response.Body.Close()
|
||||
return response.StatusCode, nil
|
||||
}
|
||||
|
||||
@@ -179,6 +179,7 @@ func (p *Pipeline) ListPipelineRuns() (*devops.PipelineRunList, error) {
|
||||
// listPipelineRunsByRemotePaging get the pipeline runs with pagination by remote (Jenkins BlueOcean plugin)
|
||||
// get the pagination information from the server side is better than the local side, but the API has some issues
|
||||
// see also https://github.com/kubesphere/kubesphere/issues/3507
|
||||
//nolint:unused
|
||||
func (p *Pipeline) listPipelineRunsByRemotePaging() (*devops.PipelineRunList, error) {
|
||||
res, err := p.Jenkins.SendPureRequest(p.Path, p.HttpParameters)
|
||||
if err != nil {
|
||||
@@ -258,6 +259,7 @@ func (p *Pipeline) parsePaging() (start, limit int) {
|
||||
return
|
||||
}
|
||||
|
||||
//nolint:unused
|
||||
func (p *Pipeline) searchPipelineRunsCount() (int, error) {
|
||||
u, err := p.resetPaging(0, 1000)
|
||||
if err != nil {
|
||||
|
||||
@@ -269,6 +269,7 @@ func appendMultiBranchJobTriggerToEtree(properties *etree.Element, s *devopsv1al
|
||||
triggerProperty.CreateAttr("plugin", "multibranch-action-triggers")
|
||||
triggerProperty.CreateElement("createActionJobsToTrigger").SetText(s.CreateActionJobsToTrigger)
|
||||
triggerProperty.CreateElement("deleteActionJobsToTrigger").SetText(s.DeleteActionJobsToTrigger)
|
||||
//nolint:gosimple
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ func (j *Jenkins) ValidateJenkinsfile(jenkinsfile string) (*ValidateJenkinsfileR
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -95,6 +96,7 @@ func (j *Jenkins) ValidatePipelineJson(json string) (*ValidatePipelineJsonRespon
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -110,6 +112,7 @@ func (j *Jenkins) PipelineJsonToJenkinsfile(json string) (*PipelineJsonToJenkins
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -125,6 +128,7 @@ func (j *Jenkins) JenkinsfileToPipelineJson(jenkinsfile string) (*JenkinsfileToP
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -140,6 +144,7 @@ func (j *Jenkins) StepsJsonToJenkinsfile(json string) (*StepJsonToJenkinsfileRes
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -155,6 +160,7 @@ func (j *Jenkins) StepsJenkinsfileToJson(jenkinsfile string) (*StepsJenkinsfileT
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ func (r *Requester) SetCrumb(ar *APIRequest) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode == 200 && crumbData["crumbRequestField"] != "" {
|
||||
ar.SetHeader(crumbData["crumbRequestField"], crumbData["crumb"])
|
||||
}
|
||||
@@ -185,6 +186,7 @@ func (r *Requester) SetClient(client *http.Client) *Requester {
|
||||
}
|
||||
|
||||
//Add auth on redirect if required.
|
||||
//nolint:unused
|
||||
func (r *Requester) redirectPolicyFunc(req *http.Request, via []*http.Request) error {
|
||||
if r.BasicAuth != nil {
|
||||
req.SetBasicAuth(r.BasicAuth.Username, r.BasicAuth.Password)
|
||||
@@ -410,7 +412,7 @@ func (r *Requester) DoPostForm(ar *APIRequest, responseStruct interface{}, form
|
||||
for k, v := range form {
|
||||
formValue.Set(k, v)
|
||||
}
|
||||
req, err := http.NewRequest("POST", URL.String(), strings.NewReader(formValue.Encode()))
|
||||
req, _ := http.NewRequest("POST", URL.String(), strings.NewReader(formValue.Encode()))
|
||||
if r.BasicAuth != nil {
|
||||
req.SetBasicAuth(r.BasicAuth.Username, r.BasicAuth.Password)
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ func (j *GlobalRole) Update(ids devops.GlobalPermissionIds) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -85,6 +86,7 @@ func (j *GlobalRole) AssignRole(sid string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -102,6 +104,7 @@ func (j *GlobalRole) UnAssignRole(sid string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -131,6 +134,7 @@ func (j *ProjectRole) Update(pattern string, ids devops.ProjectPermissionIds) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -148,6 +152,7 @@ func (j *ProjectRole) AssignRole(sid string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
@@ -165,6 +170,7 @@ func (j *ProjectRole) UnAssignRole(sid string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return errors.New(strconv.Itoa(response.StatusCode))
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ func (b *Bool) AppendFilter(item Item) *Bool {
|
||||
|
||||
func (b *Bool) AppendMultiFilter(items []Item) *Bool {
|
||||
|
||||
if items == nil || len(items) == 0 {
|
||||
if len(items) == 0 {
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ func (b *Bool) AppendShould(item Item) *Bool {
|
||||
|
||||
func (b *Bool) AppendMultiShould(items []Item) *Bool {
|
||||
|
||||
if items == nil || len(items) == 0 {
|
||||
if len(items) == 0 {
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ func (b *Bool) AppendMustNot(item Item) *Bool {
|
||||
|
||||
func (b *Bool) AppendMultiMustNot(items []Item) *Bool {
|
||||
|
||||
if items == nil || len(items) == 0 {
|
||||
if len(items) == 0 {
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ func NewMultiMatchPhrase(key string, val []string) []Item {
|
||||
|
||||
var array []Item
|
||||
|
||||
if val == nil || len(val) == 0 {
|
||||
if len(val) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ func NewMultiMatchPhrasePrefix(key string, val []string) []Item {
|
||||
|
||||
var array []Item
|
||||
|
||||
if val == nil || len(val) == 0 {
|
||||
if len(val) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ func NewMultiWildcard(key string, val []string) []Item {
|
||||
|
||||
var array []Item
|
||||
|
||||
if val == nil || len(val) == 0 {
|
||||
if len(val) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ func TestClient_Get(t *testing.T) {
|
||||
tt.fields.ServiceToken,
|
||||
tt.fields.Host,
|
||||
)
|
||||
//nolint:bodyclose
|
||||
gotResp, err := c.Get(tt.args.url)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Client.Get() error = %v, wantErr %v", err, tt.wantErr)
|
||||
|
||||
@@ -175,7 +175,6 @@ func (c *channelPool) Close() {
|
||||
for conn := range conns {
|
||||
conn.Close()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c *channelPool) Len() int { return len(c.getConns()) }
|
||||
|
||||
@@ -71,6 +71,7 @@ func (p *PoolConn) MarkUnusable() {
|
||||
p.unusable = true
|
||||
}
|
||||
|
||||
//nolint:unused
|
||||
func (p *PoolConn) autoClose(err error) {
|
||||
for _, code := range p.closeAt {
|
||||
if ldap.IsErrorWithCode(err, code) {
|
||||
|
||||
@@ -35,19 +35,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ldapAttributeObjectClass = "objectClass"
|
||||
ldapAttributeCommonName = "cn"
|
||||
ldapAttributeSerialNumber = "sn"
|
||||
ldapAttributeGlobalIDNumber = "gidNumber"
|
||||
ldapAttributeHomeDirectory = "homeDirectory"
|
||||
ldapAttributeUserID = "uid"
|
||||
ldapAttributeUserIDNumber = "uidNumber"
|
||||
ldapAttributeMail = "mail"
|
||||
ldapAttributeUserPassword = "userPassword"
|
||||
ldapAttributePreferredLanguage = "preferredLanguage"
|
||||
ldapAttributeDescription = "description"
|
||||
ldapAttributeCreateTimestamp = "createTimestamp"
|
||||
ldapAttributeOrganizationUnit = "ou"
|
||||
ldapAttributeObjectClass = "objectClass"
|
||||
ldapAttributeCommonName = "cn"
|
||||
ldapAttributeSerialNumber = "sn"
|
||||
ldapAttributeUserID = "uid"
|
||||
ldapAttributeMail = "mail"
|
||||
ldapAttributeUserPassword = "userPassword"
|
||||
ldapAttributeDescription = "description"
|
||||
ldapAttributeCreateTimestamp = "createTimestamp"
|
||||
ldapAttributeOrganizationUnit = "ou"
|
||||
|
||||
// ldap create timestamp attribute layout
|
||||
ldapAttributeCreateTimestampLayout = "20060102150405Z"
|
||||
|
||||
@@ -176,7 +176,7 @@ func (c *client) ExportLogs(sf logging.SearchFilter, w io.Writer) error {
|
||||
|
||||
output := new(bytes.Buffer)
|
||||
for _, l := range data {
|
||||
output.WriteString(fmt.Sprintf(`%s`, stringutils.StripAnsi(l)))
|
||||
output.WriteString(stringutils.StripAnsi(l))
|
||||
}
|
||||
_, err = io.Copy(w, output)
|
||||
if err != nil {
|
||||
|
||||
@@ -532,7 +532,7 @@ func sortedResults(result []monitoring.Metric) []monitoring.Metric {
|
||||
metricValues := mr.MetricData.MetricValues
|
||||
length := len(metricValues)
|
||||
for i, mv := range metricValues {
|
||||
podName, _ := mv.Metadata["pod"]
|
||||
podName := mv.Metadata["pod"]
|
||||
if i == 0 && podName == "pod2" && length >= 2 {
|
||||
metricValues[0], metricValues[1] = metricValues[1], metricValues[0]
|
||||
}
|
||||
|
||||
@@ -155,6 +155,7 @@ type ApplicationsOption struct {
|
||||
|
||||
func (aso ApplicationsOption) Apply(o *QueryOptions) {
|
||||
// nothing should be done
|
||||
//nolint:gosimple
|
||||
return
|
||||
}
|
||||
|
||||
@@ -167,6 +168,7 @@ type OpenpitrixsOption struct {
|
||||
|
||||
func (oso OpenpitrixsOption) Apply(o *QueryOptions) {
|
||||
// nothing should be done
|
||||
//nolint:gosimple
|
||||
return
|
||||
}
|
||||
|
||||
@@ -213,6 +215,7 @@ type ServicesOption struct {
|
||||
|
||||
func (sso ServicesOption) Apply(o *QueryOptions) {
|
||||
// nothing should be done
|
||||
//nolint:gosimple
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ func (mv *MetricValue) TransferToExportedMetricValue() {
|
||||
}
|
||||
mv.Series = nil
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (p Point) Timestamp() float64 {
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package calico
|
||||
|
||||
type Options struct {
|
||||
IPIPMode string `json:"ipipMode,omityempty" yaml:"ipipMode,omityempty"`
|
||||
VXLANMode string `json:"vxlanMode,omityempty" yaml:"vxlanMode,omityempty"`
|
||||
NATOutgoing bool `json:"natOutgoing,omitempty" yaml:"natOutgoing,omityempty"`
|
||||
IPIPMode string `json:"ipipMode,omitempty" yaml:"ipipMode,omitempty"`
|
||||
VXLANMode string `json:"vxlanMode,omitempty" yaml:"vxlanMode,omitempty"`
|
||||
NATOutgoing bool `json:"natOutgoing,omitempty" yaml:"natOutgoing,omitempty"`
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ func (c IPAMClient) findUnclaimedBlock(pool *v1alpha1.IPPool) (*v1alpha1.IPAMBlo
|
||||
/// Build a map for faster lookups.
|
||||
exists := map[string]bool{}
|
||||
for _, e := range existingBlocks {
|
||||
exists[fmt.Sprintf("%s", e.Spec.CIDR)] = true
|
||||
exists[e.Spec.CIDR] = true
|
||||
}
|
||||
|
||||
// Iterate through pools to find a new block.
|
||||
@@ -512,7 +512,7 @@ func (c IPAMClient) findUnclaimedBlock(pool *v1alpha1.IPPool) (*v1alpha1.IPAMBlo
|
||||
blocks := blockGenerator(pool)
|
||||
for subnet := blocks(); subnet != nil; subnet = blocks() {
|
||||
// Check if a block already exists for this subnet.
|
||||
if _, ok := exists[fmt.Sprintf("%s", subnet.String())]; !ok {
|
||||
if _, ok := exists[subnet.String()]; !ok {
|
||||
result = v1alpha1.NewBlock(pool, *subnet, nil)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -21,5 +21,5 @@ import (
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
Calico *calico.Options `json:"calico,omityempty" yaml:"calico,omityempty"`
|
||||
Calico *calico.Options `json:"calico,omitempty" yaml:"calico,omitempty"`
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func NewNetworkOptions() *Options {
|
||||
}
|
||||
|
||||
func (s *Options) IsEmpty() bool {
|
||||
return s.EnableNetworkPolicy == false &&
|
||||
return !s.EnableNetworkPolicy &&
|
||||
s.WeaveScopeHost == "" &&
|
||||
s.IPPoolType == networkv1alpha1.IPPoolTypeNone
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ func NewNotificationOptions() *Options {
|
||||
|
||||
func (s *Options) ApplyTo(options *Options) {
|
||||
if options == nil {
|
||||
//nolint:staticcheck
|
||||
options = s
|
||||
return
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func (c *helmWrapper) IsReleaseReady(waitTime time.Duration) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
client := c.helmConf.KubeClient
|
||||
resources, err := client.Build(bytes.NewBufferString(manifest), true)
|
||||
resources, _ := client.Build(bytes.NewBufferString(manifest), true)
|
||||
|
||||
err = client.Wait(resources, waitTime)
|
||||
|
||||
@@ -95,7 +95,6 @@ func (c *helmWrapper) IsReleaseReady(waitTime time.Duration) (bool, error) {
|
||||
|
||||
func (c *helmWrapper) Status() (*helmrelease.Release, error) {
|
||||
helmStatus := action.NewStatus(c.helmConf)
|
||||
|
||||
rel, err := helmStatus.Run(c.ReleaseName)
|
||||
if err != nil {
|
||||
if err.Error() == StatusNotFoundFormat {
|
||||
@@ -272,7 +271,7 @@ func (c *helmWrapper) createChart(chartName, chartData, values string) error {
|
||||
func (c *helmWrapper) Uninstall() error {
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
klog.V(2).Infof("run command end, namespace: %s, name: %s elapsed: %v", c.Namespace, c.ReleaseName, time.Now().Sub(start))
|
||||
klog.V(2).Infof("run command end, namespace: %s, name: %s elapsed: %v", c.Namespace, c.ReleaseName, time.Since(start))
|
||||
}()
|
||||
|
||||
uninstall := action.NewUninstall(c.helmConf)
|
||||
@@ -367,7 +366,7 @@ func (c *helmWrapper) writeAction(chartName, chartData, values string, upgrade b
|
||||
if klog.V(2) {
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
klog.V(2).Infof("run command end, namespace: %s, name: %s, upgrade: %t, elapsed: %v", c.Namespace, c.ReleaseName, upgrade, time.Now().Sub(start))
|
||||
klog.V(2).Infof("run command end, namespace: %s, name: %s, upgrade: %t, elapsed: %v", c.Namespace, c.ReleaseName, upgrade, time.Since(start))
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ func (s *sonarQube) GetSonarResultsByTaskIds(taskIds ...string) ([]*SonarStatus,
|
||||
S: "FILE_LINE",
|
||||
Facets: "severities,types",
|
||||
}
|
||||
issuesSearch, _, err := s.client.Issues.Search(issuesSearchOption)
|
||||
issuesSearch, _, _ := s.client.Issues.Search(issuesSearchOption)
|
||||
sonarStatus.Issues = issuesSearch
|
||||
sonarStatuses = append(sonarStatuses, sonarStatus)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user