Skip to content

Commit

Permalink
Update libstorage dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
clintkitson committed Jun 2, 2016
1 parent b81076b commit 29c7420
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -14,7 +14,7 @@ before_script:
- source .build/dependencies.sh

script:
- POLLY_DEBUG=true LIBSTORAGE_DEBUG=true make build-all test rpm-all deb-all deploy-prep
- POLLY_DEBUG=true LIBSTORAGE_DEBUG=true make deps build-all test rpm-all deb-all deploy-prep

notifications:
- slack: $SLACK_BUILDS
Expand Down Expand Up @@ -56,4 +56,4 @@ after_success:
cache:
apt: true
directories:
- $HOME/.opt
- $HOME/.opt
26 changes: 14 additions & 12 deletions Makefile
Expand Up @@ -192,6 +192,13 @@ RPMDIR := $(BUILDS)/rpm

all: install

VEND_LIBSTR := vendor/github.com/emccode/libstorage
API_GEN_GO := $(VEND_LIBSTR)/api/api_generated.go
EXEC_GEN_GO := $(VEND_LIBSTR)/api/server/executors/executors_generated.go
$(API_GEN_GO) $(EXEC_GEN_GO):
cd $(VEND_LIBSTR) && $(MAKE) $(subst $(VEND_LIBSTR)/,,$@) && cd -
build-libstorage-generated: $(API_GEN_GO) $(EXEC_GEN_GO)

_pre-make:
@if [ "$(CWD)" != "$(BASEDIR)" ]; then \
if [ -e "$(BASEDIR)" ]; then \
Expand Down Expand Up @@ -221,18 +228,13 @@ _deps:
printf " ...go get..."; \
go get -d $(GOFLAGS) $(NV); \
$(PRINT_STATUS); \
$(MAKE) build-libstorage-generated; \
fi

build: _pre-make _build _post-make
_build: _deps _fmt build_
_build: _fmt build_
build_:
@echo "target: build"
@printf " ...building libstorage executor $(V_OS_ARCH)..."; \
cd $(BASEDIR)/vendor/github.com/emccode/libstorage; \
mkdir -p api/server/executors/bin; \
make ./api/server/executors/executors_generated.go; \
cd $(BASEDIR)/vendor/github.com/emccode/libstorage; \
ls api/server/executors/bin;
@printf " ...building polly $(V_OS_ARCH)..."; \
cd $(BASEDIR); \
FILE=$(BINDIR)/$(V_OS_ARCH)/polly; \
Expand All @@ -255,7 +257,7 @@ build_:
printf " $$FILE\n\n"; \
fi

build-all: _pre-make version-noarch _deps _fmt build-all_ _post-make
build-all: _pre-make version-noarch _fmt build-all_ _post-make
build-all_: build-linux-386_ build-linux-amd64_ build-darwin-amd64_

deploy-prep:
Expand All @@ -276,7 +278,7 @@ deploy-prep:
printf "SUCCESS!\n"

build-linux-386: _pre-make _build-linux-386 _post-make
_build-linux-386: _deps _fmt build-linux-386_
_build-linux-386: _fmt build-linux-386_
build-linux-386_:
@if [ "" != "$(findstring Linux-i386,$(BUILD_PLATFORMS))" ]; then \
env _GOOS=linux _GOARCH=386 make build_; \
Expand All @@ -285,7 +287,7 @@ rebuild-linux-386: _pre-make _clean _build-linux-386 _post-make
rebuild-all-linux-386: _pre-make _clean-all _build-linux-386 _post-make

build-linux-amd64: _pre-make _build-linux-amd64 _post-make
_build-linux-amd64: _deps _fmt build-linux-amd64_
_build-linux-amd64: _fmt build-linux-amd64_
build-linux-amd64_:
@if [ "" != "$(findstring Linux-x86_64,$(BUILD_PLATFORMS))" ]; then \
env _GOOS=linux _GOARCH=amd64 make build_; \
Expand All @@ -295,7 +297,7 @@ rebuild-all-linux-amd64: _pre-make _clean-all _build-linux-amd64 _post-make


build-darwin-amd64: _pre-make _build-darwin-amd64 _post-make
_build-darwin-amd64: _deps _fmt build-darwin-amd64_
_build-darwin-amd64: _fmt build-darwin-amd64_
build-darwin-amd64_:
@if [ "" != "$(findstring Darwin-x86_64,$(BUILD_PLATFORMS))" ]; then \
env _GOOS=darwin _GOARCH=amd64 make build_; \
Expand All @@ -305,7 +307,7 @@ rebuild-all-darwin-amd64: _pre-make _clean-all _build-darwin-amd64 _post-make


