Skip to content

Commit

Permalink
No. More. Gofig.
Browse files Browse the repository at this point in the history
This patch removes Gofig unless the build tag "gofig" is used when
building libStorage or anything that depends upon it.
  • Loading branch information
akutz committed Nov 7, 2016
1 parent 81dca0f commit b2be18e
Show file tree
Hide file tree
Showing 76 changed files with 397 additions and 295 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ before_install:

script:
- make gometalinter-all
- make -j build
- make -j test
- BUILD_TAGS="gofig pflag" make -j build
- BUILD_TAGS="gofig pflag" make -j test
- VFS_INSTANCEID_USE_FIELDS=true ./drivers/storage/vfs/tests/vfs.test
- go clean -i ./client && go build ./client

after_success:
- make -j cover
Expand Down
37 changes: 31 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ export PATH := $(GOPATH)/bin:$(PATH)
################################################################################

GO_LIST_BUILD_INFO_CMD := go list -f '{{with $$ip:=.}}{{with $$ctx:=context}}{{printf "%s %s %s %s %s 0,%s" $$ip.ImportPath $$ip.Name $$ip.Dir $$ctx.GOOS $$ctx.GOARCH (join $$ctx.BuildTags ",")}}{{end}}{{end}}'
ifneq (,$(BUILD_TAGS))
GO_LIST_BUILD_INFO_CMD += -tags "$(BUILD_TAGS)"
endif
BUILD_INFO := $(shell $(GO_LIST_BUILD_INFO_CMD))
ROOT_IMPORT_PATH := $(word 1,$(BUILD_INFO))
ROOT_IMPORT_PATH_NV := $(ROOT_IMPORT_PATH)
ROOT_IMPORT_NAME := $(word 2,$(BUILD_INFO))
ROOT_DIR := $(word 3,$(BUILD_INFO))
GOOS ?= $(word 4,$(BUILD_INFO))
GOARCH ?= $(word 5,$(BUILD_INFO))
BUILD_TAGS := $(word 6,$(BUILD_INFO))
BUILD_TAGS := $(subst $(COMMA), ,$(BUILD_TAGS))
BUILD_TAGS := $(wordlist 2,$(words $(BUILD_TAGS)),$(BUILD_TAGS))
VENDORED := 0
ifneq (,$(strip $(findstring vendor,$(ROOT_IMPORT_PATH))))
VENDORED := 1
Expand Down Expand Up @@ -262,7 +262,11 @@ endif
## PROJECT DETAIL ##
################################################################################

GO_LIST_IMPORT_PATHS_INFO_CMD := go list -f '{{with $$ip:=.}}{{if $$ip.ImportPath | le "$(ROOT_IMPORT_PATH)"}}{{if $$ip.ImportPath | gt "$(ROOT_IMPORT_PATH)/vendor" }}{{printf "%s;%s;%s;%s;%v;0,%s,%s,%s,%s;0,%s;0,%s;0,%s" $$ip.ImportPath $$ip.Name $$ip.Dir $$ip.Target $$ip.Stale (join $$ip.GoFiles ",") (join $$ip.CgoFiles ",") (join $$ip.CFiles ",") (join $$ip.HFiles ",") (join $$ip.TestGoFiles ",") (join $$ip.Imports ",") (join $$ip.TestImports ",")}};{{end}}{{end}}{{end}}' ./...
GO_LIST_IMPORT_PATHS_INFO_CMD := go list -f '{{with $$ip:=.}}{{if $$ip.ImportPath | le "$(ROOT_IMPORT_PATH)"}}{{if $$ip.ImportPath | gt "$(ROOT_IMPORT_PATH)/vendor" }}{{printf "%s;%s;%s;%s;%v;0,%s,%s,%s,%s;0,%s;0,%s;0,%s" $$ip.ImportPath $$ip.Name $$ip.Dir $$ip.Target $$ip.Stale (join $$ip.GoFiles ",") (join $$ip.CgoFiles ",") (join $$ip.CFiles ",") (join $$ip.HFiles ",") (join $$ip.TestGoFiles ",") (join $$ip.Imports ",") (join $$ip.TestImports ",")}};{{end}}{{end}}{{end}}'
ifneq (,$(BUILD_TAGS))
GO_LIST_IMPORT_PATHS_INFO_CMD += -tags "$(BUILD_TAGS)"
endif
GO_LIST_IMPORT_PATHS_INFO_CMD += ./...
IMPORT_PATH_INFO := $(shell $(GO_LIST_IMPORT_PATHS_INFO_CMD))

# this runtime ruleset acts as a pre-processor, processing the import path
Expand Down Expand Up @@ -376,6 +380,7 @@ ifeq (1,$(VENDORED))
endif
$(info Project Name................$(ROOT_IMPORT_NAME))
$(info OS / Arch...................$(GOOS)_$(GOARCH))
$(info Build Tags..................$(BUILD_TAGS))
$(info Vendored....................$(VENDORED))
$(info GOPATH......................$(GOPATH))
$(info GOHOSTOS....................$(GOHOSTOS))
Expand Down Expand Up @@ -707,7 +712,11 @@ $$(PKG_D_$1)-clean:
GO_CLEAN += $$(PKG_D_$1)-clean

