linter fixes
This commit is contained in:
parent
6c04e86a8c
commit
ffb356182e
4 changed files with 8 additions and 11 deletions
11
client.go
11
client.go
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
2
task.go
2
task.go
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
package pve
|
||||
|
||||
import (
|
||||
//"encoding/base64"
|
||||
//"net/url"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue