linter fixes

This commit is contained in:
ston1th 2021-11-07 11:57:25 +01:00
commit ffb356182e
4 changed files with 8 additions and 11 deletions

View file

@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/http/httputil"
@ -37,7 +36,7 @@ func ExponentialBackoff(b float64, d time.Duration) BackoffFunc {
*/
type Client struct {
sync.Mutex
mu sync.Mutex
endpoints []string
username string
password string
@ -231,8 +230,8 @@ func (c *Client) Auth() (err error) {
if !time.Now().After(c.session.Time) {
return
}
c.Lock()
defer c.Unlock()
c.mu.Lock()
defer c.mu.Unlock()
if !time.Now().After(c.session.Time) {
return
}
@ -289,13 +288,13 @@ func (c *Client) Do(r *http.Request, v interface{}) (resp *http.Response, err er
if err != nil {
return
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
resp.Body.Close()
return
}
resp.Body.Close()
resp.Body = ioutil.NopCloser(bytes.NewReader(body))
resp.Body = io.NopCloser(bytes.NewReader(body))
if c.debugWriter != nil {
dumpResp, err := httputil.DumpResponse(resp, true)

View file

@ -313,7 +313,7 @@ func (o *ServerTemplateOpts) Validate(ctx context.Context, c *Client) error {
return nil
}
func (o ServerTemplateOpts) body() httpbody {
func (o *ServerTemplateOpts) body() httpbody {
body := httpbody{"name": o.Name}
if o.TargetStorage != "" {
body["storage"] = o.TargetStorage
@ -325,7 +325,7 @@ func (o ServerTemplateOpts) body() httpbody {
return body
}
func (c *ServerClient) CreateFromTemplate(ctx context.Context, opts ServerTemplateOpts) (t *Task, url string, err error) {
func (c *ServerClient) CreateFromTemplate(ctx context.Context, opts *ServerTemplateOpts) (t *Task, url string, err error) {
err = opts.Validate(ctx, c.client)
if err != nil {
return

View file

@ -97,7 +97,7 @@ func (c *TaskClient) Wait(ctx context.Context, t *Task, f OnTaskChange) error {
}
}
time.Sleep(TaskStatusCheckInterval * time.Second)
waited = waited + TaskStatusCheckInterval
waited += TaskStatusCheckInterval
}
return errors.New("task wait timeout for: " + t.ID)
}

View file

@ -3,8 +3,6 @@
package pve
import (
//"encoding/base64"
//"net/url"
"gopkg.in/yaml.v2"
)