Skip to content

Commit 4422ccf

Browse files
authored
Lint Fix (#195)
* Lint Fix Signed-off-by: Aayush Subramaniam <[email protected]> * go mod and opensource updated Signed-off-by: Aayush Subramaniam <[email protected]> * makefile and go mod updated Signed-off-by: Aayush Subramaniam <[email protected]> * copyright updated Signed-off-by: Aayush Subramaniam <[email protected]> * updated shellcheck Signed-off-by: Aayush Subramaniam <[email protected]> --------- Signed-off-by: Aayush Subramaniam <[email protected]>
1 parent dca4b46 commit 4422ccf

File tree

9 files changed

+91
-54
lines changed

9 files changed

+91
-54
lines changed

block-storage-attacher/.golangci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,44 @@ linters-settings:
3232
goconst:
3333
min-len: 2
3434
min-occurrences: 2
35+
depguard:
36+
rules:
37+
main:
38+
list-mode: lax # allow unless explicitely denied
39+
files:
40+
- $all
41+
- "!$test"
42+
allow:
43+
- $gostd
44+
- github.ibm.com
45+
- k8s.io
46+
- github.com/BurntSushi/toml
47+
- github.com/rook/rook
48+
- github.com/red-hat-storage/ocs-operator
49+
- github.com/pkg/errors
50+
- github.com/IBM/secret-common-lib
51+
- github.com/IBM/secret-utils-lib
52+
- github.com/kelseyhightower/envconfig
53+
- github.com/gofrs/uuid
54+
- github.ibm.com/alchemy-containers/armada-slclient-lib/
55+
- github.com/IBM/ibmcloud-storage-utilities/block-storage-attacher/
56+
- github.com/IBM/
57+
- github.com/coreos/go-systemd/v22/dbus
58+
- k8s.io/api/core/v1
59+
- k8s.io/
60+
- k8s.io/client-go/kubernetes
61+
- k8s.io/client-go/rest
62+
- k8s.io/client-go/tools/clientcmd
63+
- k8s.io/apimachinery/pkg/apis/meta/v1
64+
- k8s.io/apimachinery/pkg/runtime
65+
- k8s.io/apimachinery/pkg/
66+
- k8s.io/apimachinery/pkg/apis/meta/v1
67+
- k8s.io/apimachinery/pkg/util/wait
68+
- k8s.io/apimachinery/pkg/watch
69+
- k8s.io/client-go/tools/cache
70+
- k8s.io/client-go/util/workqueue
71+
- io/ioutil
72+
3573
issues:
3674
include: [EXC01, EXC02]
3775
exclude-use-default: false

block-storage-attacher/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ BUILD_DATE="$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")"
1212
# Jenkins vars. Set to `unknown` if the variable is not yet defined
1313
BUILD_NUMBER?=unknown
1414
TRAVIS_BUILD_NUMBER ?= unknown
15-
OSS_FILES := Dockerfile go.mod
15+
OSS_FILES := Dockerfile.fips go.mod
1616

17-
LINT_VERSION="1.50.1"
17+
LINT_VERSION=1.55.2
1818
GOSEC_VERSION="v2.14.0"
1919
NANCY_VERSION := 1.0.42
2020
PROXY_IMAGE_URL=docker-na.artifactory.swg-devops.com/wcp-alchemy-containers-team-icr-docker-remote

