Skip to content

Commit 1f93c9c

Browse files
authored
[Linter] [Imports] Standardize k8s.io/api/storage/v1 (#1058)
1 parent b24df22 commit 1f93c9c

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

.golangci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ linters-settings:
4040
alias: apps
4141
- pkg: k8s.io/api/batch/v1
4242
alias: batch
43+
- pkg: k8s.io/api/storage/v1
44+
alias: storage
4345
gci:
4446
sections:
4547
- standard

pkg/storage/storage_class.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"context"
2525

2626
core "k8s.io/api/core/v1"
27-
v1 "k8s.io/api/storage/v1"
27+
storage "k8s.io/api/storage/v1"
2828
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
2929

3030
api "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha"
@@ -40,9 +40,9 @@ var (
4040
// If such a class already exists, the create is ignored.
4141
func (l *LocalStorage) ensureStorageClass(apiObject *api.ArangoLocalStorage) error {
4242
spec := apiObject.Spec.StorageClass
43-
bindingMode := v1.VolumeBindingWaitForFirstConsumer
43+
bindingMode := storage.VolumeBindingWaitForFirstConsumer
4444
reclaimPolicy := core.PersistentVolumeReclaimRetain
45-
sc := &v1.StorageClass{
45+
sc := &storage.StorageClass{
4646
ObjectMeta: meta.ObjectMeta{
4747
Name: spec.Name,
4848
},

pkg/util/k8sutil/storageclass.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"strconv"
2626
"time"
2727

28-
v1 "k8s.io/api/storage/v1"
28+
storage "k8s.io/api/storage/v1"
2929
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
3131

@@ -39,7 +39,7 @@ var (
3939

4040
// StorageClassIsDefault returns true if the given storage class is marked default,
4141
// false otherwise.
42-
func StorageClassIsDefault(sc *v1.StorageClass) bool {
42+
func StorageClassIsDefault(sc *storage.StorageClass) bool {
4343
if value, found := sc.GetObjectMeta().GetAnnotations()[annStorageClassIsDefault]; found {
4444
if boolValue, err := strconv.ParseBool(value); err == nil && boolValue {
4545
return true

pkg/util/k8sutil/storageclass_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
"github.com/stretchr/testify/assert"
2828
"github.com/stretchr/testify/require"
29-
v1 "k8s.io/api/storage/v1"
29+
storage "k8s.io/api/storage/v1"
3030
er "k8s.io/apimachinery/pkg/api/errors"
3131
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"k8s.io/apimachinery/pkg/runtime"
@@ -40,19 +40,19 @@ import (
4040
func TestStorageClassIsDefault(t *testing.T) {
4141
testCases := []struct {
4242
Name string
43-
StorageClass v1.StorageClass
43+
StorageClass storage.StorageClass
4444
IsDefault bool
4545
}{
4646
{
4747
Name: "Storage class without annotations",
48-
StorageClass: v1.StorageClass{
48+
StorageClass: storage.StorageClass{
4949
ObjectMeta: meta.ObjectMeta{},
5050
},
5151
IsDefault: false,
5252
},
5353
{
5454
Name: "Storage class with empty annotations",
55-
StorageClass: v1.StorageClass{
55+
StorageClass: storage.StorageClass{
5656
ObjectMeta: meta.ObjectMeta{
5757
Annotations: map[string]string{},
5858
},
@@ -61,7 +61,7 @@ func TestStorageClassIsDefault(t *testing.T) {
6161
},
6262
{
6363
Name: "Storage class without default",
64-
StorageClass: v1.StorageClass{
64+
StorageClass: storage.StorageClass{
6565
ObjectMeta: meta.ObjectMeta{
6666
Annotations: map[string]string{
6767
annStorageClassIsDefault: "false",
@@ -72,7 +72,7 @@ func TestStorageClassIsDefault(t *testing.T) {
7272
},
7373
{
7474
Name: "Storage class with invalid value in annotation",
75-
StorageClass: v1.StorageClass{
75+
StorageClass: storage.StorageClass{
7676
ObjectMeta: meta.ObjectMeta{
7777
Annotations: map[string]string{
7878
annStorageClassIsDefault: "foo",
@@ -83,7 +83,7 @@ func TestStorageClassIsDefault(t *testing.T) {
8383
},
8484
{
8585
Name: "Default storage class exits",
86-
StorageClass: v1.StorageClass{
86+
StorageClass: storage.StorageClass{
8787
ObjectMeta: meta.ObjectMeta{
8888
Annotations: map[string]string{
8989
annStorageClassIsDefault: "true",
@@ -120,7 +120,7 @@ func TestPatchStorageClassIsDefault(t *testing.T) {
120120
{
121121
Name: "Storage class does not exist",
122122
StorageClassName: "invalid",
123-
ExpectedErr: er.NewNotFound(v1.Resource(resourceName), "invalid"),
123+
ExpectedErr: er.NewNotFound(storage.Resource(resourceName), "invalid"),
124124
},
125125
{
126126
Name: "Can not get storage class from kubernetes",
@@ -145,10 +145,10 @@ func TestPatchStorageClassIsDefault(t *testing.T) {
145145
StorageClassName: "test",
146146
Reactor: func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
147147
return true, nil,
148-
retry.Permanent(er.NewConflict(v1.Resource(resourceName), "test", nil))
148+
retry.Permanent(er.NewConflict(storage.Resource(resourceName), "test", nil))
149149
},
150150
ReactorActionVerb: "update",
151-
ExpectedErr: er.NewConflict(v1.Resource(resourceName), "test", nil),
151+
ExpectedErr: er.NewConflict(storage.Resource(resourceName), "test", nil),
152152
},
153153
}
154154

@@ -160,7 +160,7 @@ func TestPatchStorageClassIsDefault(t *testing.T) {
160160

161161
clientSet := fake.NewSimpleClientset()
162162
storageSet := clientSet.StorageV1()
163-
_, err = storageSet.StorageClasses().Create(context.Background(), &v1.StorageClass{
163+
_, err = storageSet.StorageClasses().Create(context.Background(), &storage.StorageClass{
164164
TypeMeta: meta.TypeMeta{},
165165
ObjectMeta: meta.ObjectMeta{
166166
Name: "test",

0 commit comments

Comments
 (0)