$$(PKG_A_$1): $$(EXT_DEPS_SRCS_$1) $$(SRCS_$1) | $$(DEPS_ARKS_$1)
ifeq (,$$(BUILD_TAGS))
GOOS=$(GOOS) GOARCH=$(GOARCH) go install $1
else
GOOS=$(GOOS) GOARCH=$(GOARCH) go install -tags "$$(BUILD_TAGS)" $1
endif

ifeq (true,$$(STALE_$1))
GO_PHONY += $$(PKG_A_$1)
Expand Down Expand Up @@ -751,7 +760,12 @@ $$(PKG_TA_$1): $$(SRCS_$1)
endif

$$(PKG_TA_$1): $$(TEST_SRCS_$1) $$(TEST_EXT_DEPS_SRCS_$1) | $$(TEST_DEPS_ARKS_$1)
ifeq (,$$(BUILD_TAGS))
go test -cover -coverpkg '$$(TEST_COVERPKG_$1)' -c -o $$@ $1
else
go test -cover -coverpkg '$$(TEST_COVERPKG_$1)' -tags "$$(BUILD_TAGS)" -c -o $$@ $1
endif

$$(PKG_TA_$1)-clean:
rm -f $$(PKG_TA_$1)
GO_PHONY += $$(PKG_TA_$1)-clean
Expand Down Expand Up @@ -814,7 +828,7 @@ LSX_EMBEDDED_$2 := ./api/server/executors/bin/$$(notdir $1)

ifneq ($2,$$(GOOS))
$1:
env GOOS=$2 GOARCH=amd64 $$(MAKE) $$@
BUILD_TAGS="$$(BUILD_TAGS)" GOOS=$2 GOARCH=amd64 $$(MAKE) $$@
$1-clean:
rm -f $1
GO_PHONY += $1-clean
Expand Down Expand Up @@ -866,7 +880,11 @@ libstor-c: $(C_LIBSTOR_C_SO) $(C_LIBSTOR_C_BIN)

$(C_LIBSTOR_C_SO): $(EXT_DEPS_SRCS_./c/libstor-c) \
$(SRCS_./c/libstor-c) | $(DEPS_ARKS_./c/libstor-c)
ifeq (,$(BUILD_TAGS))
go build -buildmode=c-shared -o $@ $(C_LIBSTOR_C_DIR)
else
go build -tags "$(BUILD_TAGS)" -buildmode=c-shared -o $@ $(C_LIBSTOR_C_DIR)
endif

$(C_LIBSTOR_C_SO)-clean:
rm -f $(C_LIBSTOR_C_SO) $(basename $(C_LIBSTOR_C_SO).h)
Expand Down Expand Up @@ -897,7 +915,11 @@ libstor-s: $(C_LIBSTOR_S_BIN) $(C_LIBSTOR_S_SO)

$(C_LIBSTOR_S_SO): $(EXT_DEPS_SRCS_./c/libstor-s) \
$(SRCS_./c/libstor-s) | $(DEPS_ARKS_./c/libstor-s)
ifeq (,$(BUILD_TAGS))
go build -buildmode=c-shared -o $@ $(C_LIBSTOR_S_DIR)
else
go build -tags "$(BUILD_TAGS)" -buildmode=c-shared -o $@ $(C_LIBSTOR_S_DIR)
endif

$(C_LIBSTOR_S_SO)-clean:
rm -f $(C_LIBSTOR_S_SO) $(basename $(C_LIBSTOR_S_SO).h)
Expand Down Expand Up @@ -931,7 +953,7 @@ build-lss-windows: $(LSS_WINDOWS)
define LSS_RULES
ifneq ($2,$$(GOOS))
$1:
env GOOS=$2 GOARCH=amd64 $$(MAKE) $$@
BUILD_TAGS="$$(BUILD_TAGS)" GOOS=$2 GOARCH=amd64 $$(MAKE) $$@
$1-clean:
rm -f $1
GO_PHONY += $1-clean
Expand Down Expand Up @@ -1002,6 +1024,9 @@ build-generated:
$(MAKE) build-lsx
$(MAKE) $(API_GENERATED_SRC)

build-client-nogofig:
go build ./client

build:
$(MAKE) build-generated
$(MAKE) build-libstorage
Expand Down
8 changes: 8 additions & 0 deletions api/registry/registry_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package registry

import (
gofig "github.com/akutz/gofig/types"
)

// NewConfig is a function that returns a new Config object.
var NewConfig func() gofig.Config
11 changes: 11 additions & 0 deletions api/registry/registry_config_gofig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build gofig

package registry

import (
"github.com/akutz/gofig"
)

func init() {
NewConfig = gofig.New
}
2 changes: 1 addition & 1 deletion api/registry/registry_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"sync"

log "github.com/Sirupsen/logrus"
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/context"
"github.com/codedellemc/libstorage/api/types"
Expand Down
3 changes: 2 additions & 1 deletion api/server/httputils/httputils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"net/http/httptest"
"time"

