1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Linter] [Imports] Standardize k8s.io/api/storage/v1 (#1058)

This commit is contained in:
Adam Janikowski 2022-07-15 07:56:00 +02:00 committed by GitHub
parent b24df22e6d
commit 1f93c9c367
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 16 deletions

View file

@ -40,6 +40,8 @@ linters-settings:
alias: apps
- pkg: k8s.io/api/batch/v1
alias: batch
- pkg: k8s.io/api/storage/v1
alias: storage
gci:
sections:
- standard

View file

@ -24,7 +24,7 @@ import (
"context"
core "k8s.io/api/core/v1"
v1 "k8s.io/api/storage/v1"
storage "k8s.io/api/storage/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha"
@ -40,9 +40,9 @@ var (
// If such a class already exists, the create is ignored.
func (l *LocalStorage) ensureStorageClass(apiObject *api.ArangoLocalStorage) error {
spec := apiObject.Spec.StorageClass
bindingMode := v1.VolumeBindingWaitForFirstConsumer
bindingMode := storage.VolumeBindingWaitForFirstConsumer
reclaimPolicy := core.PersistentVolumeReclaimRetain
sc := &v1.StorageClass{
sc := &storage.StorageClass{
ObjectMeta: meta.ObjectMeta{
Name: spec.Name,
},

View file

@ -25,7 +25,7 @@ import (
"strconv"
"time"
v1 "k8s.io/api/storage/v1"
storage "k8s.io/api/storage/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
@ -39,7 +39,7 @@ var (
// StorageClassIsDefault returns true if the given storage class is marked default,
// false otherwise.
func StorageClassIsDefault(sc *v1.StorageClass) bool {
func StorageClassIsDefault(sc *storage.StorageClass) bool {
if value, found := sc.GetObjectMeta().GetAnnotations()[annStorageClassIsDefault]; found {
if boolValue, err := strconv.ParseBool(value); err == nil && boolValue {
return true

View file

@ -26,7 +26,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/storage/v1"
storage "k8s.io/api/storage/v1"
er "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
@ -40,19 +40,19 @@ import (
func TestStorageClassIsDefault(t *testing.T) {
testCases := []struct {
Name string
StorageClass v1.StorageClass
StorageClass storage.StorageClass
IsDefault bool
}{
{
Name: "Storage class without annotations",
StorageClass: v1.StorageClass{
StorageClass: storage.StorageClass{
ObjectMeta: meta.ObjectMeta{},
},
IsDefault: false,
},
{
Name: "Storage class with empty annotations",
StorageClass: v1.StorageClass{
StorageClass: storage.StorageClass{
ObjectMeta: meta.ObjectMeta{
Annotations: map[string]string{},
},
@ -61,7 +61,7 @@ func TestStorageClassIsDefault(t *testing.T) {
},
{
Name: "Storage class without default",
StorageClass: v1.StorageClass{
StorageClass: storage.StorageClass{
ObjectMeta: meta.ObjectMeta{
Annotations: map[string]string{
annStorageClassIsDefault: "false",
@ -72,7 +72,7 @@ func TestStorageClassIsDefault(t *testing.T) {
},
{
Name: "Storage class with invalid value in annotation",
StorageClass: v1.StorageClass{
StorageClass: storage.StorageClass{
ObjectMeta: meta.ObjectMeta{
Annotations: map[string]string{
annStorageClassIsDefault: "foo",
@ -83,7 +83,7 @@ func TestStorageClassIsDefault(t *testing.T) {
},
{
Name: "Default storage class exits",
StorageClass: v1.StorageClass{
StorageClass: storage.StorageClass{
ObjectMeta: meta.ObjectMeta{
Annotations: map[string]string{
annStorageClassIsDefault: "true",
@ -120,7 +120,7 @@ func TestPatchStorageClassIsDefault(t *testing.T) {
{
Name: "Storage class does not exist",
StorageClassName: "invalid",
ExpectedErr: er.NewNotFound(v1.Resource(resourceName), "invalid"),
ExpectedErr: er.NewNotFound(storage.Resource(resourceName), "invalid"),
},
{
Name: "Can not get storage class from kubernetes",
@ -145,10 +145,10 @@ func TestPatchStorageClassIsDefault(t *testing.T) {
StorageClassName: "test",
Reactor: func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
return true, nil,
retry.Permanent(er.NewConflict(v1.Resource(resourceName), "test", nil))
retry.Permanent(er.NewConflict(storage.Resource(resourceName), "test", nil))
},
ReactorActionVerb: "update",
ExpectedErr: er.NewConflict(v1.Resource(resourceName), "test", nil),
ExpectedErr: er.NewConflict(storage.Resource(resourceName), "test", nil),
},
}
@ -160,7 +160,7 @@ func TestPatchStorageClassIsDefault(t *testing.T) {
clientSet := fake.NewSimpleClientset()
storageSet := clientSet.StorageV1()
_, err = storageSet.StorageClasses().Create(context.Background(), &v1.StorageClass{
_, err = storageSet.StorageClasses().Create(context.Background(), &storage.StorageClass{
TypeMeta: meta.TypeMeta{},
ObjectMeta: meta.ObjectMeta{
Name: "test",