restructure to build individual binaries

This commit is contained in:
Michael Hobbs
2017-01-14 20:22:37 -08:00
parent e61475c7ea
commit fc31b28ab6
8 changed files with 30 additions and 43 deletions

2
plugins/repo/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/commands
/subcommands/*

View File

@@ -1,5 +1,8 @@
.PHONY: build-in-docker build clean
GO_REPO_ROOT ?= /go/src/github.com/dokku/dokku
BUILD_IMAGE ?= golang:1.7.1
build-in-docker: clean
docker run --rm \
-v $$PWD/../..:$(GO_REPO_ROOT) \
@@ -7,8 +10,17 @@ build-in-docker: clean
$(BUILD_IMAGE) \
bash -c "make build" || exit $$?
build:
cd src && go build -a -o ../commands
build: commands subcommands
subcommands: subcommands/gc subcommands/purge-cache
commands: **/**/commands.go
go build -a -o commands src/commands/commands.go
subcommands/gc: **/**/**/gc.go
go build -a -o subcommands/gc src/subcommands/gc/gc.go
subcommands/purge-cache: **/**/**/purge-cache.go
go build -a -o subcommands/purge-cache src/subcommands/purge-cache/purge-cache.go
clean:
rm -f commands
rm -rf commands subcommands

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
[[ " help repo:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/repo/internal-functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | repo:help)
repo_help_cmd "$@"
;;
*)
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
;;
esac

View File

@@ -33,10 +33,6 @@ func main() {
usage()
case "help":
fmt.Print(helpContent)
case "repo:gc":
gitGC()
case "repo:purge-cache":
purgeCache()
default:
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))
if err != nil {

View File

@@ -8,7 +8,7 @@ import (
)
// runs 'git gc --aggressive' against the application's repo
func gitGC() {
func main() {
flag.Parse()
appName := flag.Arg(1)
if appName == "" {

View File

@@ -9,7 +9,7 @@ import (
)
// deletes the contents of the build cache stored in the repository
func purgeCache() {
func main() {
flag.Parse()
appName := flag.Arg(1)
if appName == "" {

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
repo_gc() {
declare desc="runs 'git gc --aggressive' against the application's repo"
local cmd="repo:gc"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
local APP="$2"; local APP_DIR="$DOKKU_ROOT/$APP"
verify_app_name "$APP"
GIT_DIR="$APP_DIR" git gc --aggressive
}
repo_gc "$@"