Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various linting warnings #164

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cluster_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
4 changes: 2 additions & 2 deletions nodes_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ 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)
}

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)
Expand Down
4 changes: 2 additions & 2 deletions tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1061,7 +1061,7 @@ type FirewallRule struct {
}

func (r *FirewallRule) IsEnable() bool {
return 1 == r.Enable
return r.Enable == 1
}

type FirewallNodeOption struct {
Expand Down
2 changes: 1 addition & 1 deletion virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion virtual_machine_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading