diff --git a/cluster_firewall.go b/cluster_firewall.go index 87ce838..073418b 100644 --- a/cluster_firewall.go +++ b/cluster_firewall.go @@ -27,7 +27,7 @@ func (cl *Cluster) FWGroup(ctx context.Context, name string) (group *FirewallSec } func (cl *Cluster) NewFWGroup(ctx context.Context, group *FirewallSecurityGroup) error { - return cl.client.Post(ctx, fmt.Sprintf("/cluster/firewall/groups"), group, &group) + return cl.client.Post(ctx, "/cluster/firewall/groups", group, &group) } func (g *FirewallSecurityGroup) GetRules(ctx context.Context) ([]*FirewallRule, error) { diff --git a/cluster_test.go b/cluster_test.go index 72abb80..891cd53 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -64,9 +64,11 @@ func TestCluster_Resources(t *testing.T) { // json unmarshaling tests rs, err := cluster.Resources(ctx) + assert.Nil(t, err) assert.Equal(t, 20, len(rs)) // type param test rs, err = cluster.Resources(ctx, "node") + assert.Nil(t, err) assert.Equal(t, 1, len(rs)) } diff --git a/nodes_network.go b/nodes_network.go index c50d98e..c2a3a3a 100644 --- a/nodes_network.go +++ b/nodes_network.go @@ -59,7 +59,7 @@ func (n *Node) NetworkReload(ctx context.Context) (*Task, error) { } func (nw *NodeNetwork) Update(ctx context.Context) error { - if "" == nw.Iface { + if nw.Iface == "" { return nil } return nw.client.Put(ctx, fmt.Sprintf("/nodes/%s/network/%s", nw.Node, nw.Iface), nw, nil) @@ -67,7 +67,7 @@ func (nw *NodeNetwork) Update(ctx context.Context) error { func (nw *NodeNetwork) Delete(ctx context.Context) (task *Task, err error) { var upid UPID - if "" == nw.Iface { + if nw.Iface == "" { return } err = nw.client.Delete(ctx, fmt.Sprintf("/nodes/%s/network/%s", nw.Node, nw.Iface), &upid) diff --git a/tasks.go b/tasks.go index 62416b8..52c6065 100644 --- a/tasks.go +++ b/tasks.go @@ -46,13 +46,13 @@ func (t *Task) Ping(ctx context.Context) error { t.client = tmp.client } - if "stopped" == t.Status { + if t.Status == "stopped" { t.IsCompleted = true } else { t.IsRunning = true } if t.IsCompleted { - if "OK" == t.ExitStatus { + if t.ExitStatus == "OK" { t.IsSuccessful = true } else { t.IsFailed = true diff --git a/types.go b/types.go index 0ca7265..7291054 100644 --- a/types.go +++ b/types.go @@ -952,7 +952,7 @@ func (b *IntOrBool) UnmarshalJSON(i []byte) error { } func (b *IntOrBool) MarshalJSON() ([]byte, error) { - if *b == true { + if *b { return []byte("1"), nil } return []byte("0"), nil @@ -1061,7 +1061,7 @@ type FirewallRule struct { } func (r *FirewallRule) IsEnable() bool { - return 1 == r.Enable + return r.Enable == 1 } type FirewallNodeOption struct { diff --git a/virtual_machine.go b/virtual_machine.go index 6a36416..bcedac9 100644 --- a/virtual_machine.go +++ b/virtual_machine.go @@ -477,7 +477,7 @@ func (v *VirtualMachine) AgentGetNetworkIFaces(ctx context.Context) (iFaces []*A } if result, ok := networks["result"]; ok { for _, iface := range result { - if "lo" == iface.Name { + if iface.Name == "lo" { continue } iFaces = append(iFaces, iface) diff --git a/virtual_machine_config.go b/virtual_machine_config.go index f42641d..312b1de 100644 --- a/virtual_machine_config.go +++ b/virtual_machine_config.go @@ -15,7 +15,7 @@ func (vmc *VirtualMachineConfig) mergeIndexedDevices(prefix string) map[string]s for i := 0; i < count; i++ { fn := t.Field(i).Name fv := v.Field(i).String() - if "" == fv { + if fv == "" { continue } if strings.HasPrefix(fn, prefix) {