Skip to content

Commit

Permalink
fix(golang-ci): update folder structure and fix golang-ci lint error (#…
Browse files Browse the repository at this point in the history
…24)

- Move pkg/generated/maya dir to pkg/maya follows standard pkg dir structure
- fix the client versioned issue which causing golang-ci lint
  to fail in first place
- fix unit test

Signed-off-by: prateekpandey14 <[email protected]>
  • Loading branch information
prateekpandey14 authored and vishnuitta committed Jul 18, 2019
1 parent 5ba71fd commit 970295a
Show file tree
Hide file tree
Showing 32 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion pkg/cstor/volume/v1alpha1/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package v1alpha1

import (
apismaya "github.com/openebs/csi/pkg/apis/openebs.io/maya/v1alpha1"
errors "github.com/openebs/csi/pkg/generated/maya/errors/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
)

// Builder is the builder object for CStorVolume
Expand Down
2 changes: 1 addition & 1 deletion pkg/cstor/volume/v1alpha1/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

apismaya "github.com/openebs/csi/pkg/apis/openebs.io/maya/v1alpha1"
clientset "github.com/openebs/csi/pkg/generated/clientset/maya/internalclientset"
client "github.com/openebs/csi/pkg/generated/maya/kubernetes/client/v1alpha1"
client "github.com/openebs/csi/pkg/maya/kubernetes/client/v1alpha1"

"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cvc/v1alpha1/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strconv"

apismaya "github.com/openebs/csi/pkg/apis/openebs.io/maya/v1alpha1"
errors "github.com/openebs/csi/pkg/generated/maya/errors/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
metav1 "k8s.io/api/core/v1"
resource "k8s.io/apimachinery/pkg/api/resource"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cvc/v1alpha1/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
apismaya "github.com/openebs/csi/pkg/apis/openebs.io/maya/v1alpha1"

clientset "github.com/openebs/csi/pkg/generated/clientset/maya/internalclientset"
client "github.com/openebs/csi/pkg/generated/maya/kubernetes/client/v1alpha1"
client "github.com/openebs/csi/pkg/maya/kubernetes/client/v1alpha1"

