Skip to content

Commit

Permalink
Replace dep manager & fix dep issues, add makefile, improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonog committed Mar 15, 2017
1 parent 5a6a85c commit 1d6ad2b
Show file tree
Hide file tree
Showing 11 changed files with 317 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ redalert
notes
config.json
*.rice-box.go
Godeps/_workspace
vendor
*.exe
44 changes: 0 additions & 44 deletions Godeps/Godeps.json

This file was deleted.

5 changes: 0 additions & 5 deletions Godeps/Readme

This file was deleted.

40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
BINARY=redalert

VERSION=0.2.1
BUILD=`git rev-parse HEAD`

LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"

build: build-static
go build ${LDFLAGS} -o ${BINARY}

build-static:
go get github.com/GeertJohan/go.rice
go get github.com/GeertJohan/go.rice/rice
cd web && rice embed-go && cd ..

build-proto:
protoc -I servicepb/ servicepb/service.proto --go_out=plugins=grpc:servicepb

clean:
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi

test-deps:
docker pull sickp/alpine-sshd
docker pull postgres

test:
go test -v -race $(shell glide novendor)

build-docker-image-local: build-static
docker run --rm \
-v "$(shell pwd):/src" \
-v /var/run/docker.sock:/var/run/docker.sock \
centurylink/golang-builder \
jonog/redalert

build-docker-image-remote: build-docker-image-local
docker tag jonog/redalert jonog/redalert:v${VERSION}
docker push jonog/redalert

.PHONY: build-static build-proto clean test-deps test build-docker-image build-docker-image-remote
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,25 +469,11 @@ If there are errors sending email via gmail - enable `Access for less secure app
### Development

#### Setup
Getting started:
```
go get github.com/tools/godep
```

Embedding static web files:
```
go get github.com/GeertJohan/go.rice
go get github.com/GeertJohan/go.rice/rice
cd web && rice embed-go && cd ..
```

#### Dockerizing Redalert
```
docker run --rm \
-v "$(pwd):/src" \
-v /var/run/docker.sock:/var/run/docker.sock \
centurylink/golang-builder
```
Dependencies:
* Go dependency manager - [glide](https://github.com/Masterminds/glide)
* Embedding static assets into binary - [go.rice](https://github.com/GeertJohan/go.rice)
* `protoc` for gRPC code generation - [gRPC](http://www.grpc.io/docs/quickstart/go.html)
* Docker-machine for tests

### Credits
Rocket emoji via https://github.com/twitter/twemoji
Expand Down
3 changes: 2 additions & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"

"github.com/jonog/redalert/utils"
"github.com/spf13/cobra"
)

Expand All @@ -11,7 +12,7 @@ var versionCmd = &cobra.Command{
Short: "Print the version number of Redalert",
Long: "Print the version number of Redalert",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Redalert v0.2.0")
fmt.Println("Redalert v" + utils.Version() + " sha: " + utils.Build())
},
}

Expand Down
126 changes: 126 additions & 0 deletions glide.lock

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

36 changes: 36 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package: github.com/jonog/redalert
import:
- package: github.com/GeertJohan/go.rice
- package: github.com/docker/engine-api
version: ^0.4.0
subpackages:
- client
- types
- package: github.com/fatih/color
version: ^1.4.1
- package: github.com/golang/protobuf
subpackages:
- proto
- package: github.com/gorilla/mux
version: ^1.3.0
- package: github.com/jmoiron/jsonq
- package: github.com/lib/pq
- package: github.com/olekukonko/tablewriter
- package: github.com/rs/cors
version: ^1.0.0
- package: github.com/spf13/cobra
- package: golang.org/x/crypto
subpackages:
- ssh
- ssh/agent
- package: golang.org/x/net
subpackages:
- context
- package: google.golang.org/grpc
version: ^1.0.5
- package: gopkg.in/gorp.v1
testImport:
- package: github.com/docker/go-connections
subpackages:
- nat
- package: github.com/nu7hatch/gouuid
11 changes: 10 additions & 1 deletion redalert.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package main // import "github.com/jonog/redalert"

import "github.com/jonog/redalert/cmd"
import (
"github.com/jonog/redalert/cmd"
"github.com/jonog/redalert/utils"
)

var (
Version string
Build string
)

func main() {
utils.RegisterVersionAndBuild(Version, Build)
cmd.Execute()
}
Loading

0 comments on commit 1d6ad2b

Please sign in to comment.