Skip to content

Commit

Permalink
Merge pull request #77 from justenwalker/godeps
Browse files Browse the repository at this point in the history
Add support for godep
  • Loading branch information
tgross committed Feb 18, 2016
2 parents 0c7673d + 4ae8cb3 commit 3062e5b
Show file tree
Hide file tree
Showing 23 changed files with 120 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ _testmain.go
build/
release/
cover/
/vendor/
/Godeps/_workspace/
examples/**/opt/containerbuddy/containerbuddy
*.tar.gz
.godeps
Expand Down
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ services:
## Need docker-compose 1.5.x for Variable Interpolation
env:
DOCKER_COMPOSE_VERSION: 1.5.2
GO15VENDOREXPERIMENT: 1

before_install:
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin

install:
- make vendor

script:
- make clean lint build
- make lint build
- make test
- make integration
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM golang

RUN go get -u github.com/golang/lint/golint
RUN go get github.com/golang/lint/golint \
&& go get github.com/tools/godep

ENV CGO_ENABLED 0
ENV GO15VENDOREXPERIMENT 1
ENTRYPOINT ["make"]
52 changes: 52 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Godeps/Readme

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 17 additions & 21 deletions Makefile.docker
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,31 @@ SHELL := /bin/bash
.SHELLFLAGS = -o pipefail -euc
.DEFAULT_GOAL := build

.PHONY: all build check test cover
.PHONY: all build check test cover update-deps vendor

CONSUL_REF := 158eabdd6f2408067c1d7656fa10e49434f96480
ETCD_REF := release-2.2

ROOT := /go
CDWD := cd ${ROOT}/src/containerbuddy
PACKAGE := github.com/joyent/containerbuddy
SRC := /go/src/${PACKAGE}
CDWD := cd ${SRC}
NO_VENDOR:= $(shell cd ${SRC} && go list ./... | grep -v /vendor/)
GO15VENDOREXPERIMENT := 1
export GO15VENDOREXPERIMENT

all: build cover

build: /go/src/github.com
${CDWD} && go build -a -o /build/containerbuddy -ldflags "$(LDFLAGS)"
chmod 755 /build/containerbuddy
vendor:
${CDWD} && godep restore

/go/src/github.com:
mkdir -p "${ROOT}/src/github.com/hashicorp"
git clone https://github.com/hashicorp/consul.git ${ROOT}/src/github.com/hashicorp/consul
cd ${ROOT}/src/github.com/hashicorp/consul && git checkout ${CONSUL_REF}
mkdir -p "${ROOT}/src/github.com/coreos"
git clone https://github.com/coreos/etcd.git ${ROOT}/src/github.com/coreos/etcd
cd ${ROOT}/src/github.com/coreos/etcd && git checkout ${ETCD_REF}
build: vendor
${CDWD} && go build -a -o /build/containerbuddy -ldflags "$(LDFLAGS)" ./
chmod 755 /build/containerbuddy

lint:
${CDWD} && go vet
${CDWD} && go fmt
golint ${ROOT}/src/containerbuddy
${CDWD} && go vet ${NO_VENDOR}
${CDWD} && go fmt ${NO_VENDOR}
golint ${SRC}

test: /go/src/github.com
${CDWD} && go test -v -coverprofile=/cover/coverage.out
test:
${CDWD} && go test -v -coverprofile=/cover/coverage.out ./containerbuddy

cover: test
go tool cover -html=/cover/coverage.out -o /cover/coverage.html
2 changes: 1 addition & 1 deletion src/containerbuddy/config.go → containerbuddy/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"bufio"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion src/containerbuddy/consul.go → containerbuddy/consul.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

// DiscoveryService is an interface
// which all service discovery backends must implement
Expand Down
4 changes: 2 additions & 2 deletions src/containerbuddy/etcd.go → containerbuddy/etcd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"fmt"
Expand All @@ -8,8 +8,8 @@ import (

"encoding/json"

"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
"github.com/coreos/etcd/client"
"golang.org/x/net/context"
)

// Etcd is a service discovery backend for CoreOS etcd
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion src/containerbuddy/ips.go → containerbuddy/ips.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"encoding/json"
Expand Down
5 changes: 3 additions & 2 deletions src/containerbuddy/main.go → containerbuddy/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"flag"
Expand All @@ -10,7 +10,8 @@ import (
"time"
)

func main() {
// Main executes the containerbuddy CLI
func Main() {
// make sure we use only a single CPU so as not to cause
// contention on the main application
runtime.GOMAXPROCS(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"log"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"flag"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package containerbuddy

import (
"reflect"
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/joyent/containerbuddy/containerbuddy"

func main() {
containerbuddy.Main()
}
15 changes: 11 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ SHELL := /bin/bash
.PHONY: clean test integration consul etcd run-consul run-etcd example example-consul example-etcd ship dockerfile docker cover lint

VERSION ?= dev-build-not-for-release
LDFLAGS := '-X main.GitHash=$(shell git rev-parse --short HEAD) -X main.Version=${VERSION}'
LDFLAGS := '-X containerbuddy.GitHash=$(shell git rev-parse --short HEAD) -X containerbuddy.Version=${VERSION}'

ROOT := $(shell pwd)
PACKAGE := github.com/joyent/containerbuddy
GO15VENDOREXPERIMENT := 1
export GO15VENDOREXPERIMENT

COMPOSE_PREFIX_ETCD := exetcd
COMPOSE_PREFIX_CONSUL := exconsul


DOCKERMAKE := docker run --rm \
--link containerbuddy_consul:consul \
--link containerbuddy_etcd:etcd \
-v ${ROOT}/src/containerbuddy:/go/src/containerbuddy \
-v ${ROOT}/.godeps:/go/src \
-v ${ROOT}/vendor:/go/src \
-v ${ROOT}:/go/src/${PACKAGE} \
-v ${ROOT}/build:/build \
-v ${ROOT}/cover:/cover \
-v ${ROOT}/examples:/root/examples:ro \
Expand All @@ -26,7 +30,7 @@ DOCKERMAKE := docker run --rm \
containerbuddy_build

clean:
rm -rf build release cover .godeps
rm -rf build release cover vendor
docker rmi -f containerbuddy_build > /dev/null 2>&1 || true
docker rm -f containerbuddy_consul > /dev/null 2>&1 || true
docker rm -f containerbuddy_etcd > /dev/null 2>&1 || true
Expand All @@ -46,6 +50,9 @@ docker: build/containerbuddy_build consul etcd
build: docker
${DOCKERMAKE} build

vendor: docker
${DOCKERMAKE} vendor

# ----------------------------------------------
# develop and test

Expand Down

0 comments on commit 3062e5b

Please sign in to comment.