"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"reflect"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apis "github.com/openebs/csi/pkg/apis/openebs.io/maya/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestWithAPIList(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

apis "github.com/openebs/csi/pkg/apis/openebs.io/maya/v1alpha1"
clientset "github.com/openebs/csi/pkg/generated/clientset/maya/internalclientset"
client "github.com/openebs/csi/pkg/generated/maya/kubernetes/client/v1alpha1"
client "github.com/openebs/csi/pkg/maya/kubernetes/client/v1alpha1"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -134,7 +134,7 @@ func WithNamespace(namespace string) KubeclientBuildOption {

// WithNamespace sets the provided namespace
// against this Kubeclient instance
func(k *Kubeclient) WithNamespace(namespace string) *Kubeclient {
func (k *Kubeclient) WithNamespace(namespace string) *Kubeclient {
k.namespace = namespace
return k
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/pkg/errors"

apis "github.com/openebs/csi/pkg/apis/openebs.io/maya/v1alpha1"
"github.com/openebs/csi/pkg/generated/clientset/versioned"
clientset "github.com/openebs/csi/pkg/generated/clientset/maya/internalclientset"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -30,56 +30,56 @@ var (
_, _ = fakeGetNilErrClientSetForPath("")
)

func fakeGetClientsetOk() (clientset *versioned.Clientset, err error) {
return &versioned.Clientset{}, nil
func fakeGetClientsetOk() (cs *clientset.Clientset, err error) {
return &clientset.Clientset{}, nil
}

func fakeListOk(cli *versioned.Clientset, namespace string, opts metav1.ListOptions) (*apis.CStorVolumeList, error) {
func fakeListOk(cli *clientset.Clientset, namespace string, opts metav1.ListOptions) (*apis.CStorVolumeList, error) {
return &apis.CStorVolumeList{}, nil
}

func fakeGetOk(cli *versioned.Clientset, name, namespace string, opts metav1.GetOptions) (*apis.CStorVolume, error) {
func fakeGetOk(cli *clientset.Clientset, name, namespace string, opts metav1.GetOptions) (*apis.CStorVolume, error) {
return &apis.CStorVolume{}, nil
}

func fakeDeleteOk(cli *versioned.Clientset, name, namespace string, opts *metav1.DeleteOptions) error {
func fakeDeleteOk(cli *clientset.Clientset, name, namespace string, opts *metav1.DeleteOptions) error {
return nil
}

func fakeListErr(cli *versioned.Clientset, namespace string, opts metav1.ListOptions) (*apis.CStorVolumeList, error) {
func fakeListErr(cli *clientset.Clientset, namespace string, opts metav1.ListOptions) (*apis.CStorVolumeList, error) {
return &apis.CStorVolumeList{}, errors.New("some error")
}

func fakeGetErr(cli *versioned.Clientset, name, namespace string, opts metav1.GetOptions) (*apis.CStorVolume, error) {
func fakeGetErr(cli *clientset.Clientset, name, namespace string, opts metav1.GetOptions) (*apis.CStorVolume, error) {
return &apis.CStorVolume{}, errors.New("some error")
}

func fakeDeleteErr(cli *versioned.Clientset, name, namespace string, opts *metav1.DeleteOptions) error {
func fakeDeleteErr(cli *clientset.Clientset, name, namespace string, opts *metav1.DeleteOptions) error {
return errors.New("some error")

}

func fakeSetClientsetOk(k *Kubeclient) {
k.clientset = &versioned.Clientset{}
k.clientset = &clientset.Clientset{}
}

func fakeSetClientsetNil(k *Kubeclient) {
k.clientset = nil
}

func fakeGetNilErrClientSet() (clientset *versioned.Clientset, err error) {
func fakeGetNilErrClientSet() (clientset *clientset.Clientset, err error) {
return nil, nil
}

func fakeGetNilErrClientSetForPath(path string) (clientset *versioned.Clientset, err error) {
func fakeGetNilErrClientSetForPath(path string) (clientset *clientset.Clientset, err error) {
return nil, nil
}

func fakeGetErrClientSetForPath(path string) (clientset *versioned.Clientset, err error) {
func fakeGetErrClientSetForPath(path string) (clientset *clientset.Clientset, err error) {
return nil, errors.New("Some error")
}

func fakeGetErrClientSet() (clientset *versioned.Clientset, err error) {
func fakeGetErrClientSet() (clientset *clientset.Clientset, err error) {
return nil, errors.New("Some error")
}

Expand Down Expand Up @@ -121,11 +121,11 @@ func TestWithDefaults(t *testing.T) {

func TestKubernetesWithKubeClient(t *testing.T) {
tests := map[string]struct {
Clientset *versioned.Clientset
Clientset *clientset.Clientset
expectKubeClientEmpty bool
}{
"Clientset is empty": {nil, true},
"Clientset is not empty": {&versioned.Clientset{}, false},
"Clientset is not empty": {&clientset.Clientset{}, false},
}

for name, mock := range tests {
Expand Down Expand Up @@ -172,14 +172,14 @@ func TestKubernetesKubeClient(t *testing.T) {
}
}

func TesKubernetestGetClientOrCached(t *testing.T) {
func TestKubernetestGetClientOrCached(t *testing.T) {
tests := map[string]struct {
expectErr bool
KubeClient *Kubeclient
}{
// Positive tests
"Positive 1": {false, &Kubeclient{nil, "", "", fakeGetNilErrClientSet, fakeGetNilErrClientSetForPath, fakeGetOk, fakeListOk, fakeDeleteOk}},
"Positive 2": {false, &Kubeclient{&versioned.Clientset{}, "", "", fakeGetNilErrClientSet, fakeGetNilErrClientSetForPath, fakeGetOk, fakeListOk, fakeDeleteOk}},
"Positive 2": {false, &Kubeclient{&clientset.Clientset{}, "", "", nil, fakeGetNilErrClientSetForPath, fakeGetOk, fakeListOk, fakeDeleteOk}},
// Negative tests
"Negative 1": {true, &Kubeclient{nil, "", "", fakeGetErrClientSet, fakeGetErrClientSetForPath, fakeGetOk, fakeListOk, fakeDeleteOk}},
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import (
"strings"

env "github.com/openebs/csi/pkg/generated/maya/env/v1alpha1"
env "github.com/openebs/csi/pkg/maya/env/v1alpha1"
"github.com/pkg/errors"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import (
"testing"

env "github.com/openebs/csi/pkg/generated/env/v1alpha1"
env "github.com/openebs/csi/pkg/maya/env/v1alpha1"
"github.com/pkg/errors"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package v1alpha1

import (
client "github.com/openebs/csi/pkg/generated/maya/kubernetes/client/v1alpha1"
client "github.com/openebs/csi/pkg/maya/kubernetes/client/v1alpha1"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package v1alpha1
import (
"testing"

errors "github.com/openebs/csi/pkg/generated/maya/errors/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package v1alpha1

import (
errors "github.com/openebs/csi/pkg/generated/maya/errors/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package v1alpha1

import (
errors "github.com/openebs/csi/pkg/generated/maya/errors/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
corev1 "k8s.io/api/core/v1"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ package v1alpha1
import (
"strings"

errors "github.com/openebs/csi/pkg/generated/maya/errors/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
client "github.com/openebs/csi/pkg/maya/kubernetes/client/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
client "github.com/openebs/csi/pkg/generated/maya/kubernetes/client/v1alpha1"
"k8s.io/client-go/kubernetes"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package v1alpha1
import (
"testing"

errors "github.com/openebs/csi/pkg/generated/errors/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -465,7 +465,7 @@ func TestKubernetesPVCreate(t *testing.T) {
getClientSetForPath: fakeGetClientSetForPathErr,
kubeConfigPath: "fake-path",
create: fakeCreateFnOk,
pv: nil,
pv: &v1.PersistentVolume{ObjectMeta: metav1.ObjectMeta{Name: "PV-3"}},
expectErr: true,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import (
"encoding/json"

client "github.com/openebs/csi/pkg/generated/maya/kubernetes/client/v1alpha1"
client "github.com/openebs/csi/pkg/maya/kubernetes/client/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down
2 changes: 1 addition & 1 deletion pkg/service/v1alpha1/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/container-storage-interface/spec/lib/go/csi"
apismaya "github.com/openebs/csi/pkg/apis/openebs.io/maya/v1alpha1"
errors "github.com/openebs/csi/pkg/generated/maya/errors/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
csipayload "github.com/openebs/csi/pkg/payload/v1alpha1"
utils "github.com/openebs/csi/pkg/utils/v1alpha1"
"golang.org/x/net/context"
Expand Down
10 changes: 5 additions & 5 deletions pkg/utils/v1alpha1/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ package utils

import (
apis "github.com/openebs/csi/pkg/apis/openebs.io/core/v1alpha1"
csv "github.com/openebs/csi/pkg/generated/maya/cstorvolume/v1alpha1"
errors "github.com/openebs/csi/pkg/generated/maya/errors/v1alpha1"
node "github.com/openebs/csi/pkg/generated/maya/kubernetes/node/v1alpha1"
pv "github.com/openebs/csi/pkg/generated/maya/kubernetes/persistentvolume/v1alpha1"
csv "github.com/openebs/csi/pkg/maya/cstorvolume/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
node "github.com/openebs/csi/pkg/maya/kubernetes/node/v1alpha1"
pv "github.com/openebs/csi/pkg/maya/kubernetes/persistentvolume/v1alpha1"
csivolume "github.com/openebs/csi/pkg/volume/v1alpha1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// getNodeDetails fetches the nodeInfo for the current node
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/v1alpha1/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package v1alpha1

import (
apis "github.com/openebs/csi/pkg/apis/openebs.io/core/v1alpha1"
errors "github.com/openebs/csi/pkg/generated/maya/errors/v1alpha1"
errors "github.com/openebs/csi/pkg/maya/errors/v1alpha1"
)

// Builder is the builder object for CSIVolume
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/v1alpha1/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

apis "github.com/openebs/csi/pkg/apis/openebs.io/core/v1alpha1"
clientset "github.com/openebs/csi/pkg/generated/clientset/core/internalclientset"
client "github.com/openebs/csi/pkg/generated/maya/kubernetes/client/v1alpha1"
client "github.com/openebs/csi/pkg/maya/kubernetes/client/v1alpha1"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down

0 comments on commit 970295a

Please sign in to comment.