block-storage-attacher/OPENSOURCE

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
docker://hub.docker.com/r/$BUILDER,latest
12
docker://hub.docker.com/r/scratch,latest
23
github.com/BurntSushi/toml,v0.3.1,direct
34
github.com/coreos/go-systemd/v22,v22.2.0,direct
45
github.com/gofrs/uuid,v4.2.0+incompatible,direct
5-
github.com/stretchr/testify,v1.8.4,direct
6-
go.uber.org/zap,v1.26.0,direct
6+
github.com/stretchr/testify,v1.7.0,direct
7+
go.uber.org/zap,v1.16.0,direct
78
golang.org/x/time,v0.0.0-20210220033141-f8bda1e9f3ba,direct
89
k8s.io/api,v0.19.2,direct
910
k8s.io/apimachinery,v0.19.2,direct
@@ -28,7 +29,7 @@ github.com/pkg/errors,v0.9.1,indirect
2829
github.com/pmezard/go-difflib,v1.0.0,indirect
2930
github.com/spf13/pflag,v1.0.5,indirect
3031
go.uber.org/atomic,v1.7.0,indirect
31-
go.uber.org/multierr,v1.10.0,indirect
32+
go.uber.org/multierr,v1.6.0,indirect
3233
golang.org/x/crypto,v0.0.0-20211202192323-5770296d904e,indirect
3334
golang.org/x/lint,v0.0.0-20201208152925-83fdc39ff7b5,indirect
3435
golang.org/x/net,v0.0.0-20220722155237-a158d28d115b,indirect
@@ -37,7 +38,7 @@ golang.org/x/sys,v0.0.0-20220722155257-8c9f86f7a55f,indirect
3738
golang.org/x/term,v0.0.0-20210927222741-03fcf44c2211,indirect
3839
golang.org/x/text,v0.3.8,indirect
3940
google.golang.org/appengine,v1.6.7,indirect
40-
google.golang.org/protobuf,v1.26.0,indirect
41+
google.golang.org/protobuf,v1.34.1,indirect
4142
gopkg.in/inf.v0,v0.9.1,indirect
4243
gopkg.in/yaml.v2,v2.4.0,indirect
4344
gopkg.in/yaml.v3,v3.0.0-20210107192922-496545a6307b,indirect
@@ -46,4 +47,4 @@ k8s.io/klog/v2,v2.8.0,indirect
4647
k8s.io/kube-openapi,v0.0.0-20200805222855-6aeccd4b50c6,indirect
4748
k8s.io/utils,v0.0.0-20210305010621-2afb4311ab10,indirect
4849
sigs.k8s.io/structured-merge-diff/v4,v4.1.0,indirect
49-
sigs.k8s.io/yaml,v1.2.0,indirect
50+
sigs.k8s.io/yaml,v1.2.0,indirect

block-storage-attacher/go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,6 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
502502
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
503503
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
504504
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
505-
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
506505
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
507506
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
508507
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=

