Skip to content

Commit

Permalink
Build Tag Activated Drivers/Executors
Browse files Browse the repository at this point in the history
This patch enables the specific activation of storage drivers/executors
via build tags. The tags `libstorage_storage_driver` and
`libstorage_storage_executor`, if absent, will result in all
drivers/executors being activated. This is the previous, default
behavior. However, if the tags `libstorage_storage_driver` and
`libstorage_storage_executor` are present along with
`libstorage_storage_driver_NAME` and `libstorage_storage_executor_NAME`,
where NAME is the name of a driver, ex. `ebs`, then only that driver and
executor are considered for compilation.
  • Loading branch information
akutz committed Dec 7, 2016
1 parent 099d442 commit 0bc6b8c
Show file tree
Hide file tree
Showing 62 changed files with 245 additions and 40 deletions.
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ go:
os:
- linux

env:
- BUILD_TAGS="gofig pflag libstorage_integration_driver_docker libstorage_storage_driver libstorage_storage_driver_vfs libstorage_storage_executor libstorage_storage_executor_vfs"
- BUILD_TAGS="gofig pflag libstorage_integration_driver_docker"
- BUILD_TAGS=""

matrix:
allow_failures:
- go: 1.6.3
- go: tip
- go: 1.6.3
- go: tip
fast_finish: true

before_install:
- if [ "$BUILD_TAGS" = "$DEFAULT_BUILD_TAGS" ] && [ "$TRAVIS_GO_VERSION" = "$COVERED_GO_VERSION" ]; then echo coverage enabled; fi
- git config --global 'url.https://gopkg.in/yaml.v1.insteadof' 'https://gopkg.in/yaml.v1/'
- git config --global 'url.https://gopkg.in/yaml.v2.insteadof' 'https://gopkg.in/yaml.v2/'
- git config --global 'url.https://gopkg.in/fsnotify.v1.insteadof' 'https://gopkg.in/fsnotify.v1/'
Expand All @@ -28,12 +34,11 @@ before_install:
script:
- make gometalinter-all
- make -j build
- make -j test
- VFS_INSTANCEID_USE_FIELDS=true ./drivers/storage/vfs/tests/vfs.test
- go clean -i ./client && go build ./client
- if [ "$BUILD_TAGS" = "$DEFAULT_BUILD_TAGS" ] && [ "$TRAVIS_GO_VERSION" = "$COVERED_GO_VERSION" ]; then make -j test; fi
- if [ "$BUILD_TAGS" = "$DEFAULT_BUILD_TAGS" ] && [ "$TRAVIS_GO_VERSION" = "$COVERED_GO_VERSION" ]; then VFS_INSTANCEID_USE_FIELDS=true ./drivers/storage/vfs/tests/vfs.test; fi

after_success:
- make -j cover
- if [ "$BUILD_TAGS" = "$DEFAULT_BUILD_TAGS" ] && [ "$TRAVIS_GO_VERSION" = "$COVERED_GO_VERSION" ]; then make -j cover; fi

addons:
apt:
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
SHELL := /bin/bash

ifeq (undefined,$(origin BUILD_TAGS))
BUILD_TAGS := gofig pflag libstorage_integration_driver_docker
BUILD_TAGS := gofig \
pflag \
libstorage_integration_driver_docker
ifneq (true,$(TRAVIS))
BUILD_TAGS += libstorage_storage_driver \
libstorage_storage_driver_vfs \
libstorage_storage_executor \
libstorage_storage_executor_vfs
endif
endif

all:
Expand Down Expand Up @@ -184,7 +192,7 @@ else
GOVERSION := $(shell go version | awk '{print $$3}' | cut -c3-)
endif

ifeq (1.7.1,$(TRAVIS_GO_VERSION))
ifeq (1.7.4,$(TRAVIS_GO_VERSION))
ifeq (linux,$(TRAVIS_OS_NAME))
COVERAGE_ENABLED := 1
endif
Expand Down
67 changes: 39 additions & 28 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,25 @@ func New(goCtx gocontext.Context, config gofig.Config) (types.Client, error) {
context.ServiceKey, config.GetString(types.ConfigService))
}

