From 2906d39d94f664e08c52bd12480fdb42be45d098 Mon Sep 17 00:00:00 2001 From: Shubham Bajpai Date: Fri, 18 Dec 2020 21:12:52 +0530 Subject: [PATCH] refact(csi): use common lib-csi imports (#263) Signed-off-by: shubham --- go.mod | 9 +- go.sum | 2 + pkg/builder/bkpbuilder/build.go | 2 +- pkg/builder/bkpbuilder/kubernetes.go | 2 +- pkg/builder/restorebuilder/build.go | 2 +- pkg/builder/restorebuilder/kubernetes.go | 2 +- pkg/builder/snapbuilder/build.go | 2 +- pkg/builder/snapbuilder/kubernetes.go | 2 +- pkg/builder/volbuilder/build.go | 2 +- pkg/builder/volbuilder/kubernetes.go | 2 +- pkg/client/k8s/v1alpha1/clientset_test.go | 38 --- pkg/client/k8s/v1alpha1/config_test.go | 74 ----- pkg/client/k8s/v1alpha1/configmap_test.go | 48 --- pkg/client/k8s/v1alpha1/dynamic_test.go | 41 --- pkg/client/k8s/v1alpha1/resource_test.go | 31 -- pkg/common/kubernetes/client/client_test.go | 310 ------------------ pkg/driver/agent.go | 4 +- pkg/driver/controller.go | 6 +- pkg/usage/ping.go | 3 +- pkg/usage/usage.go | 2 +- pkg/usage/versionset.go | 4 +- pkg/zfs/mount.go | 2 +- pkg/zfs/zfs_util.go | 7 +- tests/container/container.go | 2 +- tests/deploy/deployment.go | 2 +- tests/deploy/kubernetes.go | 2 +- tests/k8svolume/build.go | 2 +- tests/pod/build.go | 2 +- tests/pod/kubernetes.go | 4 +- tests/pts/pts.go | 2 +- tests/pvc/build.go | 2 +- tests/pvc/buildlist.go | 2 +- tests/pvc/kubernetes.go | 4 +- tests/sc/build.go | 2 +- tests/sc/buildlist.go | 2 +- tests/sc/kubernetes.go | 4 +- vendor/github.com/openebs/lib-csi/LICENSE | 201 ++++++++++++ .../openebs/lib-csi/pkg}/btrfs/btrfs_util.go | 0 .../lib-csi/pkg/client/k8s}/clientset.go | 2 +- .../openebs/lib-csi/pkg/client/k8s}/config.go | 7 +- .../lib-csi/pkg/client/k8s}/configmap.go | 2 +- .../lib-csi/pkg/client/k8s}/dynamic.go | 2 +- .../openebs/lib-csi/pkg/client/k8s}/k8s.go | 2 +- .../lib-csi/pkg/client/k8s}/namespace.go | 2 +- .../openebs/lib-csi/pkg/client/k8s}/node.go | 2 +- .../lib-csi/pkg/client/k8s}/resource.go | 4 +- .../openebs/lib-csi/pkg}/common/env/env.go | 0 .../lib-csi/pkg}/common/errors/errors.go | 0 .../lib-csi/pkg}/common/errors/types.go | 0 .../lib-csi/pkg}/common/helpers/helpers.go | 0 .../pkg}/common/kubernetes/client/client.go | 4 +- .../openebs/lib-csi/pkg}/mount/mount_utils.go | 0 .../lib-csi/pkg}/scheduler/scheduler.go | 4 +- .../openebs/lib-csi/pkg}/xfs/xfs_util.go | 2 +- vendor/modules.txt | 19 +- 55 files changed, 271 insertions(+), 611 deletions(-) delete mode 100644 pkg/client/k8s/v1alpha1/clientset_test.go delete mode 100644 pkg/client/k8s/v1alpha1/config_test.go delete mode 100644 pkg/client/k8s/v1alpha1/configmap_test.go delete mode 100644 pkg/client/k8s/v1alpha1/dynamic_test.go delete mode 100644 pkg/client/k8s/v1alpha1/resource_test.go delete mode 100644 pkg/common/kubernetes/client/client_test.go create mode 100644 vendor/github.com/openebs/lib-csi/LICENSE rename {pkg => vendor/github.com/openebs/lib-csi/pkg}/btrfs/btrfs_util.go (100%) rename {pkg/client/k8s/v1alpha1 => vendor/github.com/openebs/lib-csi/pkg/client/k8s}/clientset.go (98%) rename {pkg/client/k8s/v1alpha1 => vendor/github.com/openebs/lib-csi/pkg/client/k8s}/config.go (97%) rename {pkg/client/k8s/v1alpha1 => vendor/github.com/openebs/lib-csi/pkg/client/k8s}/configmap.go (99%) rename {pkg/client/k8s/v1alpha1 => vendor/github.com/openebs/lib-csi/pkg/client/k8s}/dynamic.go (98%) rename {pkg/client/k8s/v1alpha1 => vendor/github.com/openebs/lib-csi/pkg/client/k8s}/k8s.go (98%) rename {pkg/client/k8s/v1alpha1 => vendor/github.com/openebs/lib-csi/pkg/client/k8s}/namespace.go (99%) rename {pkg/client/k8s/v1alpha1 => vendor/github.com/openebs/lib-csi/pkg/client/k8s}/node.go (99%) rename {pkg/client/k8s/v1alpha1 => vendor/github.com/openebs/lib-csi/pkg/client/k8s}/resource.go (99%) rename {pkg => vendor/github.com/openebs/lib-csi/pkg}/common/env/env.go (100%) rename {pkg => vendor/github.com/openebs/lib-csi/pkg}/common/errors/errors.go (100%) rename {pkg => vendor/github.com/openebs/lib-csi/pkg}/common/errors/types.go (100%) rename {pkg => vendor/github.com/openebs/lib-csi/pkg}/common/helpers/helpers.go (100%) rename {pkg => vendor/github.com/openebs/lib-csi/pkg}/common/kubernetes/client/client.go (99%) rename {pkg => vendor/github.com/openebs/lib-csi/pkg}/mount/mount_utils.go (100%) rename {pkg => vendor/github.com/openebs/lib-csi/pkg}/scheduler/scheduler.go (96%) rename {pkg => vendor/github.com/openebs/lib-csi/pkg}/xfs/xfs_util.go (98%) diff --git a/go.mod b/go.mod index e7aa3ce..cbd1d0d 100644 --- a/go.mod +++ b/go.mod @@ -8,25 +8,19 @@ require ( github.com/docker/go-units v0.4.0 github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect github.com/ghodss/yaml v1.0.0 - github.com/gogo/protobuf v1.3.0 // indirect github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect github.com/golang/protobuf v1.3.2 - github.com/googleapis/gnostic v0.3.1 // indirect github.com/hashicorp/golang-lru v0.5.3 // indirect - github.com/imdario/mergo v0.3.7 // indirect github.com/jpillora/go-ogle-analytics v0.0.0-20161213085824-14b04e0594ef - github.com/json-iterator/go v1.1.8 // indirect github.com/kubernetes-csi/csi-lib-utils v0.6.1 github.com/onsi/ginkgo v1.10.3 github.com/onsi/gomega v1.7.1 + github.com/openebs/lib-csi v0.0.0-20201218144414-a64be5d4731e github.com/pkg/errors v0.8.1 github.com/spf13/cobra v0.0.5 - github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/testify v1.5.1 - golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 // indirect golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 golang.org/x/sys v0.0.0-20190902133755-9109b7679e13 - google.golang.org/appengine v1.6.2 // indirect google.golang.org/grpc v1.23.1 k8s.io/api v0.15.12 k8s.io/apimachinery v0.15.12 @@ -36,7 +30,6 @@ require ( k8s.io/klog v1.0.0 k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a // indirect k8s.io/kubernetes v1.15.12 - k8s.io/utils v0.0.0-20191114184206-e782cd3c129f // indirect sigs.k8s.io/controller-runtime v0.2.0 ) diff --git a/go.sum b/go.sum index 9aeb275..7af2fb5 100644 --- a/go.sum +++ b/go.sum @@ -283,6 +283,8 @@ github.com/opencontainers/image-spec v0.0.0-20170604055404-372ad780f634/go.mod h github.com/opencontainers/runc v0.0.0-20181113202123-f000fe11ece1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runtime-spec v1.0.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/selinux v0.0.0-20170621221121-4a2974bf1ee9/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs= +github.com/openebs/lib-csi v0.0.0-20201218144414-a64be5d4731e h1:40mLG8RrhwHYSS3InWsWiYVcASRgGbLWrwJkP7TS0rA= +github.com/openebs/lib-csi v0.0.0-20201218144414-a64be5d4731e/go.mod h1:RqhCQqpcbFcAeNg54v9IOqLbY0/7S00WUa24ozC7cjI= github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= diff --git a/pkg/builder/bkpbuilder/build.go b/pkg/builder/bkpbuilder/build.go index 4751628..00d6611 100644 --- a/pkg/builder/bkpbuilder/build.go +++ b/pkg/builder/bkpbuilder/build.go @@ -17,8 +17,8 @@ limitations under the License. package bkpbuilder import ( + "github.com/openebs/lib-csi/pkg/common/errors" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - "github.com/openebs/zfs-localpv/pkg/common/errors" ) // Builder is the builder object for ZFSBackup diff --git a/pkg/builder/bkpbuilder/kubernetes.go b/pkg/builder/bkpbuilder/kubernetes.go index cc680ea..326bcde 100644 --- a/pkg/builder/bkpbuilder/kubernetes.go +++ b/pkg/builder/bkpbuilder/kubernetes.go @@ -17,8 +17,8 @@ package bkpbuilder import ( "encoding/json" + client "github.com/openebs/lib-csi/pkg/common/kubernetes/client" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - client "github.com/openebs/zfs-localpv/pkg/common/kubernetes/client" clientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/builder/restorebuilder/build.go b/pkg/builder/restorebuilder/build.go index d552d1a..c7e28bb 100644 --- a/pkg/builder/restorebuilder/build.go +++ b/pkg/builder/restorebuilder/build.go @@ -17,8 +17,8 @@ limitations under the License. package restorebuilder import ( + "github.com/openebs/lib-csi/pkg/common/errors" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - "github.com/openebs/zfs-localpv/pkg/common/errors" ) // Builder is the builder object for ZFSRestore diff --git a/pkg/builder/restorebuilder/kubernetes.go b/pkg/builder/restorebuilder/kubernetes.go index 3793878..7f2cfe2 100644 --- a/pkg/builder/restorebuilder/kubernetes.go +++ b/pkg/builder/restorebuilder/kubernetes.go @@ -17,8 +17,8 @@ package restorebuilder import ( "encoding/json" + client "github.com/openebs/lib-csi/pkg/common/kubernetes/client" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - client "github.com/openebs/zfs-localpv/pkg/common/kubernetes/client" clientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/builder/snapbuilder/build.go b/pkg/builder/snapbuilder/build.go index c19a275..e74198a 100644 --- a/pkg/builder/snapbuilder/build.go +++ b/pkg/builder/snapbuilder/build.go @@ -17,8 +17,8 @@ limitations under the License. package snapbuilder import ( + "github.com/openebs/lib-csi/pkg/common/errors" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - "github.com/openebs/zfs-localpv/pkg/common/errors" ) // Builder is the builder object for ZFSSnapshot diff --git a/pkg/builder/snapbuilder/kubernetes.go b/pkg/builder/snapbuilder/kubernetes.go index 8b9e2bd..f6c8356 100644 --- a/pkg/builder/snapbuilder/kubernetes.go +++ b/pkg/builder/snapbuilder/kubernetes.go @@ -17,8 +17,8 @@ package snapbuilder import ( "encoding/json" + client "github.com/openebs/lib-csi/pkg/common/kubernetes/client" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - client "github.com/openebs/zfs-localpv/pkg/common/kubernetes/client" clientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/builder/volbuilder/build.go b/pkg/builder/volbuilder/build.go index 9732887..dc3a47d 100644 --- a/pkg/builder/volbuilder/build.go +++ b/pkg/builder/volbuilder/build.go @@ -17,8 +17,8 @@ limitations under the License. package volbuilder import ( + "github.com/openebs/lib-csi/pkg/common/errors" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - "github.com/openebs/zfs-localpv/pkg/common/errors" ) // Builder is the builder object for ZFSVolume diff --git a/pkg/builder/volbuilder/kubernetes.go b/pkg/builder/volbuilder/kubernetes.go index f039f5c..cc9e9fd 100644 --- a/pkg/builder/volbuilder/kubernetes.go +++ b/pkg/builder/volbuilder/kubernetes.go @@ -17,8 +17,8 @@ package volbuilder import ( "encoding/json" + client "github.com/openebs/lib-csi/pkg/common/kubernetes/client" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - client "github.com/openebs/zfs-localpv/pkg/common/kubernetes/client" clientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/client/k8s/v1alpha1/clientset_test.go b/pkg/client/k8s/v1alpha1/clientset_test.go deleted file mode 100644 index 75182b5..0000000 --- a/pkg/client/k8s/v1alpha1/clientset_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2020 The OpenEBS Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "testing" -) - -func TestClientsetGet(t *testing.T) { - tests := map[string]struct { - iserr bool - }{ - "101": {true}, - } - - for name, mock := range tests { - t.Run(name, func(t *testing.T) { - _, err := Clientset().Get() - if !mock.iserr && err != nil { - t.Fatalf("Test '%s' failed: expected no error: actual '%s'", name, err) - } - }) - } -} diff --git a/pkg/client/k8s/v1alpha1/config_test.go b/pkg/client/k8s/v1alpha1/config_test.go deleted file mode 100644 index 8314642..0000000 --- a/pkg/client/k8s/v1alpha1/config_test.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -Copyright 2020 The OpenEBS Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "github.com/openebs/zfs-localpv/pkg/common/env" - "os" - "testing" -) - -// test if configFromENV implements ConfigGetter interface -var _ ConfigGetter = &configFromENV{} - -// test if configFromREST implements ConfigGetter interface -var _ ConfigGetter = &configFromREST{} - -// test if ConfigGetters implements ConfigGetter interface -var _ ConfigGetter = ConfigGetters{} - -func TestConfigFromENV(t *testing.T) { - tests := map[string]struct { - masterip string - kubeconfig string - iserr bool - }{ - "101": {"", "", true}, - "102": {"", "/etc/config/kubeconfig", true}, - "103": {"0.0.0.0", "", false}, - "104": {"0.0.0.0", "/etc/config/config", true}, - } - - // Sub tests is not used here as env key is set & unset to test. Since env - // is a global setting, the tests should run serially - for name, mock := range tests { - masterip := os.Getenv(string(env.KubeMaster)) - defer os.Setenv(string(env.KubeMaster), masterip) - - kubeconfig := os.Getenv(string(env.KubeConfig)) - defer os.Setenv(string(env.KubeConfig), kubeconfig) - - err := os.Setenv(string(env.KubeMaster), mock.masterip) - if err != nil { - t.Fatalf("Test '%s' failed: %s", name, err) - } - err = os.Setenv(string(env.KubeConfig), mock.kubeconfig) - if err != nil { - t.Fatalf("Test '%s' failed: %s", name, err) - } - - c := &configFromENV{} - config, err := c.Get() - - if !mock.iserr && config == nil { - t.Fatalf("Test '%s' failed: expected config: actual nil config", name) - } - if !mock.iserr && err != nil { - t.Fatalf("Test '%s' failed: expected no error: actual %s", name, err) - } - } -} diff --git a/pkg/client/k8s/v1alpha1/configmap_test.go b/pkg/client/k8s/v1alpha1/configmap_test.go deleted file mode 100644 index 06bf2e1..0000000 --- a/pkg/client/k8s/v1alpha1/configmap_test.go +++ /dev/null @@ -1,48 +0,0 @@ -/* -Copyright 2020 The OpenEBS Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "testing" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// test if configmap implements ConfigMapGetter interface -var _ ConfigMapGetter = &Configmap{} - -func TestConfigMapGet(t *testing.T) { - tests := map[string]struct { - namespace string - name string - options metav1.GetOptions - iserr bool - }{ - "101": {"", "", metav1.GetOptions{}, true}, - "102": {"default", "", metav1.GetOptions{}, true}, - "103": {"default", "myconf", metav1.GetOptions{}, true}, - } - - for name, mock := range tests { - t.Run(name, func(t *testing.T) { - _, err := ConfigMap(mock.namespace, mock.name).Get(mock.options) - if !mock.iserr && err != nil { - t.Fatalf("Test '%s' failed: expected no error: actual '%s'", name, err) - } - }) - } -} diff --git a/pkg/client/k8s/v1alpha1/dynamic_test.go b/pkg/client/k8s/v1alpha1/dynamic_test.go deleted file mode 100644 index 2438026..0000000 --- a/pkg/client/k8s/v1alpha1/dynamic_test.go +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright 2020 The OpenEBS Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "testing" -) - -// test if dynamic implements DynamicProvider interface -var _ DynamicProvider = &DynamicStruct{} - -func TestDynamicProvider(t *testing.T) { - tests := map[string]struct { - iserr bool - }{ - "101": {true}, - } - - for name, mock := range tests { - t.Run(name, func(t *testing.T) { - _, err := Dynamic().Provide() - if !mock.iserr && err != nil { - t.Fatalf("Test '%s' failed: expected no error: actual '%s'", name, err) - } - }) - } -} diff --git a/pkg/client/k8s/v1alpha1/resource_test.go b/pkg/client/k8s/v1alpha1/resource_test.go deleted file mode 100644 index cfc7b4d..0000000 --- a/pkg/client/k8s/v1alpha1/resource_test.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2020 The OpenEBS Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// TODO -// Move this file to pkg/k8sresource/v1alpha1 -package v1alpha1 - -// verify if resource struct is an implementation of ResourceGetter -var _ ResourceGetter = &ResourceStruct{} - -// verify if resource struct is an implementation of ResourceCreator -var _ ResourceCreator = &ResourceStruct{} - -// verify if resource struct is an implementation of ResourceUpdater -var _ ResourceUpdater = &ResourceStruct{} - -// verify if createOrUpdate struct is an implementation of ResourceApplier -var _ ResourceApplier = &ResourceCreateOrUpdater{} diff --git a/pkg/common/kubernetes/client/client_test.go b/pkg/common/kubernetes/client/client_test.go deleted file mode 100644 index bfcf35c..0000000 --- a/pkg/common/kubernetes/client/client_test.go +++ /dev/null @@ -1,310 +0,0 @@ -/* -Copyright 2019 The OpenEBS Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "testing" - - "github.com/pkg/errors" - "k8s.io/client-go/dynamic" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" -) - -func fakeGetClientsetOk(c *rest.Config) (*kubernetes.Clientset, error) { - return &kubernetes.Clientset{}, nil -} - -func fakeGetClientsetErr(c *rest.Config) (*kubernetes.Clientset, error) { - return nil, errors.New("fake error") -} - -func fakeInClusterConfigOk() (*rest.Config, error) { - return &rest.Config{}, nil -} - -func fakeInClusterConfigErr() (*rest.Config, error) { - return nil, errors.New("fake error") -} - -func fakeBuildConfigFromFlagsOk(kubemaster string, kubeconfig string) (*rest.Config, error) { - return &rest.Config{}, nil -} - -func fakeBuildConfigFromFlagsErr(kubemaster string, kubeconfig string) (*rest.Config, error) { - return nil, errors.New("fake error") -} - -func fakeGetKubeConfigPathOk(e string) string { - return "fake" -} - -func fakeGetKubeConfigPathNil(e string) string { - return "" -} - -func fakeGetKubeMasterIPOk(e string) string { - return "fake" -} - -func fakeGetKubeMasterIPNil(e string) string { - return "" -} - -func fakeGetDynamicClientSetOk(c *rest.Config) (dynamic.Interface, error) { - return dynamic.NewForConfig(c) -} - -func fakeGetDynamicClientSetNil(c *rest.Config) (dynamic.Interface, error) { - return nil, nil -} - -func fakeGetDynamicClientSetErr(c *rest.Config) (dynamic.Interface, error) { - return nil, errors.New("fake error") -} - -func TestNewInCluster(t *testing.T) { - c := New(InCluster()) - if !c.IsInCluster { - t.Fatalf("test failed: expected IsInCluster as 'true' actual '%t'", c.IsInCluster) - } -} - -func TestConfig(t *testing.T) { - tests := map[string]struct { - isInCluster bool - kubeConfigPath string - getInClusterConfig getInClusterConfigFunc - getKubeMasterIP getKubeMasterIPFunc - getKubeConfigPath getKubeConfigPathFunc - getConfigFromENV buildConfigFromFlagsFunc - isErr bool - }{ - "t1": {true, "", fakeInClusterConfigOk, nil, nil, nil, false}, - "t2": {true, "", fakeInClusterConfigErr, nil, nil, nil, true}, - "t3": {false, "", fakeInClusterConfigErr, fakeGetKubeMasterIPNil, fakeGetKubeConfigPathNil, nil, true}, - "t4": {false, "", fakeInClusterConfigOk, fakeGetKubeMasterIPNil, fakeGetKubeConfigPathNil, nil, false}, - "t5": {false, "fakeKubeConfigPath", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathNil, fakeBuildConfigFromFlagsOk, false}, - "t6": {false, "", nil, fakeGetKubeMasterIPNil, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsOk, false}, - "t7": {false, "", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsOk, false}, - "t8": {false, "fakeKubeConfigPath", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsErr, true}, - "t9": {false, "fakeKubeConfigpath", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsOk, false}, - } - for name, mock := range tests { - name, mock := name, mock // pin It - t.Run(name, func(t *testing.T) { - c := &Client{ - IsInCluster: mock.isInCluster, - KubeConfigPath: mock.kubeConfigPath, - getInClusterConfig: mock.getInClusterConfig, - getKubeMasterIP: mock.getKubeMasterIP, - getKubeConfigPath: mock.getKubeConfigPath, - buildConfigFromFlags: mock.getConfigFromENV, - } - _, err := c.Config() - if mock.isErr && err == nil { - t.Fatalf("test '%s' failed: expected no error actual '%s'", name, err) - } - }) - } -} - -func TestGetConfigFromENV(t *testing.T) { - tests := map[string]struct { - getKubeMasterIP getKubeMasterIPFunc - getKubeConfigPath getKubeConfigPathFunc - getConfigFromENV buildConfigFromFlagsFunc - isErr bool - }{ - "t1": {fakeGetKubeMasterIPNil, fakeGetKubeConfigPathNil, nil, true}, - "t2": {fakeGetKubeMasterIPNil, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsOk, false}, - "t3": {fakeGetKubeMasterIPOk, fakeGetKubeConfigPathNil, fakeBuildConfigFromFlagsOk, false}, - "t4": {fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsOk, false}, - "t5": {fakeGetKubeMasterIPNil, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsErr, true}, - "t6": {fakeGetKubeMasterIPOk, fakeGetKubeConfigPathNil, fakeBuildConfigFromFlagsErr, true}, - "t7": {fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsErr, true}, - } - for name, mock := range tests { - name, mock := name, mock // pin It - t.Run(name, func(t *testing.T) { - c := &Client{ - getKubeMasterIP: mock.getKubeMasterIP, - getKubeConfigPath: mock.getKubeConfigPath, - buildConfigFromFlags: mock.getConfigFromENV, - } - _, err := c.getConfigFromENV() - if mock.isErr && err == nil { - t.Fatalf("test '%s' failed: expected error actual no error", name) - } - if !mock.isErr && err != nil { - t.Fatalf("test '%s' failed: expected no error actual '%s'", name, err) - } - }) - } -} - -func TestGetConfigFromPathOrDirect(t *testing.T) { - tests := map[string]struct { - kubeConfigPath string - getConfigFromFlags buildConfigFromFlagsFunc - getInClusterConfig getInClusterConfigFunc - isErr bool - }{ - "T1": {"", fakeBuildConfigFromFlagsErr, fakeInClusterConfigOk, false}, - "T2": {"fake-path", fakeBuildConfigFromFlagsOk, fakeInClusterConfigErr, false}, - "T3": {"fake-path", fakeBuildConfigFromFlagsErr, fakeInClusterConfigOk, true}, - "T4": {"", fakeBuildConfigFromFlagsOk, fakeInClusterConfigErr, true}, - "T5": {"fake-path", fakeBuildConfigFromFlagsErr, fakeInClusterConfigErr, true}, - } - for name, mock := range tests { - name, mock := name, mock // pin It - t.Run(name, func(t *testing.T) { - c := &Client{ - KubeConfigPath: mock.kubeConfigPath, - buildConfigFromFlags: mock.getConfigFromFlags, - getInClusterConfig: mock.getInClusterConfig, - getKubeMasterIP: fakeGetKubeMasterIPNil, - getKubeConfigPath: fakeGetKubeConfigPathNil, - } - _, err := c.GetConfigForPathOrDirect() - if mock.isErr && err == nil { - t.Fatalf("test '%s' failed: expected error actual no error", name) - } - if !mock.isErr && err != nil { - t.Fatalf("test '%s' failed: expected no error actual '%s'", name, err) - } - }) - } -} - -func TestClientset(t *testing.T) { - tests := map[string]struct { - isInCluster bool - kubeConfigPath string - getInClusterConfig getInClusterConfigFunc - getKubeMasterIP getKubeMasterIPFunc - getKubeConfigPath getKubeConfigPathFunc - getConfigFromENV buildConfigFromFlagsFunc - getKubernetesClientset getKubernetesClientsetFunc - isErr bool - }{ - "t10": {true, "", fakeInClusterConfigOk, nil, nil, nil, fakeGetClientsetOk, false}, - "t11": {true, "", fakeInClusterConfigOk, nil, nil, nil, fakeGetClientsetErr, true}, - "t12": {true, "", fakeInClusterConfigErr, nil, nil, nil, fakeGetClientsetOk, true}, - - "t21": {false, "", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathNil, fakeBuildConfigFromFlagsOk, fakeGetClientsetOk, false}, - "t22": {false, "", nil, fakeGetKubeMasterIPNil, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsOk, fakeGetClientsetOk, false}, - "t23": {false, "", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsOk, fakeGetClientsetOk, false}, - "t24": {false, "fake-path", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsErr, fakeGetClientsetOk, true}, - "t25": {false, "", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsOk, fakeGetClientsetErr, true}, - "t26": {false, "fakePath", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsErr, fakeGetClientsetOk, true}, - - "t30": {false, "", fakeInClusterConfigOk, fakeGetKubeMasterIPNil, fakeGetKubeConfigPathNil, nil, fakeGetClientsetOk, false}, - "t31": {false, "", fakeInClusterConfigOk, fakeGetKubeMasterIPNil, fakeGetKubeConfigPathNil, nil, fakeGetClientsetErr, true}, - "t32": {false, "", fakeInClusterConfigErr, fakeGetKubeMasterIPNil, fakeGetKubeConfigPathNil, nil, nil, true}, - "t33": {false, "fakePath", nil, fakeGetKubeMasterIPOk, fakeGetKubeConfigPathOk, fakeBuildConfigFromFlagsOk, fakeGetClientsetOk, false}, - } - for name, mock := range tests { - name, mock := name, mock // pin It - t.Run(name, func(t *testing.T) { - c := &Client{ - IsInCluster: mock.isInCluster, - KubeConfigPath: mock.kubeConfigPath, - getInClusterConfig: mock.getInClusterConfig, - getKubeMasterIP: mock.getKubeMasterIP, - getKubeConfigPath: mock.getKubeConfigPath, - buildConfigFromFlags: mock.getConfigFromENV, - getKubernetesClientset: mock.getKubernetesClientset, - } - _, err := c.Clientset() - if mock.isErr && err == nil { - t.Fatalf("test '%s' failed: expected error actual no error", name) - } - if !mock.isErr && err != nil { - t.Fatalf("test '%s' failed: expected no error actual '%s'", name, err) - } - }) - } -} - -func TestDynamic(t *testing.T) { - tests := map[string]struct { - getKubeMasterIP getKubeMasterIPFunc - getInClusterConfig getInClusterConfigFunc - getKubernetesDynamicClientSet getKubernetesDynamicClientFunc - kubeConfigPath string - getConfigFromENV buildConfigFromFlagsFunc - getKubeConfigPath getKubeConfigPathFunc - isErr bool - }{ - "t1": {fakeGetKubeMasterIPNil, fakeInClusterConfigErr, fakeGetDynamicClientSetOk, "fake-path", fakeBuildConfigFromFlagsOk, fakeGetKubeConfigPathNil, false}, - "t2": {fakeGetKubeMasterIPNil, fakeInClusterConfigErr, fakeGetDynamicClientSetErr, "fake-path", fakeBuildConfigFromFlagsOk, fakeGetKubeConfigPathOk, true}, - "t3": {fakeGetKubeMasterIPNil, fakeInClusterConfigErr, fakeGetDynamicClientSetOk, "fake-path", fakeBuildConfigFromFlagsErr, fakeGetKubeConfigPathOk, true}, - "t4": {fakeGetKubeMasterIPOk, fakeInClusterConfigOk, fakeGetDynamicClientSetOk, "", fakeBuildConfigFromFlagsOk, fakeGetKubeConfigPathOk, false}, - "t5": {fakeGetKubeMasterIPOk, fakeInClusterConfigErr, fakeGetDynamicClientSetErr, "", fakeBuildConfigFromFlagsOk, fakeGetKubeConfigPathOk, true}, - "t6": {fakeGetKubeMasterIPNil, fakeInClusterConfigOk, fakeGetDynamicClientSetErr, "", fakeBuildConfigFromFlagsErr, fakeGetKubeConfigPathNil, true}, - "t7": {fakeGetKubeMasterIPNil, fakeInClusterConfigErr, fakeGetDynamicClientSetOk, "", fakeBuildConfigFromFlagsErr, fakeGetKubeConfigPathNil, true}, - "t8": {fakeGetKubeMasterIPNil, fakeInClusterConfigErr, fakeGetDynamicClientSetErr, "", fakeBuildConfigFromFlagsErr, fakeGetKubeConfigPathNil, true}, - } - for name, mock := range tests { - name, mock := name, mock // pin It - t.Run(name, func(t *testing.T) { - c := &Client{ - getKubeMasterIP: mock.getKubeMasterIP, - KubeConfigPath: mock.kubeConfigPath, - getInClusterConfig: mock.getInClusterConfig, - buildConfigFromFlags: mock.getConfigFromENV, - getKubeConfigPath: mock.getKubeConfigPath, - getKubernetesDynamicClient: mock.getKubernetesDynamicClientSet, - } - _, err := c.Dynamic() - if mock.isErr && err == nil { - t.Fatalf("test '%s' failed: expected error actual no error", name) - } - if !mock.isErr && err != nil { - t.Fatalf("test '%s' failed: expected no error but got '%v'", name, err) - } - }) - } -} - -func TestConfigForPath(t *testing.T) { - tests := map[string]struct { - kubeConfigPath string - getConfigFromPath buildConfigFromFlagsFunc - isErr bool - }{ - "T1": {"", fakeBuildConfigFromFlagsErr, true}, - "T2": {"fake-path", fakeBuildConfigFromFlagsOk, false}, - } - for name, mock := range tests { - name, mock := name, mock // pin It - t.Run(name, func(t *testing.T) { - c := &Client{ - KubeConfigPath: mock.kubeConfigPath, - buildConfigFromFlags: mock.getConfigFromPath, - } - _, err := c.ConfigForPath(mock.kubeConfigPath) - if mock.isErr && err == nil { - t.Fatalf("test '%s' failed: expected error actual no error", name) - } - if !mock.isErr && err != nil { - t.Fatalf("test '%s' failed: expected no error but got '%v'", name, err) - } - }) - } -} diff --git a/pkg/driver/agent.go b/pkg/driver/agent.go index 5209ebb..b064d3b 100644 --- a/pkg/driver/agent.go +++ b/pkg/driver/agent.go @@ -21,14 +21,14 @@ import ( "sync" "github.com/container-storage-interface/spec/lib/go/csi" + k8sapi "github.com/openebs/lib-csi/pkg/client/k8s" + "github.com/openebs/lib-csi/pkg/mount" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" "github.com/openebs/zfs-localpv/pkg/builder/volbuilder" - k8sapi "github.com/openebs/zfs-localpv/pkg/client/k8s/v1alpha1" "github.com/openebs/zfs-localpv/pkg/mgmt/backup" "github.com/openebs/zfs-localpv/pkg/mgmt/restore" "github.com/openebs/zfs-localpv/pkg/mgmt/snapshot" "github.com/openebs/zfs-localpv/pkg/mgmt/volume" - "github.com/openebs/zfs-localpv/pkg/mount" "github.com/openebs/zfs-localpv/pkg/zfs" "golang.org/x/net/context" "golang.org/x/sys/unix" diff --git a/pkg/driver/controller.go b/pkg/driver/controller.go index 992e0a4..4141f68 100644 --- a/pkg/driver/controller.go +++ b/pkg/driver/controller.go @@ -29,12 +29,12 @@ import ( k8serror "k8s.io/apimachinery/pkg/api/errors" "k8s.io/klog" + errors "github.com/openebs/lib-csi/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/helpers" + schd "github.com/openebs/lib-csi/pkg/scheduler" "github.com/openebs/zfs-localpv/pkg/builder/snapbuilder" "github.com/openebs/zfs-localpv/pkg/builder/volbuilder" - errors "github.com/openebs/zfs-localpv/pkg/common/errors" - "github.com/openebs/zfs-localpv/pkg/common/helpers" csipayload "github.com/openebs/zfs-localpv/pkg/response" - schd "github.com/openebs/zfs-localpv/pkg/scheduler" analytics "github.com/openebs/zfs-localpv/pkg/usage" zfs "github.com/openebs/zfs-localpv/pkg/zfs" ) diff --git a/pkg/usage/ping.go b/pkg/usage/ping.go index deefe40..ed73f99 100644 --- a/pkg/usage/ping.go +++ b/pkg/usage/ping.go @@ -18,8 +18,9 @@ package usage import ( "fmt" - "github.com/openebs/zfs-localpv/pkg/common/env" "time" + + "github.com/openebs/lib-csi/pkg/common/env" ) // OpenEBSPingPeriod ping interval of volume io analytics diff --git a/pkg/usage/usage.go b/pkg/usage/usage.go index fcf7de7..e36bf1c 100644 --- a/pkg/usage/usage.go +++ b/pkg/usage/usage.go @@ -17,7 +17,7 @@ limitations under the License. package usage import ( - k8sapi "github.com/openebs/zfs-localpv/pkg/client/k8s/v1alpha1" + k8sapi "github.com/openebs/lib-csi/pkg/client/k8s" ) // Usage struct represents all information about a usage metric sent to diff --git a/pkg/usage/versionset.go b/pkg/usage/versionset.go index 1925ecc..c296576 100644 --- a/pkg/usage/versionset.go +++ b/pkg/usage/versionset.go @@ -17,8 +17,8 @@ limitations under the License. package usage import ( - k8sapi "github.com/openebs/zfs-localpv/pkg/client/k8s/v1alpha1" - env "github.com/openebs/zfs-localpv/pkg/common/env" + k8sapi "github.com/openebs/lib-csi/pkg/client/k8s" + env "github.com/openebs/lib-csi/pkg/common/env" openebsversion "github.com/openebs/zfs-localpv/pkg/version" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog" diff --git a/pkg/zfs/mount.go b/pkg/zfs/mount.go index a98709d..b80c478 100644 --- a/pkg/zfs/mount.go +++ b/pkg/zfs/mount.go @@ -20,8 +20,8 @@ import ( "os" "os/exec" + mnt "github.com/openebs/lib-csi/pkg/mount" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - mnt "github.com/openebs/zfs-localpv/pkg/mount" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "k8s.io/klog" diff --git a/pkg/zfs/zfs_util.go b/pkg/zfs/zfs_util.go index 4be2474..d3c9abb 100644 --- a/pkg/zfs/zfs_util.go +++ b/pkg/zfs/zfs_util.go @@ -22,12 +22,13 @@ import ( "fmt" + "strings" + + "github.com/openebs/lib-csi/pkg/btrfs" + "github.com/openebs/lib-csi/pkg/xfs" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" - "github.com/openebs/zfs-localpv/pkg/btrfs" - "github.com/openebs/zfs-localpv/pkg/xfs" k8serrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/klog" - "strings" ) // zfs related constants diff --git a/tests/container/container.go b/tests/container/container.go index 106b282..6d7a365 100644 --- a/tests/container/container.go +++ b/tests/container/container.go @@ -17,7 +17,7 @@ limitations under the License. package container import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" corev1 "k8s.io/api/core/v1" ) diff --git a/tests/deploy/deployment.go b/tests/deploy/deployment.go index 518ae84..62b6cbf 100644 --- a/tests/deploy/deployment.go +++ b/tests/deploy/deployment.go @@ -14,7 +14,7 @@ limitations under the License. package deploy import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" templatespec "github.com/openebs/zfs-localpv/tests/pts" "github.com/openebs/zfs-localpv/tests/stringer" appsv1 "k8s.io/api/apps/v1" diff --git a/tests/deploy/kubernetes.go b/tests/deploy/kubernetes.go index ab712ed..d74a3ed 100644 --- a/tests/deploy/kubernetes.go +++ b/tests/deploy/kubernetes.go @@ -20,7 +20,7 @@ import ( "encoding/json" "strings" - client "github.com/openebs/zfs-localpv/pkg/common/kubernetes/client" + client "github.com/openebs/lib-csi/pkg/common/kubernetes/client" "github.com/pkg/errors" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/tests/k8svolume/build.go b/tests/k8svolume/build.go index 4cff6b5..45001a1 100644 --- a/tests/k8svolume/build.go +++ b/tests/k8svolume/build.go @@ -17,7 +17,7 @@ limitations under the License. package k8svolume import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" corev1 "k8s.io/api/core/v1" ) diff --git a/tests/pod/build.go b/tests/pod/build.go index 244105d..af1a218 100644 --- a/tests/pod/build.go +++ b/tests/pod/build.go @@ -17,7 +17,7 @@ limitations under the License. package pod import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" "github.com/openebs/zfs-localpv/tests/container" volume "github.com/openebs/zfs-localpv/tests/k8svolume" corev1 "k8s.io/api/core/v1" diff --git a/tests/pod/kubernetes.go b/tests/pod/kubernetes.go index f77b54e..9a12e97 100644 --- a/tests/pod/kubernetes.go +++ b/tests/pod/kubernetes.go @@ -18,8 +18,8 @@ import ( "bytes" "encoding/json" - "github.com/openebs/zfs-localpv/pkg/common/errors" - client "github.com/openebs/zfs-localpv/pkg/common/kubernetes/client" + "github.com/openebs/lib-csi/pkg/common/errors" + client "github.com/openebs/lib-csi/pkg/common/kubernetes/client" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientset "k8s.io/client-go/kubernetes" diff --git a/tests/pts/pts.go b/tests/pts/pts.go index 4821277..37dbe63 100644 --- a/tests/pts/pts.go +++ b/tests/pts/pts.go @@ -15,7 +15,7 @@ package pts import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" "github.com/openebs/zfs-localpv/tests/container" volume "github.com/openebs/zfs-localpv/tests/k8svolume" corev1 "k8s.io/api/core/v1" diff --git a/tests/pvc/build.go b/tests/pvc/build.go index 5e80702..d82f586 100644 --- a/tests/pvc/build.go +++ b/tests/pvc/build.go @@ -17,7 +17,7 @@ limitations under the License. package pvc import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" ) diff --git a/tests/pvc/buildlist.go b/tests/pvc/buildlist.go index 8ed6a12..4472e22 100644 --- a/tests/pvc/buildlist.go +++ b/tests/pvc/buildlist.go @@ -17,7 +17,7 @@ limitations under the License. package pvc import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" corev1 "k8s.io/api/core/v1" ) diff --git a/tests/pvc/kubernetes.go b/tests/pvc/kubernetes.go index df82416..adc6a7d 100644 --- a/tests/pvc/kubernetes.go +++ b/tests/pvc/kubernetes.go @@ -17,11 +17,11 @@ package pvc import ( "strings" - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - client "github.com/openebs/zfs-localpv/pkg/common/kubernetes/client" + client "github.com/openebs/lib-csi/pkg/common/kubernetes/client" "k8s.io/client-go/kubernetes" ) diff --git a/tests/sc/build.go b/tests/sc/build.go index cbd6dce..07386a9 100644 --- a/tests/sc/build.go +++ b/tests/sc/build.go @@ -17,7 +17,7 @@ limitations under the License. package sc import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" storagev1 "k8s.io/api/storage/v1" ) diff --git a/tests/sc/buildlist.go b/tests/sc/buildlist.go index 873d4f7..d277e4d 100644 --- a/tests/sc/buildlist.go +++ b/tests/sc/buildlist.go @@ -17,7 +17,7 @@ limitations under the License. package sc import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" + "github.com/openebs/lib-csi/pkg/common/errors" storagev1 "k8s.io/api/storage/v1" ) diff --git a/tests/sc/kubernetes.go b/tests/sc/kubernetes.go index efcffd2..0f08471 100644 --- a/tests/sc/kubernetes.go +++ b/tests/sc/kubernetes.go @@ -17,8 +17,8 @@ limitations under the License. package sc import ( - "github.com/openebs/zfs-localpv/pkg/common/errors" - client "github.com/openebs/zfs-localpv/pkg/common/kubernetes/client" + "github.com/openebs/lib-csi/pkg/common/errors" + client "github.com/openebs/lib-csi/pkg/common/kubernetes/client" storagev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" diff --git a/vendor/github.com/openebs/lib-csi/LICENSE b/vendor/github.com/openebs/lib-csi/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/vendor/github.com/openebs/lib-csi/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/pkg/btrfs/btrfs_util.go b/vendor/github.com/openebs/lib-csi/pkg/btrfs/btrfs_util.go similarity index 100% rename from pkg/btrfs/btrfs_util.go rename to vendor/github.com/openebs/lib-csi/pkg/btrfs/btrfs_util.go diff --git a/pkg/client/k8s/v1alpha1/clientset.go b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/clientset.go similarity index 98% rename from pkg/client/k8s/v1alpha1/clientset.go rename to vendor/github.com/openebs/lib-csi/pkg/client/k8s/clientset.go index 6f8f008..dfae5fc 100644 --- a/pkg/client/k8s/v1alpha1/clientset.go +++ b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/clientset.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package k8s import ( "github.com/pkg/errors" diff --git a/pkg/client/k8s/v1alpha1/config.go b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/config.go similarity index 97% rename from pkg/client/k8s/v1alpha1/config.go rename to vendor/github.com/openebs/lib-csi/pkg/client/k8s/config.go index 74419e0..326320e 100644 --- a/pkg/client/k8s/v1alpha1/config.go +++ b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/config.go @@ -14,14 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package k8s import ( - "github.com/openebs/zfs-localpv/pkg/common/env" + "strings" + + "github.com/openebs/lib-csi/pkg/common/env" "github.com/pkg/errors" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" - "strings" ) // ConfigGetter abstracts fetching of kubernetes client config diff --git a/pkg/client/k8s/v1alpha1/configmap.go b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/configmap.go similarity index 99% rename from pkg/client/k8s/v1alpha1/configmap.go rename to vendor/github.com/openebs/lib-csi/pkg/client/k8s/configmap.go index f105a0a..6e9a068 100644 --- a/pkg/client/k8s/v1alpha1/configmap.go +++ b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/configmap.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package k8s import ( "strings" diff --git a/pkg/client/k8s/v1alpha1/dynamic.go b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/dynamic.go similarity index 98% rename from pkg/client/k8s/v1alpha1/dynamic.go rename to vendor/github.com/openebs/lib-csi/pkg/client/k8s/dynamic.go index 94c37bb..556d382 100644 --- a/pkg/client/k8s/v1alpha1/dynamic.go +++ b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/dynamic.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package k8s import ( "github.com/pkg/errors" diff --git a/pkg/client/k8s/v1alpha1/k8s.go b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/k8s.go similarity index 98% rename from pkg/client/k8s/v1alpha1/k8s.go rename to vendor/github.com/openebs/lib-csi/pkg/client/k8s/k8s.go index 78f8cbc..3275bd8 100644 --- a/pkg/client/k8s/v1alpha1/k8s.go +++ b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/k8s.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package k8s import ( "github.com/pkg/errors" diff --git a/pkg/client/k8s/v1alpha1/namespace.go b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/namespace.go similarity index 99% rename from pkg/client/k8s/v1alpha1/namespace.go rename to vendor/github.com/openebs/lib-csi/pkg/client/k8s/namespace.go index fc860f3..692dec8 100644 --- a/pkg/client/k8s/v1alpha1/namespace.go +++ b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/namespace.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package k8s import ( "github.com/pkg/errors" diff --git a/pkg/client/k8s/v1alpha1/node.go b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/node.go similarity index 99% rename from pkg/client/k8s/v1alpha1/node.go rename to vendor/github.com/openebs/lib-csi/pkg/client/k8s/node.go index ed45e0c..89712bf 100644 --- a/pkg/client/k8s/v1alpha1/node.go +++ b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/node.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package k8s import ( "github.com/pkg/errors" diff --git a/pkg/client/k8s/v1alpha1/resource.go b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/resource.go similarity index 99% rename from pkg/client/k8s/v1alpha1/resource.go rename to vendor/github.com/openebs/lib-csi/pkg/client/k8s/resource.go index e798413..eb509ff 100644 --- a/pkg/client/k8s/v1alpha1/resource.go +++ b/vendor/github.com/openebs/lib-csi/pkg/client/k8s/resource.go @@ -17,7 +17,7 @@ limitations under the License. // TODO // Move this file to pkg/k8sresource/v1alpha1 -package v1alpha1 +package k8s import ( "fmt" @@ -237,7 +237,7 @@ func NewResourceCreateOrUpdater( // String implements Stringer interface func (r *ResourceCreateOrUpdater) String() string { if r.ResourceStruct == nil { - return fmt.Sprint("ResourceCreateOrUpdater") + return "ResourceCreateOrUpdater" } return fmt.Sprintf("ResourceCreateOrUpdater %s", r.ResourceStruct) } diff --git a/pkg/common/env/env.go b/vendor/github.com/openebs/lib-csi/pkg/common/env/env.go similarity index 100% rename from pkg/common/env/env.go rename to vendor/github.com/openebs/lib-csi/pkg/common/env/env.go diff --git a/pkg/common/errors/errors.go b/vendor/github.com/openebs/lib-csi/pkg/common/errors/errors.go similarity index 100% rename from pkg/common/errors/errors.go rename to vendor/github.com/openebs/lib-csi/pkg/common/errors/errors.go diff --git a/pkg/common/errors/types.go b/vendor/github.com/openebs/lib-csi/pkg/common/errors/types.go similarity index 100% rename from pkg/common/errors/types.go rename to vendor/github.com/openebs/lib-csi/pkg/common/errors/types.go diff --git a/pkg/common/helpers/helpers.go b/vendor/github.com/openebs/lib-csi/pkg/common/helpers/helpers.go similarity index 100% rename from pkg/common/helpers/helpers.go rename to vendor/github.com/openebs/lib-csi/pkg/common/helpers/helpers.go diff --git a/pkg/common/kubernetes/client/client.go b/vendor/github.com/openebs/lib-csi/pkg/common/kubernetes/client/client.go similarity index 99% rename from pkg/common/kubernetes/client/client.go rename to vendor/github.com/openebs/lib-csi/pkg/common/kubernetes/client/client.go index 8ae394c..ffe7f78 100644 --- a/pkg/common/kubernetes/client/client.go +++ b/vendor/github.com/openebs/lib-csi/pkg/common/kubernetes/client/client.go @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package client import ( "strings" "sync" - env "github.com/openebs/zfs-localpv/pkg/common/env" + env "github.com/openebs/lib-csi/pkg/common/env" "github.com/pkg/errors" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" diff --git a/pkg/mount/mount_utils.go b/vendor/github.com/openebs/lib-csi/pkg/mount/mount_utils.go similarity index 100% rename from pkg/mount/mount_utils.go rename to vendor/github.com/openebs/lib-csi/pkg/mount/mount_utils.go diff --git a/pkg/scheduler/scheduler.go b/vendor/github.com/openebs/lib-csi/pkg/scheduler/scheduler.go similarity index 96% rename from pkg/scheduler/scheduler.go rename to vendor/github.com/openebs/lib-csi/pkg/scheduler/scheduler.go index 9470a70..ab4dddb 100644 --- a/pkg/scheduler/scheduler.go +++ b/vendor/github.com/openebs/lib-csi/pkg/scheduler/scheduler.go @@ -20,7 +20,7 @@ import ( "math" "github.com/container-storage-interface/spec/lib/go/csi" - k8sapi "github.com/openebs/zfs-localpv/pkg/client/k8s/v1alpha1" + k8sapi "github.com/openebs/lib-csi/pkg/client/k8s" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog" ) @@ -44,7 +44,7 @@ func getNodeList(topo *csi.TopologyRequirement) ([]string, error) { break } } - if nodeFiltered == false { + if !nodeFiltered { nodelist = append(nodelist, node.Name) break } diff --git a/pkg/xfs/xfs_util.go b/vendor/github.com/openebs/lib-csi/pkg/xfs/xfs_util.go similarity index 98% rename from pkg/xfs/xfs_util.go rename to vendor/github.com/openebs/lib-csi/pkg/xfs/xfs_util.go index 11b02d2..3898682 100644 --- a/pkg/xfs/xfs_util.go +++ b/vendor/github.com/openebs/lib-csi/pkg/xfs/xfs_util.go @@ -17,7 +17,7 @@ limitations under the License. package xfs import ( - "github.com/openebs/zfs-localpv/pkg/mount" + "github.com/openebs/lib-csi/pkg/mount" "os" "os/exec" "path/filepath" diff --git a/vendor/modules.txt b/vendor/modules.txt index a4c4d92..d6c985f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -19,7 +19,6 @@ github.com/evanphx/json-patch ## explicit github.com/ghodss/yaml # github.com/gogo/protobuf v1.3.0 -## explicit github.com/gogo/protobuf/proto github.com/gogo/protobuf/sortkeys # github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 @@ -44,7 +43,6 @@ github.com/google/go-cmp/cmp/internal/value # github.com/google/gofuzz v1.0.0 github.com/google/gofuzz # github.com/googleapis/gnostic v0.3.1 -## explicit github.com/googleapis/gnostic/OpenAPIv2 github.com/googleapis/gnostic/compiler github.com/googleapis/gnostic/extensions @@ -59,7 +57,6 @@ github.com/hpcloud/tail/util github.com/hpcloud/tail/watch github.com/hpcloud/tail/winfile # github.com/imdario/mergo v0.3.7 -## explicit github.com/imdario/mergo # github.com/inconshreveable/mousetrap v1.0.0 github.com/inconshreveable/mousetrap @@ -67,7 +64,6 @@ github.com/inconshreveable/mousetrap ## explicit github.com/jpillora/go-ogle-analytics # github.com/json-iterator/go v1.1.8 -## explicit github.com/json-iterator/go # github.com/kubernetes-csi/csi-lib-utils v0.6.1 ## explicit @@ -110,6 +106,17 @@ github.com/onsi/gomega/matchers/support/goraph/edge github.com/onsi/gomega/matchers/support/goraph/node github.com/onsi/gomega/matchers/support/goraph/util github.com/onsi/gomega/types +# github.com/openebs/lib-csi v0.0.0-20201218144414-a64be5d4731e +## explicit +github.com/openebs/lib-csi/pkg/btrfs +github.com/openebs/lib-csi/pkg/client/k8s +github.com/openebs/lib-csi/pkg/common/env +github.com/openebs/lib-csi/pkg/common/errors +github.com/openebs/lib-csi/pkg/common/helpers +github.com/openebs/lib-csi/pkg/common/kubernetes/client +github.com/openebs/lib-csi/pkg/mount +github.com/openebs/lib-csi/pkg/scheduler +github.com/openebs/lib-csi/pkg/xfs # github.com/pkg/errors v0.8.1 ## explicit github.com/pkg/errors @@ -119,13 +126,11 @@ github.com/pmezard/go-difflib/difflib ## explicit github.com/spf13/cobra # github.com/spf13/pflag v1.0.5 -## explicit github.com/spf13/pflag # github.com/stretchr/testify v1.5.1 ## explicit github.com/stretchr/testify/assert # golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 -## explicit golang.org/x/crypto/ssh/terminal # golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 ## explicit @@ -212,7 +217,6 @@ gonum.org/v1/gonum/lapack/gonum gonum.org/v1/gonum/lapack/lapack64 gonum.org/v1/gonum/mat # google.golang.org/appengine v1.6.2 -## explicit google.golang.org/appengine google.golang.org/appengine/internal google.golang.org/appengine/internal/app_identity @@ -569,7 +573,6 @@ k8s.io/kube-openapi/pkg/util/proto ## explicit k8s.io/kubernetes/pkg/util/mount # k8s.io/utils v0.0.0-20191114184206-e782cd3c129f -## explicit k8s.io/utils/buffer k8s.io/utils/exec k8s.io/utils/integer