"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/server/services"
"github.com/codedellemc/libstorage/api/types"
)
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/executor/executor.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package executor

import (
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/registry"
"github.com/codedellemc/libstorage/api/server/httputils"
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/help/help.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package help

import (
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/registry"
"github.com/codedellemc/libstorage/api/server/httputils"
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/root/root.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package root

import (
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/registry"
"github.com/codedellemc/libstorage/api/server/httputils"
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/service/service.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package service

import (
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/registry"
"github.com/codedellemc/libstorage/api/server/handlers"
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/snapshot/snapshot.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package snapshot

import (
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/registry"
"github.com/codedellemc/libstorage/api/server/handlers"
Expand Down
3 changes: 2 additions & 1 deletion api/server/router/tasks/tasks.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package tasks

import (
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/registry"
"github.com/codedellemc/libstorage/api/server/httputils"
"github.com/codedellemc/libstorage/api/types"
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package volume
import (
"net/http"

"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/registry"
"github.com/codedellemc/libstorage/api/server/handlers"
Expand Down
2 changes: 1 addition & 1 deletion api/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
gocontext "golang.org/x/net/context"

log "github.com/Sirupsen/logrus"
"github.com/akutz/gofig"

gofig "github.com/akutz/gofig/types"
"github.com/codedellemc/gournal"
glogrus "github.com/codedellemc/gournal/logrus"

Expand Down
2 changes: 1 addition & 1 deletion api/server/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"sync"

"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"
"github.com/akutz/goof"

"github.com/codedellemc/libstorage/api/context"
Expand Down
2 changes: 1 addition & 1 deletion api/server/services/services_storage.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package services

import (
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"
"github.com/akutz/goof"

"github.com/codedellemc/libstorage/api/context"
Expand Down
3 changes: 2 additions & 1 deletion api/server/services/services_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
"time"

log "github.com/Sirupsen/logrus"
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/akutz/goof"

"github.com/codedellemc/libstorage/api/context"
Expand Down
6 changes: 4 additions & 2 deletions api/tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
"testing"

log "github.com/Sirupsen/logrus"
"github.com/akutz/gofig"
gofigCore "github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/akutz/goof"
"github.com/akutz/gotil"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -315,7 +317,7 @@ func getTestConfig(
configBuf []byte,
debug bool) gofig.Config {

config := gofig.New()
config := gofigCore.New()

if debug {
log.SetLevel(log.DebugLevel)
Expand Down
2 changes: 1 addition & 1 deletion api/tests/tests_executors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io/ioutil"
"testing"

"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"
"github.com/stretchr/testify/assert"

"github.com/codedellemc/libstorage/api/types"
Expand Down
2 changes: 1 addition & 1 deletion api/tests/tests_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"
"github.com/stretchr/testify/assert"

"github.com/codedellemc/libstorage/api/context"
Expand Down
6 changes: 4 additions & 2 deletions api/types/types_config_compat.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package types

import "github.com/akutz/gofig"
import log "github.com/Sirupsen/logrus"
import (
log "github.com/Sirupsen/logrus"
gofig "github.com/akutz/gofig/types"
)

const (
//ConfigOldRoot is a config key.
Expand Down
4 changes: 1 addition & 3 deletions api/types/types_drivers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package types

import (
"github.com/akutz/gofig"
)
import gofig "github.com/akutz/gofig/types"

// Driver is the base interface for a libStorage driver.
type Driver interface {
Expand Down
4 changes: 1 addition & 3 deletions api/types/types_http_routes.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package types

import (
"github.com/akutz/gofig"
)
import gofig "github.com/akutz/gofig/types"

// Router defines an interface to specify a group of routes to add the the
// server.
Expand Down
5 changes: 3 additions & 2 deletions api/utils/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import (
"time"

log "github.com/Sirupsen/logrus"
gofig "github.com/akutz/gofig/types"

"github.com/akutz/gofig"
"github.com/akutz/gotil"
"github.com/codedellemc/libstorage/api/registry"
"github.com/codedellemc/libstorage/api/types"
"github.com/codedellemc/libstorage/api/utils"
)

// NewConfig returns a new configuration instance.
func NewConfig() (gofig.Config, error) {
config := gofig.New()
config := registry.NewConfig()

etcYML := types.Etc.Join("config.yml")
etcYAML := types.Etc.Join("config.yaml")
Expand Down
2 changes: 1 addition & 1 deletion api/utils/utils_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"
)

func isSet(
Expand Down
3 changes: 2 additions & 1 deletion api/utils/utils_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package utils

import (
log "github.com/Sirupsen/logrus"
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"

"github.com/codedellemc/libstorage/api/types"
)

Expand Down
2 changes: 1 addition & 1 deletion api/utils/utils_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"

log "github.com/Sirupsen/logrus"
"github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"
"github.com/akutz/goof"
"github.com/akutz/gotil"

Expand Down
Loading

0 comments on commit b2be18e

Please sign in to comment.