diff --git a/Makefile b/Makefile index 54e7fbd..65f2863 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ - NAME=vault-sync AUTHOR=Orange REGISTRY=docker.io +IMPORT_PATH=github.com/fcantournet/vault-sync HARDWARE=$(shell uname -m) -VERSION=$(shell git describe --tags --always') +VERSION=$(shell git describe --tags --always) VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr .PHONY: test authors changelog build docker static release lint cover vet @@ -13,61 +13,25 @@ default: build build: @echo "--> Compiling the project" mkdir -p bin - ${GODEPS} go build -o bin/${NAME} cmd/${NAME}/*.go + go build -o bin/${NAME} ./cmd static: @echo "--> Compiling the static binary" mkdir -p bin - CGO_ENABLED=0 GOOS=linux ${GODEPS} go build -a -tags netgo -ldflags '-w' -o bin/${NAME} cmd/${NAME}/*.go + CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags '-w' -o bin/${NAME} ./cmd docker-build: @echo "--> Compiling the project" - sudo docker run --rm -v ${ROOT_DIR}:/go/src/github.com/UKHomeOffice/${NAME} \ - -w /go/src/github.com/UKHomeOffice/${NAME}/ -e GOOS=linux golang:${GOVERSION} make static - -docker: static - @echo "--> Building the docker image" - sudo docker build -t ${REGISTRY}/${AUTHOR}/${NAME}:${VERSION} . - -release: static - mkdir -p release - gzip -c bin/${NAME} > release/${NAME}_${VERSION}_linux_${HARDWARE}.gz - rm -f release/${NAME} - -clean: - rm -rf ./bin 2>/dev/null - rm -rf ./release 2>/dev/null + docker run --rm -v ${ROOT_DIR}:/go/src/${IMPORT_PATH} \ + -w /go/src/${IMPORT_PATH}/ -e GOOS=linux golang:${GOVERSION} make static authors: @echo "--> Updating the AUTHORS" git log --format='%aN <%aE>' | sort -u > AUTHORS -vet: - @echo "--> Running go vet $(VETARGS) ." - @go tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \ - go get golang.org/x/tools/cmd/vet; \ - fi - @go tool vet $(VETARGS) ./.. - -lint: - @echo "--> Running golint" - @which golint 2>/dev/null ; if [ $$? -eq 1 ]; then \ - go get -u github.com/golang/lint/golint; \ - fi - @golint . - -format: - @echo "--> Running go fmt" - @go fmt $(PACKAGES) - -cover: - @echo "--> Running go cover" - @go test --cover ${PACKAGES} - test: deps @echo "--> Running the tests" - ${GODEPS} go test -v ${PACKAGES} - @$(MAKE) cover + go test -v $(glide nv) changelog: release git log $(shell git tag | tail -n1)..HEAD --no-merges --format=%B > changelog diff --git a/cmd/app.go b/cmd/app.go index e1bcc45..4e5b4a9 100644 --- a/cmd/app.go +++ b/cmd/app.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,7 +23,7 @@ import ( "github.com/codegangsta/cli" ) -func newVaultCtl() *cli.App { +func NewVaultCtl() *cli.App { // step: create and return the application app := cli.NewApp() app.Usage = "is a utility for provisioning a hashicorp's vault service" diff --git a/cmd/doc.go b/cmd/doc.go index 660911f..1f2e8f4 100644 --- a/cmd/doc.go +++ b/cmd/doc.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import "github.com/fcantournet/vault-sync/pkg/api" diff --git a/cmd/sync.go b/cmd/sync.go index 745b7fe..5aed791 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/transit.go b/cmd/transit.go index 113ad10..a102613 100644 --- a/cmd/transit.go +++ b/cmd/transit.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/cmd/util.go b/cmd/util.go index 9a577f0..6f1d051 100644 --- a/cmd/util.go +++ b/cmd/util.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/main.go b/main.go similarity index 87% rename from cmd/main.go rename to main.go index 7dbe0fa..5caa7c0 100644 --- a/cmd/main.go +++ b/main.go @@ -15,9 +15,13 @@ limitations under the License. package main -import "os" +import ( + "os" + + "github.com/fcantournet/vault-sync/cmd" +) func main() { - app := newVaultCtl() + app := cmd.NewVaultCtl() app.Run(os.Args) } diff --git a/pkg/api/validate_test.go b/pkg/api/validate_test.go index 592bf87..0daeddd 100644 --- a/pkg/api/validate_test.go +++ b/pkg/api/validate_test.go @@ -30,12 +30,12 @@ func TestUserIsValid(t *testing.T) { User: &User{}, }, { - User: &User{UserPass: &UserCredentials{ + User: &User{UserPass: &UserPass{ Username: "test", }}, }, { - User: &User{UserPass: &UserCredentials{ + User: &User{UserPass: &UserPass{ Username: "test", Password: "password", }}, @@ -43,7 +43,7 @@ func TestUserIsValid(t *testing.T) { }, { User: &User{ - UserPass: &UserCredentials{Username: "test", Password: "pass"}, + UserPass: &UserPass{Username: "test", Password: "pass"}, Policies: []string{"pol"}, }, Ok: true,