storageDriverName := config.GetString(types.ConfigStorageDriver)
if c.sd, err = registry.NewStorageDriver(storageDriverName); err != nil {
return nil, err
}
if err = c.sd.Init(c.ctx, config); err != nil {
return nil, err
}
if papi, ok := c.sd.(types.ProvidesAPIClient); ok {
c.api = papi.API()
}
if pxli, pxliOk := c.sd.(types.ProvidesStorageExecutorCLI); pxliOk {
c.xli = pxli.XCLI()
storDriverName := config.GetString(types.ConfigStorageDriver)
if storDriverName == "" {
c.ctx.Warn("no storage driver found")
} else {
if c.sd, err = registry.NewStorageDriver(storDriverName); err != nil {
return nil, err
}
if err = c.sd.Init(c.ctx, config); err != nil {
return nil, err
}
if papi, ok := c.sd.(types.ProvidesAPIClient); ok {
c.api = papi.API()
}
if pxli, pxliOk := c.sd.(types.ProvidesStorageExecutorCLI); pxliOk {
c.xli = pxli.XCLI()
}
c.ctx.Info("storage driver initialized")
}

c.ctx.Info("storage driver initialized")

// if the API or XLI are nil, then the storage driver is not the libStorage
// storage driver, and we should jump avoid any more initialization
if c.api == nil || c.xli == nil {
Expand All @@ -86,23 +89,31 @@ func New(goCtx gocontext.Context, config gofig.Config) (types.Client, error) {
}

osDriverName := config.GetString(types.ConfigOSDriver)
if c.od, err = registry.NewOSDriver(osDriverName); err != nil {
return nil, err
}
if err = c.od.Init(c.ctx, config); err != nil {
return nil, err
if osDriverName == "" {
c.ctx.Warn("no os driver found")
} else {
if c.od, err = registry.NewOSDriver(osDriverName); err != nil {
return nil, err
}
if err = c.od.Init(c.ctx, config); err != nil {
return nil, err
}
c.ctx.Info("os driver initialized")
}
c.ctx.Info("os driver initialized")

integrationDriverName := config.GetString(types.ConfigIntegrationDriver)
if c.id, err = registry.NewIntegrationDriver(
integrationDriverName); err != nil {
return nil, err
}
if err := c.id.Init(c.ctx, config); err != nil {
return nil, err
intDriverName := config.GetString(types.ConfigIntegrationDriver)
if intDriverName == "" {
c.ctx.Warn("no integration driver found")
} else {
if c.id, err = registry.NewIntegrationDriver(
intDriverName); err != nil {
return nil, err
}
if err := c.id.Init(c.ctx, config); err != nil {
return nil, err
}
c.ctx.Info("integration driver initialized")
}
c.ctx.Info("integration driver initialized")

c.ctx.Info("created libStorage client")
return c, nil
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/ebs/ebs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_ebs

package ebs

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/ebs/ebs_config_compat.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_ebs

package ebs

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/ebs/executor/ebs_executor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_executor libstorage_storage_executor_ebs

package executor

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/ebs/storage/ebs_storage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_ebs

package storage

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/ebs/tests/ebs_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_ebs

package ebs

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/ebs/utils/utils.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_ebs

package utils

import (
Expand Down
1 change: 1 addition & 0 deletions drivers/storage/ebs/utils/utils_go17.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build go1.7
// +build !libstorage_storage_driver libstorage_storage_driver_ebs

package utils

Expand Down
1 change: 1 addition & 0 deletions drivers/storage/ebs/utils/utils_pre_go17.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build !go1.7
// +build !libstorage_storage_driver libstorage_storage_driver_ebs

package utils

Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/ebs/utils/utils_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_ebs

package utils

import (
Expand Down
1 change: 1 addition & 0 deletions drivers/storage/ebs/utils/utils_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build !windows
// +build !libstorage_storage_driver libstorage_storage_driver_ebs

package utils

Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/efs/efs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_efs

package efs

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/efs/executor/efs_executor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_executor libstorage_storage_executor_efs

package executor

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/efs/storage/efs_storage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_efs

package storage

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/efs/tests/efs_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_efs

package efs

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/efs/utils/utils.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_efs

package utils

import (
Expand Down
1 change: 1 addition & 0 deletions drivers/storage/efs/utils/utils_go17.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build go1.7
// +build !libstorage_storage_driver libstorage_storage_driver_efs

package utils

Expand Down
1 change: 1 addition & 0 deletions drivers/storage/efs/utils/utils_pre_go17.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build !go1.7
// +build !libstorage_storage_driver libstorage_storage_driver_efs

package utils

Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/efs/utils/utils_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_efs

package utils

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/isilon/executor/isilon_executor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_executor libstorage_storage_executor_isilon

package executor

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/isilon/isilon.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_isilon

package isilon

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/isilon/storage/isilon_storage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_isilon

package storage

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/isilon/tests/isilon_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_isilon

package isilon

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/rackspace/executor/rackspace_executor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build none

package executor

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/rackspace/rackspace.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build none

package rackspace

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/rackspace/storage/rackspace_storage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build none

package storage

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/rackspace/tests/rackspace_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build none

package rackspace

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/scaleio/executor/scaleio_executor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_executor libstorage_storage_executor_scaleio

package executor

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/scaleio/scaleio.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_scaleio

package scaleio

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/scaleio/storage/scaleio_storage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_scaleio

package storage

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/scaleio/tests/scaleio_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_scaleio

package scaleio

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vbox/client/vbox_client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build none

package client

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vbox/client/vbox_client_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build none

package client

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vbox/client/vbox_machine.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build none

package client

// Machine represents an installed virtual machine in vbox.
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vbox/client/vbox_soap.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build none

package client

import "encoding/xml"
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vbox/executor/vbox_executor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_executor libstorage_storage_executor_vbox

package executor

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vbox/storage/vbox_storage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_vbox

package storage

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vbox/tests/vbox_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_vbox

package vbox

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vbox/vbox.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_vbox

package vbox

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vfs/client/vfs_client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_vfs

package client

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vfs/executor/vfs_executor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_executor libstorage_storage_executor_vfs

package executor

import (
Expand Down
2 changes: 2 additions & 0 deletions drivers/storage/vfs/storage/vfs_storage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !libstorage_storage_driver libstorage_storage_driver_vfs

package storage

import (
Expand Down
Loading

0 comments on commit 0bc6b8c

Please sign in to comment.