block-storage-attacher/tests/e2e/common/common_util_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* IBM Confidential
33
* OCO Source Materials
44
* IBM Cloud Kubernetes Service, 5737-D43
5-
* (C) Copyright IBM Corp. 2022 All Rights Reserved.
5+
* (C) Copyright IBM Corp. 2022, 2024 All Rights Reserved.
66
* The source code for this program is not published or otherwise divested of
77
* its trade secrets, irrespective of what has been deposited with
88
* the U.S. Copyright Office.
@@ -18,19 +18,19 @@ package common
1818
import (
1919
"bytes"
2020
"fmt"
21-
"io/ioutil"
2221
"os"
2322
"path"
2423
"strings"
2524
"time"
2625

2726
"github.com/IBM/ibmcloud-storage-utilities/block-storage-attacher/tests/e2e/framework"
28-
"k8s.io/api/core/v1"
27+
"github.com/opencontainers/selinux/go-selinux"
2928
"k8s.io/api/storage/v1beta1"
3029
"k8s.io/apimachinery/pkg/api/resource"
3130
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3231
"k8s.io/apimachinery/pkg/runtime"
3332
utilyaml "k8s.io/apimachinery/pkg/util/yaml"
33+
v1 "k8s.io/client-go/1.5/pkg/api/v1"
3434
clientset "k8s.io/client-go/kubernetes"
3535
extensions "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
3636

@@ -313,7 +313,7 @@ func StartProvisionerDeployment(c clientset.Interface, ns string) (*v1.Service,
313313

314314
deployment := DeployFromManifest(path.Join(gopath, DeploymentGOFilePATH))
315315

316-
tmpDir, err := ioutil.TempDir("", ProvisionerPodName+"-deployment")
316+
tmpDir, err := os.TempDir("", ProvisionerPodName+"-deployment")
317317
Expect(err).NotTo(HaveOccurred())
318318
if selinux.GetEnabled() {
319319
//fcon, err := selinux.Getfilecon(tmpDir)
@@ -347,10 +347,10 @@ func StartProvisionerDeployment(c clientset.Interface, ns string) (*v1.Service,
347347
// SvcFromManifest reads a .json/yaml file and returns the json of the desired
348348
func SvcFromManifest(fileName string) *v1.Service {
349349
var service v1.Service
350-
data, err := ioutil.ReadFile(fileName) //#nosec G304 test file
350+
data, err := os.ReadFile(fileName) //#nosec G304 test file
351351
Expect(err).NotTo(HaveOccurred())
352352

353-
r := ioutil.NopCloser(bytes.NewReader(data))
353+
r := os.NopCloser(bytes.NewReader(data))
354354
decoder := utilyaml.NewDocumentDecoder(r)
355355
var chunk []byte
356356
for {
@@ -373,10 +373,10 @@ func SvcFromManifest(fileName string) *v1.Service {
373373
// deployFromManifest reads a .json/yaml file and returns the json of the desired
374374
func DeployFromManifest(fileName string) *extensions.Deployment {
375375
var deployment extensions.Deployment
376-
data, err := ioutil.ReadFile(fileName) //#nosec G304 test file
376+
data, err := os.ReadFile(fileName) //#nosec G304 test file
377377
Expect(err).NotTo(HaveOccurred())
378378

379-
r := ioutil.NopCloser(bytes.NewReader(data))
379+
r := os.NopCloser(bytes.NewReader(data))
380380
decoder := utilyaml.NewDocumentDecoder(r)
381381
var chunk []byte
382382
for {

block-storage-attacher/utils/crn/crn_test.go

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* IBM Confidential
33
* OCO Source Materials
44
* IBM Cloud Kubernetes Service, 5737-D43
5-
* (C) Copyright IBM Corp. 2022 All Rights Reserved.
5+
* (C) Copyright IBM Corp. 2022, 2024 All Rights Reserved.
66
* The source code for this program is not published or otherwise divested of
77
* its trade secrets, irrespective of what has been deposited with
88
* the U.S. Copyright Office.
@@ -12,7 +12,6 @@ package crn
1212

1313
import (
1414
"fmt"
15-
"io/ioutil"
1615
"os"
1716
"path/filepath"
1817
"testing"
@@ -68,7 +67,7 @@ func TestGetServiceCRNError(t *testing.T) {
6867
fullPath := testPathDirectory + "/" + CRNCnameProp
6968
cleanupConfigMapMount(fullPath)
7069
valueAsByteArray := []byte(CRNCnameProp)
71-
ioutil.WriteFile(fullPath, valueAsByteArray, 0000)
70+
os.WriteFile(fullPath, valueAsByteArray, 0000)
7271
testCM, err := GetServiceCRN()
7372
assert.Nil(t, err)
7473
assert.Equal(t, testCM, expectedCRNString)
@@ -103,7 +102,7 @@ func TestGetCRNValueFromConfigMapMount(t *testing.T) {
103102
// make sure this file isn't already hanging out
104103
os.Remove(testFile)
105104
cnameValue := []byte(testValue)
106-
err := ioutil.WriteFile(testFile, cnameValue, 0644)
105+
err := os.WriteFile(testFile, cnameValue, 0644)
107106
assert.Nil(t, err, "Error writing config map volume file.")
108107
expected := testValue
109108
defaultValue := "testDefault"
@@ -163,7 +162,7 @@ func TestGetServiceCRNStructCNameError(t *testing.T) {
163162
fullPath := testPathDirectory + "/" + CRNCnameProp
164163
cleanupConfigMapMount(fullPath)
165164
valueAsByteArray := []byte(CRNCnameProp)
166-
ioutil.WriteFile(fullPath, valueAsByteArray, 0000)
165+
os.WriteFile(fullPath, valueAsByteArray, 0000)
167166
_, err := GetServiceCRNStruct(testPathDirectory)
168167
assert.Error(t, err)
169168
cleanupConfigMapMount(fullPath)
@@ -173,14 +172,14 @@ func TestGetServiceCRNStructCVersionError(t *testing.T) {
173172
fullPath := testPathDirectory + "/" + CRNCnameProp
174173
cleanupConfigMapMount(fullPath)
175174
valueAsByteArray := []byte(CRNCnameProp)
176-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
175+
os.WriteFile(fullPath, valueAsByteArray, 0777)
177176
_, err := GetServiceCRNStruct(testPathDirectory)
178177
assert.Nil(t, err)
179178

180179
fullPath = testPathDirectory + "/" + CRNVersionProp
181180
cleanupConfigMapMount(fullPath)
182181
valueAsByteArray = []byte(CRNVersionProp)
183-
ioutil.WriteFile(fullPath, valueAsByteArray, 0000)
182+
os.WriteFile(fullPath, valueAsByteArray, 0000)
184183
_, err = GetServiceCRNStruct(testPathDirectory)
185184
assert.Error(t, err)
186185
cleanupConfigMapMount(fullPath)
@@ -190,21 +189,21 @@ func TestGetServiceCRNStructCTypeError(t *testing.T) {
190189
fullPath := testPathDirectory + "/" + CRNCnameProp
191190
cleanupConfigMapMount(fullPath)
192191
valueAsByteArray := []byte(CRNCnameProp)
193-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
192+
os.WriteFile(fullPath, valueAsByteArray, 0777)
194193
_, err := GetServiceCRNStruct(testPathDirectory)
195194
assert.Nil(t, err)
196195

197196
fullPath = testPathDirectory + "/" + CRNVersionProp
198197
cleanupConfigMapMount(fullPath)
199198
valueAsByteArray = []byte(CRNVersionProp)
200-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
199+
os.WriteFile(fullPath, valueAsByteArray, 0777)
201200
_, err = GetServiceCRNStruct(testPathDirectory)
202201
assert.Nil(t, err)
203202

204203
fullPath = testPathDirectory + "/" + CRNCtypeProp
205204
cleanupConfigMapMount(fullPath)
206205
valueAsByteArray = []byte(CRNCtypeProp)
207-
ioutil.WriteFile(fullPath, valueAsByteArray, 0000)
206+
os.WriteFile(fullPath, valueAsByteArray, 0000)
208207
_, err = GetServiceCRNStruct(testPathDirectory)
209208
assert.Error(t, err)
210209
cleanupConfigMapMount(fullPath)
@@ -215,7 +214,7 @@ func TestGetServiceCRNStructVersionError(t *testing.T) {
215214
fullPath := testPathDirectory + "/" + CRNCnameProp
216215
cleanupConfigMapMount(fullPath)
217216
valueAsByteArray := []byte(CRNCnameProp)
218-
ioutil.WriteFile(fullPath, valueAsByteArray, 0000)
217+
os.WriteFile(fullPath, valueAsByteArray, 0000)
219218
_, err := GetServiceCRNStruct(testPathDirectory)
220219
assert.Error(t, err)
221220
}
@@ -224,28 +223,28 @@ func TestGetServiceCRNStructCRegionError(t *testing.T) {
224223
fullPath := testPathDirectory + "/" + CRNCnameProp
225224
cleanupConfigMapMount(fullPath)
226225
valueAsByteArray := []byte(CRNCnameProp)
227-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
226+
os.WriteFile(fullPath, valueAsByteArray, 0777)
228227
_, err := GetServiceCRNStruct(testPathDirectory)
229228
assert.Nil(t, err)
230229

231230
fullPath = testPathDirectory + "/" + CRNVersionProp
232231
cleanupConfigMapMount(fullPath)
233232
valueAsByteArray = []byte(CRNVersionProp)
234-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
233+
os.WriteFile(fullPath, valueAsByteArray, 0777)
235234
_, err = GetServiceCRNStruct(testPathDirectory)
236235
assert.Nil(t, err)
237236

238237
fullPath = testPathDirectory + "/" + CRNCtypeProp
239238
cleanupConfigMapMount(fullPath)
240239
valueAsByteArray = []byte(CRNCtypeProp)
241-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
240+
os.WriteFile(fullPath, valueAsByteArray, 0777)
242241
_, err = GetServiceCRNStruct(testPathDirectory)
243242
assert.Nil(t, err)
244243

245244
fullPath = testPathDirectory + "/" + CRNRegionProp
246245
cleanupConfigMapMount(fullPath)
247246
valueAsByteArray = []byte(CRNRegionProp)
248-
ioutil.WriteFile(fullPath, valueAsByteArray, 0000)
247+
os.WriteFile(fullPath, valueAsByteArray, 0000)
249248
_, err = GetServiceCRNStruct(testPathDirectory)
250249
assert.Error(t, err)
251250
cleanupConfigMapMount(fullPath)
@@ -255,42 +254,42 @@ func TestGetServiceCRNStructCServiceNameError(t *testing.T) {
255254
fullPath := testPathDirectory + "/" + CRNCnameProp
256255
cleanupConfigMapMount(fullPath)
257256
valueAsByteArray := []byte(CRNCnameProp)
258-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
257+
os.WriteFile(fullPath, valueAsByteArray, 0777)
259258
_, err := GetServiceCRNStruct(testPathDirectory)
260259
assert.Nil(t, err)
261260

262261
fullPath = testPathDirectory + "/" + CRNVersionProp
263262
cleanupConfigMapMount(fullPath)
264263
valueAsByteArray = []byte(CRNVersionProp)
265-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
264+
os.WriteFile(fullPath, valueAsByteArray, 0777)
266265
_, err = GetServiceCRNStruct(testPathDirectory)
267266
assert.Nil(t, err)
268267

269268
fullPath = testPathDirectory + "/" + CRNCtypeProp
270269
cleanupConfigMapMount(fullPath)
271270
valueAsByteArray = []byte(CRNCtypeProp)
272-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
271+
os.WriteFile(fullPath, valueAsByteArray, 0777)
273272
_, err = GetServiceCRNStruct(testPathDirectory)
274273
assert.Nil(t, err)
275274

276275
fullPath = testPathDirectory + "/" + CRNRegionProp
277276
cleanupConfigMapMount(fullPath)
278277
valueAsByteArray = []byte(CRNRegionProp)
279-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
278+
os.WriteFile(fullPath, valueAsByteArray, 0777)
280279
_, err = GetServiceCRNStruct(testPathDirectory)
281280
assert.Nil(t, err)
282281

283282
fullPath = testPathDirectory + "/" + CRNClusterIDProp
284283
cleanupConfigMapMount(fullPath)
285284
valueAsByteArray = []byte(CRNClusterIDProp)
286-
ioutil.WriteFile(fullPath, valueAsByteArray, 0777)
285+
os.WriteFile(fullPath, valueAsByteArray, 0777)
287286
_, err = GetServiceCRNStruct(testPathDirectory)
288287
assert.Nil(t, err)
289288

290289
fullPath = testPathDirectory + "/" + CRNServiceNameProp
291290
cleanupConfigMapMount(fullPath)
292291
valueAsByteArray = []byte(CRNServiceNameProp)
293-
ioutil.WriteFile(fullPath, valueAsByteArray, 0000)
292+
os.WriteFile(fullPath, valueAsByteArray, 0000)
294293
_, err = GetServiceCRNStruct(testPathDirectory)
295294
assert.Error(t, err)
296295
cleanupConfigMapMount(fullPath)
@@ -299,7 +298,7 @@ func TestGetServiceCRNStructCServiceNameError(t *testing.T) {
299298
func prepConfigMapMount(fileName string, value string) error {
300299
cleanupConfigMapMount(fileName)
301300
valueAsByteArray := []byte(value)
302-
return ioutil.WriteFile(fileName, valueAsByteArray, 0644)
301+
return os.WriteFile(fileName, valueAsByteArray, 0644)
303302
}
304303

305304
func cleanupConfigMapMount(filename string) {

0 commit comments

Comments
 (0)