Skip to content

Commit

Permalink
Fix MakeFile to work without godep
Browse files Browse the repository at this point in the history
Some test still panic...

Signed-off-by: Félix Cantournet <[email protected]>
  • Loading branch information
Félix Cantournet committed Jan 4, 2017
1 parent 286abc8 commit af21ad6
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 54 deletions.
50 changes: 7 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package main
package cmd

import (
"fmt"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cmd/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package main
package cmd

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/transit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package main
package cmd

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package main
package cmd

import (
"fmt"
Expand Down
8 changes: 6 additions & 2 deletions cmd/main.go → main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions pkg/api/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ 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",
}},
Ok: true,
},
{
User: &User{
UserPass: &UserCredentials{Username: "test", Password: "pass"},
UserPass: &UserPass{Username: "test", Password: "pass"},
Policies: []string{"pol"},
},
Ok: true,
Expand Down

0 comments on commit af21ad6

Please sign in to comment.