Extract providers (#1985)

* Remove cloud providers and reorg code

Signed-off-by: Carlisia <carlisia@vmware.com>

* Update dependencies

Signed-off-by: Carlisia <carlisia@vmware.com>

* Fix tests

Signed-off-by: Carlisia <carlisia@vmware.com>

* fix dependency issues

Signed-off-by: Carlisia <carlisia@vmware.com>

* Delete dup test

Signed-off-by: Carlisia <carlisia@vmware.com>

* Add back spaces to file

Signed-off-by: Carlisia <carlisia@vmware.com>

* Remove and update docs

Signed-off-by: Carlisia <carlisia@vmware.com>

* Make the plugins flag required

Signed-off-by: Carlisia <carlisia@vmware.com>

* Add changelog

Signed-off-by: Carlisia <carlisia@vmware.com>

* Make the plugins flag conditional

Signed-off-by: Carlisia <carlisia@vmware.com>
This commit is contained in:
KubeKween
2019-10-22 15:31:27 -07:00
committed by Adnan Abdulhussein
parent 69f993aebd
commit d26bf05b33
214 changed files with 441 additions and 250600 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ import (
"os"
"os/exec"
"github.com/hashicorp/go-hclog"
hclog "github.com/hashicorp/go-hclog"
hcplugin "github.com/hashicorp/go-plugin"
"github.com/sirupsen/logrus"
@@ -26,8 +26,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
cloudprovidermocks "github.com/vmware-tanzu/velero/pkg/cloudprovider/mocks"
"github.com/vmware-tanzu/velero/pkg/plugin/framework"
providermocks "github.com/vmware-tanzu/velero/pkg/plugin/velero/mocks"
)
func TestRestartableGetObjectStore(t *testing.T) {
@@ -49,7 +49,7 @@ func TestRestartableGetObjectStore(t *testing.T) {
},
{
name: "happy path",
plugin: new(cloudprovidermocks.ObjectStore),
plugin: new(providermocks.ObjectStore),
},
}
@@ -97,7 +97,7 @@ func TestRestartableObjectStoreReinitialize(t *testing.T) {
err := r.reinitialize(3)
assert.EqualError(t, err, "int is not a ObjectStore!")
objectStore := new(cloudprovidermocks.ObjectStore)
objectStore := new(providermocks.ObjectStore)
objectStore.Test(t)
defer objectStore.AssertExpectations(t)
@@ -129,7 +129,7 @@ func TestRestartableObjectStoreGetDelegate(t *testing.T) {
// Happy path
p.On("resetIfNeeded").Return(nil)
objectStore := new(cloudprovidermocks.ObjectStore)
objectStore := new(providermocks.ObjectStore)
objectStore.Test(t)
defer objectStore.AssertExpectations(t)
p.On("getByKindAndName", key).Return(objectStore, nil)
@@ -160,7 +160,7 @@ func TestRestartableObjectStoreInit(t *testing.T) {
assert.EqualError(t, err, "getByKindAndName error")
// Delegate returns error
objectStore := new(cloudprovidermocks.ObjectStore)
objectStore := new(providermocks.ObjectStore)
objectStore.Test(t)
defer objectStore.AssertExpectations(t)
p.On("getByKindAndName", key).Return(objectStore, nil)
@@ -194,7 +194,7 @@ func TestRestartableObjectStoreDelegatedFunctions(t *testing.T) {
}
},
func() mockable {
return new(cloudprovidermocks.ObjectStore)
return new(providermocks.ObjectStore)
},
restartableDelegateTest{
function: "PutObject",
@@ -25,8 +25,8 @@ import (
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"github.com/vmware-tanzu/velero/pkg/cloudprovider/mocks"
"github.com/vmware-tanzu/velero/pkg/plugin/framework"
providermocks "github.com/vmware-tanzu/velero/pkg/plugin/velero/mocks"
)
func TestRestartableGetVolumeSnapshotter(t *testing.T) {
@@ -48,7 +48,7 @@ func TestRestartableGetVolumeSnapshotter(t *testing.T) {
},
{
name: "happy path",
plugin: new(mocks.VolumeSnapshotter),
plugin: new(providermocks.VolumeSnapshotter),
},
}
@@ -96,7 +96,7 @@ func TestRestartableVolumeSnapshotterReinitialize(t *testing.T) {
err := r.reinitialize(3)
assert.EqualError(t, err, "int is not a VolumeSnapshotter!")
volumeSnapshotter := new(mocks.VolumeSnapshotter)
volumeSnapshotter := new(providermocks.VolumeSnapshotter)
volumeSnapshotter.Test(t)
defer volumeSnapshotter.AssertExpectations(t)
@@ -128,7 +128,7 @@ func TestRestartableVolumeSnapshotterGetDelegate(t *testing.T) {
// Happy path
p.On("resetIfNeeded").Return(nil)
volumeSnapshotter := new(mocks.VolumeSnapshotter)
volumeSnapshotter := new(providermocks.VolumeSnapshotter)
volumeSnapshotter.Test(t)
defer volumeSnapshotter.AssertExpectations(t)
p.On("getByKindAndName", key).Return(volumeSnapshotter, nil)
@@ -159,7 +159,7 @@ func TestRestartableVolumeSnapshotterInit(t *testing.T) {
assert.EqualError(t, err, "getByKindAndName error")
// Delegate returns error
volumeSnapshotter := new(mocks.VolumeSnapshotter)
volumeSnapshotter := new(providermocks.VolumeSnapshotter)
volumeSnapshotter.Test(t)
defer volumeSnapshotter.AssertExpectations(t)
p.On("getByKindAndName", key).Return(volumeSnapshotter, nil)
@@ -205,7 +205,7 @@ func TestRestartableVolumeSnapshotterDelegatedFunctions(t *testing.T) {
}
},
func() mockable {
return new(mocks.VolumeSnapshotter)
return new(providermocks.VolumeSnapshotter)
},
restartableDelegateTest{
function: "CreateVolumeFromSnapshot",
+1 -1
View File
@@ -17,7 +17,7 @@ limitations under the License.
package framework
import (
"github.com/hashicorp/go-plugin"
plugin "github.com/hashicorp/go-plugin"
"golang.org/x/net/context"
"google.golang.org/grpc"
+1 -1
View File
@@ -17,7 +17,7 @@ limitations under the License.
package framework
import (
"github.com/hashicorp/go-plugin"
plugin "github.com/hashicorp/go-plugin"
"golang.org/x/net/context"
"google.golang.org/grpc"
+1 -1
View File
@@ -19,7 +19,7 @@ package framework
import (
"testing"
"github.com/hashicorp/go-plugin"
plugin "github.com/hashicorp/go-plugin"
"github.com/stretchr/testify/assert"
)
+1 -1
View File
@@ -17,7 +17,7 @@ limitations under the License.
package framework
import (
"github.com/hashicorp/go-plugin"
plugin "github.com/hashicorp/go-plugin"
"golang.org/x/net/context"
"google.golang.org/grpc"
+1 -1
View File
@@ -17,7 +17,7 @@ limitations under the License.
package framework
import (
"github.com/hashicorp/go-plugin"
plugin "github.com/hashicorp/go-plugin"
"golang.org/x/net/context"
"google.golang.org/grpc"
+165
View File
@@ -0,0 +1,165 @@
// Code generated by mockery v1.0.0. DO NOT EDIT.
package mocks
import io "io"
import mock "github.com/stretchr/testify/mock"
import time "time"
// ObjectStore is an autogenerated mock type for the ObjectStore type
type ObjectStore struct {
mock.Mock
}
// CreateSignedURL provides a mock function with given fields: bucket, key, ttl
func (_m *ObjectStore) CreateSignedURL(bucket string, key string, ttl time.Duration) (string, error) {
ret := _m.Called(bucket, key, ttl)
var r0 string
if rf, ok := ret.Get(0).(func(string, string, time.Duration) string); ok {
r0 = rf(bucket, key, ttl)
} else {
r0 = ret.Get(0).(string)
}
var r1 error
if rf, ok := ret.Get(1).(func(string, string, time.Duration) error); ok {
r1 = rf(bucket, key, ttl)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// DeleteObject provides a mock function with given fields: bucket, key
func (_m *ObjectStore) DeleteObject(bucket string, key string) error {
ret := _m.Called(bucket, key)
var r0 error
if rf, ok := ret.Get(0).(func(string, string) error); ok {
r0 = rf(bucket, key)
} else {
r0 = ret.Error(0)
}
return r0
}
// GetObject provides a mock function with given fields: bucket, key
func (_m *ObjectStore) GetObject(bucket string, key string) (io.ReadCloser, error) {
ret := _m.Called(bucket, key)
var r0 io.ReadCloser
if rf, ok := ret.Get(0).(func(string, string) io.ReadCloser); ok {
r0 = rf(bucket, key)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(io.ReadCloser)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(bucket, key)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Init provides a mock function with given fields: config
func (_m *ObjectStore) Init(config map[string]string) error {
ret := _m.Called(config)
var r0 error
if rf, ok := ret.Get(0).(func(map[string]string) error); ok {
r0 = rf(config)
} else {
r0 = ret.Error(0)
}
return r0
}
// ListCommonPrefixes provides a mock function with given fields: bucket, prefix, delimiter
func (_m *ObjectStore) ListCommonPrefixes(bucket string, prefix string, delimiter string) ([]string, error) {
ret := _m.Called(bucket, prefix, delimiter)
var r0 []string
if rf, ok := ret.Get(0).(func(string, string, string) []string); ok {
r0 = rf(bucket, prefix, delimiter)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]string)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(string, string, string) error); ok {
r1 = rf(bucket, prefix, delimiter)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ListObjects provides a mock function with given fields: bucket, prefix
func (_m *ObjectStore) ListObjects(bucket string, prefix string) ([]string, error) {
ret := _m.Called(bucket, prefix)
var r0 []string
if rf, ok := ret.Get(0).(func(string, string) []string); ok {
r0 = rf(bucket, prefix)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]string)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(bucket, prefix)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ObjectExists provides a mock function with given fields: bucket, key
func (_m *ObjectStore) ObjectExists(bucket string, key string) (bool, error) {
ret := _m.Called(bucket, key)
var r0 bool
if rf, ok := ret.Get(0).(func(string, string) bool); ok {
r0 = rf(bucket, key)
} else {
r0 = ret.Get(0).(bool)
}
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(bucket, key)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// PutObject provides a mock function with given fields: bucket, key, body
func (_m *ObjectStore) PutObject(bucket string, key string, body io.Reader) error {
ret := _m.Called(bucket, key, body)
var r0 error
if rf, ok := ret.Get(0).(func(string, string, io.Reader) error); ok {
r0 = rf(bucket, key, body)
} else {
r0 = ret.Error(0)
}
return r0
}
@@ -0,0 +1,155 @@
// Code generated by mockery v1.0.0. DO NOT EDIT.
package mocks
import mock "github.com/stretchr/testify/mock"
import runtime "k8s.io/apimachinery/pkg/runtime"
// VolumeSnapshotter is an autogenerated mock type for the VolumeSnapshotter type
type VolumeSnapshotter struct {
mock.Mock
}
// CreateSnapshot provides a mock function with given fields: volumeID, volumeAZ, tags
func (_m *VolumeSnapshotter) CreateSnapshot(volumeID string, volumeAZ string, tags map[string]string) (string, error) {
ret := _m.Called(volumeID, volumeAZ, tags)
var r0 string
if rf, ok := ret.Get(0).(func(string, string, map[string]string) string); ok {
r0 = rf(volumeID, volumeAZ, tags)
} else {
r0 = ret.Get(0).(string)
}
var r1 error
if rf, ok := ret.Get(1).(func(string, string, map[string]string) error); ok {
r1 = rf(volumeID, volumeAZ, tags)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// CreateVolumeFromSnapshot provides a mock function with given fields: snapshotID, volumeType, volumeAZ, iops
func (_m *VolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID string, volumeType string, volumeAZ string, iops *int64) (string, error) {
ret := _m.Called(snapshotID, volumeType, volumeAZ, iops)
var r0 string
if rf, ok := ret.Get(0).(func(string, string, string, *int64) string); ok {
r0 = rf(snapshotID, volumeType, volumeAZ, iops)
} else {
r0 = ret.Get(0).(string)
}
var r1 error
if rf, ok := ret.Get(1).(func(string, string, string, *int64) error); ok {
r1 = rf(snapshotID, volumeType, volumeAZ, iops)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// DeleteSnapshot provides a mock function with given fields: snapshotID
func (_m *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
ret := _m.Called(snapshotID)
var r0 error
if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(snapshotID)
} else {
r0 = ret.Error(0)
}
return r0
}
// GetVolumeID provides a mock function with given fields: pv
func (_m *VolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error) {
ret := _m.Called(pv)
var r0 string
if rf, ok := ret.Get(0).(func(runtime.Unstructured) string); ok {
r0 = rf(pv)
} else {
r0 = ret.Get(0).(string)
}
var r1 error
if rf, ok := ret.Get(1).(func(runtime.Unstructured) error); ok {
r1 = rf(pv)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetVolumeInfo provides a mock function with given fields: volumeID, volumeAZ
func (_m *VolumeSnapshotter) GetVolumeInfo(volumeID string, volumeAZ string) (string, *int64, error) {
ret := _m.Called(volumeID, volumeAZ)
var r0 string
if rf, ok := ret.Get(0).(func(string, string) string); ok {
r0 = rf(volumeID, volumeAZ)
} else {
r0 = ret.Get(0).(string)
}
var r1 *int64
if rf, ok := ret.Get(1).(func(string, string) *int64); ok {
r1 = rf(volumeID, volumeAZ)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*int64)
}
}
var r2 error
if rf, ok := ret.Get(2).(func(string, string) error); ok {
r2 = rf(volumeID, volumeAZ)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// Init provides a mock function with given fields: config
func (_m *VolumeSnapshotter) Init(config map[string]string) error {
ret := _m.Called(config)
var r0 error
if rf, ok := ret.Get(0).(func(map[string]string) error); ok {
r0 = rf(config)
} else {
r0 = ret.Error(0)
}
return r0
}
// SetVolumeID provides a mock function with given fields: pv, volumeID
func (_m *VolumeSnapshotter) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
ret := _m.Called(pv, volumeID)
var r0 runtime.Unstructured
if rf, ok := ret.Get(0).(func(runtime.Unstructured, string) runtime.Unstructured); ok {
r0 = rf(pv, volumeID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(runtime.Unstructured)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(runtime.Unstructured, string) error); ok {
r1 = rf(pv, volumeID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}