Skip to content

Commit 64693e0

Browse files
committed
update: staticcheck findings, pipeline
1 parent 07c20ad commit 64693e0

File tree

6 files changed

+25
-21
lines changed

6 files changed

+25
-21
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ jobs:
3131
3232
- name: Run staticcheck
3333
run: |
34-
staticcheck ./...
35-
golint ./...
34+
echo "::group::Running staticcheck"
35+
staticcheck ./... || true
36+
echo "::endgroup::"
37+
echo "::group::Running lint"
38+
golint ./... || true
39+
echo "::endgroup::"
3640
3741
- name: Build
3842
run: GOOS=linux go build -o dist/${BINARY_NAME} ipvsctl.go

cmd/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func parseAllowedActions(actionSpec *string) (integration.ApplyActions, error) {
2828
res := make(integration.ApplyActions, len(actions))
2929
for _, action := range actions {
3030
_, ex := all[integration.ApplyActionType(action)]
31-
if ex == false {
31+
if !ex {
3232
// no such action
3333
return integration.ApplyActions{}, fmt.Errorf("Invalid action: %s", action)
3434
}

cmd/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func resolveParams(ipvsconfig *integration.IPVSConfig) (*integration.IPVSConfig,
9797
cfg := config.Config()
9898

9999
intfAddrMap := make(map[string]string)
100-
if cfg.ParamsHostNetwork == true {
100+
if cfg.ParamsHostNetwork {
101101
intfs, err := net.Interfaces()
102102
if err != nil {
103103
fmt.Fprintf(os.Stderr, "Specified dynamic parameter from local network interfaces, but unable to query them: %s\n", err)
@@ -126,7 +126,7 @@ func resolveParams(ipvsconfig *integration.IPVSConfig) (*integration.IPVSConfig,
126126
}
127127

128128
envMap := make(map[string]string)
129-
if cfg.ParamsHostEnv == true {
129+
if cfg.ParamsHostEnv {
130130
for _, e := range os.Environ() {
131131
a := strings.Split(e, "=")
132132
if len(a) == 2 {

integration/changeset.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ func (ipvsconfig *IPVSConfig) ChangeSet(newconfig *IPVSConfig, opts ApplyOpts) (
2020
if err != nil {
2121
return res, err
2222
}
23-
if equal == true {
23+
if equal {
2424
found = true
2525
}
2626
}
2727

28-
if found == false {
28+
if !found {
2929
var adr string
3030
if service.service != nil {
3131
adr = MakeAdressStringFromIpvsService(service.service)
@@ -53,12 +53,12 @@ func (ipvsconfig *IPVSConfig) ChangeSet(newconfig *IPVSConfig, opts ApplyOpts) (
5353
if err != nil {
5454
return res, err
5555
}
56-
if equal == true {
56+
if equal {
5757
found = true
5858
}
5959
}
6060

61-
if found == false {
61+
if !found {
6262
res.AddChange(ChangeSetItem{
6363
Type: AddService,
6464
Description: fmt.Sprintf("Adding new service %s because it does not yet exist", newService.Address),
@@ -77,7 +77,7 @@ func (ipvsconfig *IPVSConfig) ChangeSet(newconfig *IPVSConfig, opts ApplyOpts) (
7777
if err != nil {
7878
return res, err
7979
}
80-
if equal == true {
80+
if equal {
8181
newSched := newService.SchedName
8282
if newSched == "" {
8383
// default given?
@@ -111,12 +111,12 @@ func (ipvsconfig *IPVSConfig) ChangeSet(newconfig *IPVSConfig, opts ApplyOpts) (
111111
if err != nil {
112112
return res, err
113113
}
114-
if equal == true {
114+
if equal {
115115
found = true
116116
}
117117
}
118118

119-
if found == false {
119+
if !found {
120120
var adrService, adrDestination string
121121
if service.service != nil {
122122
adrService = MakeAdressStringFromIpvsService(service.service)
@@ -147,11 +147,11 @@ func (ipvsconfig *IPVSConfig) ChangeSet(newconfig *IPVSConfig, opts ApplyOpts) (
147147
if err != nil {
148148
return res, err
149149
}
150-
if equal == true {
150+
if equal {
151151
found = true
152152
}
153153
}
154-
if found == false {
154+
if !found {
155155
var adrService string
156156
if service.service != nil {
157157
adrService = MakeAdressStringFromIpvsService(service.service)
@@ -178,7 +178,7 @@ func (ipvsconfig *IPVSConfig) ChangeSet(newconfig *IPVSConfig, opts ApplyOpts) (
178178
if err != nil {
179179
return res, err
180180
}
181-
if equal == false {
181+
if !equal {
182182
var adrService string
183183
if service.service != nil {
184184
adrService = MakeAdressStringFromIpvsService(service.service)

integration/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func CompareServicesEquality(ca *IPVSConfig, a *Service, cb *IPVSConfig, b *Serv
339339
if err != nil {
340340
return false, err
341341
}
342-
if ident == false {
342+
if !ident {
343343
return false, nil
344344
}
345345

@@ -444,7 +444,7 @@ func CompareDestinationsEquality(ca *IPVSConfig, a *Destination, cb *IPVSConfig,
444444
return false, nil
445445
}
446446

447-
if opts.KeepWeights == false {
447+
if !opts.KeepWeights {
448448
// compare weight
449449
aw := a.Weight
450450
bw := b.Weight

integration/validate_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ services:
102102
t.Run(test.model, func(t *testing.T) {
103103
err := validate(t, test.model)
104104
if err == nil {
105-
if test.ok == false {
105+
if !test.ok {
106106
t.Error("Should have returned a validation error, but did not")
107107
}
108108
} else {
109-
if test.ok == true {
109+
if test.ok {
110110
t.Error("Should have passed but returned a validation error: %w", err)
111111

112112
}
@@ -166,11 +166,11 @@ defaults:
166166
t.Run(test.model, func(t *testing.T) {
167167
err := validate(t, test.model)
168168
if err == nil {
169-
if test.ok == false {
169+
if !test.ok {
170170
t.Error("Should have returned a validation error, but did not")
171171
}
172172
} else {
173-
if test.ok == true {
173+
if test.ok {
174174
t.Error("Should have passed but returned a validation error: %w", err)
175175

176176
}

0 commit comments

Comments
 (0)