linter fixes

This commit is contained in:
ston1th 2021-11-07 13:30:22 +01:00
commit df5babf6c8
15 changed files with 49 additions and 55 deletions

View file

@ -27,11 +27,11 @@ func NewClient(c *apiclient.Client) (*Client, error) {
return &Client{c}, nil
}
func (c *Client) GetLoadBalancers(ctx context.Context) (lbs map[string]schema.LoadBalancer, err error) {
func (c *Client) GetLoadBalancers(ctx context.Context) (lbs map[string]*schema.LoadBalancer, err error) {
return c.GetLoadBalancersWithCluster(ctx, "")
}
func (c *Client) GetLoadBalancersWithCluster(ctx context.Context, cluster string) (lbs map[string]schema.LoadBalancer, err error) {
func (c *Client) GetLoadBalancersWithCluster(ctx context.Context, cluster string) (lbs map[string]*schema.LoadBalancer, err error) {
path := base
if cluster != "" {
path += "/" + cluster
@ -40,12 +40,12 @@ func (c *Client) GetLoadBalancersWithCluster(ctx context.Context, cluster string
if err != nil {
return
}
lbs = make(map[string]schema.LoadBalancer)
lbs = make(map[string]*schema.LoadBalancer)
_, err = c.c.Do(req, &lbs)
return
}
func (c *Client) GetLoadBalancer(ctx context.Context, cluster, name string) (lb schema.LoadBalancer, err error) {
func (c *Client) GetLoadBalancer(ctx context.Context, cluster, name string) (lb *schema.LoadBalancer, err error) {
path := fmt.Sprintf("%s/%s/%s", base, cluster, name)
req, err := c.c.NewRequest(ctx, "GET", path, nil)
if err != nil {
@ -55,7 +55,7 @@ func (c *Client) GetLoadBalancer(ctx context.Context, cluster, name string) (lb
return
}
func (c *Client) CreateLoadBalancer(ctx context.Context, cluster, name string, lb schema.LoadBalancer) (err error) {
func (c *Client) CreateLoadBalancer(ctx context.Context, cluster, name string, lb *schema.LoadBalancer) (err error) {
buf := new(bytes.Buffer)
path := fmt.Sprintf("%s/%s/%s", base, cluster, name)
err = lb.ValidateClient()

View file

@ -137,7 +137,7 @@ func (o Servers) RemoveByName(name string) Servers {
return append(o[:index], o[index+1:]...)
}
func (lb LoadBalancer) ValidateClient() error {
func (lb *LoadBalancer) ValidateClient() error {
for i, p := range lb.Ports {
if p.Port < 0 || p.Port > 65535 {
return fmt.Errorf("LoadBalancer.Ports[%d].Port is invalid (range 0-65535", i)
@ -157,7 +157,7 @@ func (lb LoadBalancer) ValidateClient() error {
return nil
}
func (lb LoadBalancer) ValidateServer() error {
func (lb *LoadBalancer) ValidateServer() error {
if lb.Name == "" {
return errors.New("LoadBalancer.Name can not be empty")
}
@ -183,6 +183,6 @@ func (lb LoadBalancer) ValidateServer() error {
return nil
}
func (lb LoadBalancer) JSON() ([]byte, error) {
func (lb *LoadBalancer) JSON() ([]byte, error) {
return json.Marshal(lb)
}

View file

@ -1,8 +1,6 @@
package server
import (
//"golang.org/x/crypto/bcrypt"
//"net/http"
"encoding/json"
"errors"
"net"