diff --git a/.travis.yml b/.travis.yml index 51fc786..5f24c1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -56,4 +56,4 @@ after_success: cache: apt: true directories: - - $HOME/.opt \ No newline at end of file + - $HOME/.opt diff --git a/Makefile b/Makefile index 4ffd448..a45259d 100644 --- a/Makefile +++ b/Makefile @@ -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 \ @@ -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; \ @@ -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: @@ -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_; \ @@ -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_; \ @@ -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_; \ @@ -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); \ diff --git a/core/libstorage/client/client.go b/core/libstorage/client/client.go index 50d4abe..f2548a4 100644 --- a/core/libstorage/client/client.go +++ b/core/libstorage/client/client.go @@ -25,11 +25,19 @@ 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 { @@ -37,14 +45,14 @@ func NewWithConfig(ctx apitypes.Context, config gofig.Config) (*Client, error) { } }() - 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) } @@ -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) { diff --git a/core/libstorage/server/server.go b/core/libstorage/server/server.go index c55c09d..1bf196c 100644 --- a/core/libstorage/server/server.go +++ b/core/libstorage/server/server.go @@ -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 } diff --git a/glide.yaml b/glide.yaml index 0c17fd4..f3c0810 100644 --- a/glide.yaml +++ b/glide.yaml @@ -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 diff --git a/util/util.go b/util/util.go index 13854a6..ae3fd45 100644 --- a/util/util.go +++ b/util/util.go @@ -10,8 +10,9 @@ import ( "strconv" "github.com/akutz/gotil" - + apiversion "github.com/emccode/libstorage/api" "github.com/emccode/polly/core/version" + "time" ) const ( @@ -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 diff --git a/util/util_test.go b/util/util_test.go index dab5ff5..e939dc9 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -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)