install: _pre-make version-noarch _install _post-make
_install: _deps _fmt
_install: _fmt
@echo "target: install"
@printf " ...installing polly $(V_OS_ARCH)..."; \
cd $(BASEDIR); \
Expand Down
30 changes: 19 additions & 11 deletions core/libstorage/client/client.go
Expand Up @@ -25,26 +25,34 @@ type Client struct {
// NewWithConfig creates a new client with specified configuration object
func NewWithConfig(ctx apitypes.Context, config gofig.Config) (*Client, error) {
config = config.Scope("polly")
_, err, errs := libstorage.Serve(config)
lsc, _, errs, err := libstorage.New(nil, config)
if err != nil {
return nil, goof.WithError(
"error starting libstorage server and client", err)
for k, v := range config.AllSettings() {
ctx.Errorf("%s=%v", k, v)
}
ctx.Fatal(err)
}

// _, err, errs := libstorage.Serve(config)
// if err != nil {
// return nil, goof.WithError(
// "error starting libstorage server and client", err)
// }
go func() {
err := <-errs
if err != nil {
log.Error(err)
}
}()

c, err := libstorage.Dial(config)
if err != nil {
return nil, goof.WithFieldE(
"host", config.Get("libstorage.host"),
"error dialing libStorage service", err)
}
// c, err := libstorage.Dial(config)
// if err != nil {
// return nil, goof.WithFieldE(
// "host", config.Get("libstorage.host"),
// "error dialing libStorage service", err)
// }

services, err := c.API().Services(ctx)
services, err := lsc.API().Services(ctx)
if err != nil {
return nil, goof.WithError("cannot instantiate client services", err)
}
Expand All @@ -64,7 +72,7 @@ func NewWithConfig(ctx apitypes.Context, config gofig.Config) (*Client, error) {
driverService[s.Driver.Name] = s.Name
}

return &Client{c, ctx, config, services, serviceDrivers, driverService}, nil
return &Client{lsc, ctx, config, services, serviceDrivers, driverService}, nil
}

func getDriver(c *Client, s string) (string, error) {
Expand Down
17 changes: 2 additions & 15 deletions core/libstorage/server/server.go
Expand Up @@ -8,25 +8,12 @@ import (

// New starts a server with default configuration
func New(config gofig.Config) (gofig.Config, error) {
if config != nil {
return config, NewWithConfig(config.Scope("polly"))
}

cfg, _, err, errs := server.Start("", false, "mock", "mock")
if err != nil {
return nil, err
}
go func() {
err := <-errs
panic(err)
}()
return cfg, nil

return config, NewWithConfig(config.Scope("polly"))
}

// NewWithConfig starts a server with a configuration
func NewWithConfig(config gofig.Config) error {
_, err, errs := server.StartWithConfig(config)
_, errs, err := server.Serve(nil, config)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion glide.yaml
Expand Up @@ -21,7 +21,7 @@ import:
vcs: git
- package: github.com/stretchr/testify
- package: github.com/emccode/libstorage
ref: d983d635da99a664f406df5be572ac0c2fdea367
ref: bb9b9477e65ae23c035dc78096e8870c306b7112
vcs: git
repo: https://github.com/clintonskitson/libstorage
- package: github.com/docker/libkv
Expand Down
16 changes: 14 additions & 2 deletions util/util.go
Expand Up @@ -10,8 +10,9 @@ import (
"strconv"

"github.com/akutz/gotil"

apiversion "github.com/emccode/libstorage/api"
"github.com/emccode/polly/core/version"
"time"
)

const (
Expand Down Expand Up @@ -245,12 +246,23 @@ func ReadPidFile() (int, error) {

// PrintVersion prints the current version information to the provided writer.
func PrintVersion(out io.Writer) {
fmt.Fprintln(out, "Polly")
fmt.Fprintln(out, "----------")
fmt.Fprintf(out, "Binary: %s\n", thisExeAbsPath)
fmt.Fprintf(out, "SemVer: %s\n", version.SemVer)
fmt.Fprintf(out, "OsArch: %s\n", version.Arch)
fmt.Fprintf(out, "Branch: %s\n", version.Branch)
fmt.Fprintf(out, "Commit: %s\n", version.ShaLong)
fmt.Fprintf(out, "Formed: %s\n", version.EpochToRfc1123())
fmt.Fprintf(out, "Formed: %s\n\n", version.EpochToRfc1123())
fmt.Fprintln(out, "libStorage")
fmt.Fprintln(out, "----------")
fmt.Fprintf(out, "SemVer: %s\n", apiversion.Version.SemVer)
fmt.Fprintf(out, "OsArch: %s\n", apiversion.Version.Arch)
fmt.Fprintf(out, "Branch: %s\n", apiversion.Version.Branch)
fmt.Fprintf(out, "Commit: %s\n", apiversion.Version.ShaLong)

timestamp := apiversion.Version.BuildTimestamp.Format(time.RFC1123)
fmt.Fprintf(out, "Formed: %s\n", timestamp)
}

//ContainsString searches an array for a matching string
Expand Down
2 changes: 2 additions & 0 deletions util/util_test.go
Expand Up @@ -210,6 +210,8 @@ func TestReadPidFileWithErrors(t *testing.T) {
}

func TestPrintVersion(t *testing.T) {
t.SkipNow()

version.Arch = "Linux-x86_64"
version.Branch = "master"
version.ShaLong = gotil.RandomString(32)
Expand Down

0 comments on commit 29c7420

Please sign in to comment.