Skip to content

Commit

Permalink
Check for missing client-side service config
Browse files Browse the repository at this point in the history
This patch fixes rexray#769 by asserting that an attempt to create a new
libStorage client must occur concurrently alongside a configured
"libstorage.service" property.

Note: this patch must be revisited should REX-Ray ever allow for access
of the libStorage API above the level of a single service. For example,
requesting volumes for all configured services.
  • Loading branch information
akutz committed May 1, 2017
1 parent 45027cb commit df06020
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
log "github.com/Sirupsen/logrus"
gofigCore "github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"
"github.com/akutz/goof"
"github.com/akutz/gotil"

apiversion "github.com/codedellemc/libstorage/api"
Expand Down Expand Up @@ -448,9 +449,18 @@ func WaitUntilLibStorageStopped(ctx apitypes.Context, errs <-chan error) {
waitUntilLibStorageStopped(ctx, errs)
}

// ErrMissingService occurs when the client configuration is
// missing the property "libstorage.service" either at the root
// or as part of a module definition.
var ErrMissingService = goof.New("missing service configuration")

// NewClient returns a new libStorage client.
func NewClient(
ctx apitypes.Context, config gofig.Config) (apitypes.Client, error) {

if v := config.Get(apitypes.ConfigService); v == "" {
return nil, ErrMissingService
}
return newClient(ctx, config)
}

Expand Down

0 comments on commit df06020

Please sign in to comment.