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

View file

@ -313,7 +313,7 @@ func (o *ServerTemplateOpts) Validate(ctx context.Context, c *Client) error {
return nil return nil
} }
func (o ServerTemplateOpts) body() httpbody { func (o *ServerTemplateOpts) body() httpbody {
body := httpbody{"name": o.Name} body := httpbody{"name": o.Name}
if o.TargetStorage != "" { if o.TargetStorage != "" {
body["storage"] = o.TargetStorage body["storage"] = o.TargetStorage
@ -325,7 +325,7 @@ func (o ServerTemplateOpts) body() httpbody {
return body 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) err = opts.Validate(ctx, c.client)
if err != nil { if err != nil {
return return

View file

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

View file

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