Skip to content

Commit

Permalink
Merge pull request #545 from akutz/feature/rm-client-driver
Browse files Browse the repository at this point in the history
Remove client driver
  • Loading branch information
akutz authored May 5, 2017
2 parents 05498e7 + f50ec76 commit 7d0eb86
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 464 deletions.
47 changes: 0 additions & 47 deletions api/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ var (
storExecsCtors = map[string]types.NewStorageExecutor{}
storExecsCtorsRWL = &sync.RWMutex{}

clientDriverCtors = map[string]types.NewClientDriver{}
clientDriverCtorsRWL = &sync.RWMutex{}

storDriverCtors = map[string]types.NewStorageDriver{}
storDriverCtorsRWL = &sync.RWMutex{}

Expand Down Expand Up @@ -61,14 +58,6 @@ func RegisterStorageExecutor(name string, ctor types.NewStorageExecutor) {
storExecsCtors[strings.ToLower(name)] = ctor
}

// RegisterClientDriver registers a ClientDriver.
func RegisterClientDriver(
name string, ctor types.NewClientDriver) {
clientDriverCtorsRWL.Lock()
defer clientDriverCtorsRWL.Unlock()
clientDriverCtors[strings.ToLower(name)] = ctor
}

// RegisterStorageDriver registers a StorageDriver.
func RegisterStorageDriver(
name string, ctor types.NewStorageDriver) {
Expand Down Expand Up @@ -111,27 +100,6 @@ func NewStorageExecutor(name string) (types.StorageExecutor, error) {
return ctor(), nil
}

// NewClientDriver returns a new instance of the driver specified by
// the driver name.
func NewClientDriver(
name string) (types.ClientDriver, error) {

var ok bool
var ctor types.NewClientDriver

func() {
clientDriverCtorsRWL.RLock()
defer clientDriverCtorsRWL.RUnlock()
ctor, ok = clientDriverCtors[strings.ToLower(name)]
}()

if !ok {
return nil, goof.WithField("driver", name, "invalid driver name")
}

return ctor(), nil
}

// NewStorageDriver returns a new instance of the driver specified by the
// driver name.
func NewStorageDriver(name string) (types.StorageDriver, error) {
Expand Down Expand Up @@ -228,21 +196,6 @@ func StorageExecutors() <-chan types.StorageExecutor {
return c
}

// ClientDrivers returns a channel on which new instances of all
// registered remote local drivers can be received.
func ClientDrivers() <-chan types.ClientDriver {
c := make(chan types.ClientDriver)
go func() {
clientDriverCtorsRWL.RLock()
defer clientDriverCtorsRWL.RUnlock()
for _, ctor := range clientDriverCtors {
c <- ctor()
}
close(c)
}()
return c
}

// StorageDrivers returns a channel on which new instances of all
// registered remote storage drivers can be received.
func StorageDrivers() <-chan types.StorageDriver {
Expand Down
142 changes: 0 additions & 142 deletions api/types/types_drivers_client.go

This file was deleted.

65 changes: 0 additions & 65 deletions drivers/storage/libstorage/libstorage_client_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package libstorage
import (
"io"

"github.com/codedellemc/libstorage/api/registry"
"github.com/codedellemc/libstorage/api/types"
"github.com/codedellemc/libstorage/api/utils"
)
Expand Down Expand Up @@ -121,27 +120,11 @@ func (c *client) VolumeCreate(
}
ctx = ctxA

lsd, _ := registry.NewClientDriver(service)
if lsd != nil {
if err := lsd.Init(ctx, c.config); err != nil {
return nil, err
}

if err := lsd.VolumeCreateBefore(
&ctx, service, request); err != nil {
return nil, err
}
}

vol, err := c.APIClient.VolumeCreate(ctx, service, request)
if err != nil {
return nil, err
}

if lsd != nil {
lsd.VolumeCreateAfter(ctx, vol)
}

return vol, nil
}

Expand All @@ -152,28 +135,12 @@ func (c *client) VolumeCreateFromSnapshot(

ctx = c.withInstanceID(c.requireCtx(ctx), service)

lsd, _ := registry.NewClientDriver(service)
if lsd != nil {
if err := lsd.Init(ctx, c.config); err != nil {
return nil, err
}

if err := lsd.VolumeCreateFromSnapshotBefore(
&ctx, service, snapshotID, request); err != nil {
return nil, err
}
}

vol, err := c.APIClient.VolumeCreateFromSnapshot(
ctx, service, snapshotID, request)
if err != nil {
return nil, err
}

if lsd != nil {
lsd.VolumeCreateFromSnapshotAfter(ctx, vol)
}

return vol, nil
}

Expand All @@ -184,27 +151,11 @@ func (c *client) VolumeCopy(

ctx = c.withInstanceID(c.requireCtx(ctx), service)

lsd, _ := registry.NewClientDriver(service)
if lsd != nil {
if err := lsd.Init(ctx, c.config); err != nil {
return nil, err
}

if err := lsd.VolumeCopyBefore(
&ctx, service, volumeID, request); err != nil {
return nil, err
}
}

vol, err := c.APIClient.VolumeCopy(ctx, service, volumeID, request)
if err != nil {
return nil, err
}

if lsd != nil {
lsd.VolumeCopyAfter(ctx, vol)
}

return vol, nil
}

Expand All @@ -215,27 +166,11 @@ func (c *client) VolumeRemove(

ctx = c.withInstanceID(c.requireCtx(ctx), service)

lsd, _ := registry.NewClientDriver(service)
if lsd != nil {
if err := lsd.Init(ctx, c.config); err != nil {
return err
}

if err := lsd.VolumeRemoveBefore(
&ctx, service, volumeID); err != nil {
return err
}
}

err := c.APIClient.VolumeRemove(ctx, service, volumeID, force)
if err != nil {
return err
}

if lsd != nil {
lsd.VolumeRemoveAfter(ctx, service, volumeID)
}

return nil
}

Expand Down
Loading

0 comments on commit 7d0eb86

Please sign in to comment.