Skip to content

Commit

Permalink
2018 overhaul
Browse files Browse the repository at this point in the history
* Refactor to pkg/cmd convention
* Add static compilation flags
  • Loading branch information
sevagh committed Mar 5, 2018
1 parent e67304a commit 3efc37b
Show file tree
Hide file tree
Showing 29 changed files with 59 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
dist/
goat
43 changes: 43 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
VERSION:=0.4.0
GOAT_FILES?=$$(find . -name '*.go' | grep -v vendor)
GOAT_NAME=$(notdir $(shell pwd))

STATIC_ENV:=CGO_ENABLED=0 GOOS=linux GOARCH=amd64
STATIC_FLAGS:=-a -tags netgo -ldflags '-extldflags "-static" -X main.VERSION=$(VERSION)'
RELEASE_FLAGS:=-a -tags netgo -ldflags '-w -extldflags "-static" -X main.VERSION=$(VERSION)'

DIST_DIR=dist/
BIN_DIR=dist/bin

all: build_static

builddir:
@mkdir -p $(DIST_DIR) $(BIN_DIR)

build:
@cd cmd/goat && go build $(DYNAMIC_FLAGS) -o ../../$(BIN_DIR)/$(GOAT_NAME)

build_static: builddir
@cd cmd/goat && go build $(STATIC_FLAGS) -o ../../$(BIN_DIR)/$(GOAT_NAME)

release: builddir
@cd cmd/goat && go build $(RELEASE_FLAGS) -o ../../$(BIN_DIR)/$(GOAT_NAME)

deps:
@go get -u github.com/golang/dep
@dep ensure

test: build lint
@go vet .
@go test -v ./...

lint:
@gofmt -s -w $(GOAT_FILES)

clean:
-rm -rf build

package:
@GOAT_VERSION=$(VERSION) $(MAKE) -C ./centos-package/

.PHONY: clean test
22 changes: 0 additions & 22 deletions Makefile

This file was deleted.

1 change: 1 addition & 0 deletions centos-package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./goat
2 changes: 1 addition & 1 deletion .pkg/Makefile → centos-package/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rpm:
@make -C ../ build && cp ../goat ./
@make -C ../ release && cp ../dist/bin/goat ./
@rpmlint specfile.spec
@rpmbuild -ba specfile.spec --define "_sourcedir $$PWD" --define "_version $$GOAT_VERSION"
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions main.go → cmd/goat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
log "github.com/sirupsen/logrus"
"os"

"github.com/sevagh/goat/commands/ebs"
"github.com/sevagh/goat/commands/eni"
"github.com/sevagh/goat/pkg/commands/ebs"
"github.com/sevagh/goat/pkg/commands/eni"
)

//Goat version substituted by the Makefile
Expand Down
2 changes: 1 addition & 1 deletion awsutil/attach.go → pkg/awsutil/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
log "github.com/sirupsen/logrus"

"github.com/sevagh/goat/driveutil"
"github.com/sevagh/goat/pkg/driveutil"
)

//AttachEbsVolumes attaches the given map of {'VolumeName':[]EbsVol} with the EC2 client in the provided ec2Instance
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions commands/ebs/ebs.go → pkg/commands/ebs/ebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
log "github.com/sirupsen/logrus"
"os"

"github.com/sevagh/goat/awsutil"
"github.com/sevagh/goat/driveutil"
"github.com/sevagh/goat/fsutil"
"github.com/sevagh/goat/raidutil"
"github.com/sevagh/goat/pkg/awsutil"
"github.com/sevagh/goat/pkg/driveutil"
"github.com/sevagh/goat/pkg/fsutil"
"github.com/sevagh/goat/pkg/raidutil"
)

//GoatEbs runs Goat for your EBS volumes - attach, mount, mkfs, etc.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion commands/eni/eni.go → pkg/commands/eni/eni.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
log "github.com/sirupsen/logrus"
"os"

"github.com/sevagh/goat/awsutil"
"github.com/sevagh/goat/pkg/awsutil"
)

//GoatEni runs Goat for your ENIs - attach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package driveutil
import (
"time"

"github.com/sevagh/goat/execute"
"github.com/sevagh/goat/pkg/execute"
)

//DoesDriveExistWithTimeout makes 10 attempts, 2 second sleep between each, to stat a drive to check for its existence
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion fsutil/filesystem.go → pkg/fsutil/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
log "github.com/sirupsen/logrus"

"github.com/sevagh/goat/execute"
"github.com/sevagh/goat/pkg/execute"
)

//CheckFilesystem checks for a filesystem on a given drive using blkid. It returns ok if there is no filesystem or the filesystem is the correct type. Error if there's a different filesystem
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion fsutil/mount.go → pkg/fsutil/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"strings"

"github.com/sevagh/goat/execute"
"github.com/sevagh/goat/pkg/execute"
)

//Mount calls mount with no parameters. It relies on there being a correct fstab entry on the provided mountpoint. In the case of a dryRun it doesn't actually execute it, just logs what it would have executed
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions raidutil/raid.go → pkg/raidutil/raid.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"
"strconv"

"github.com/sevagh/goat/driveutil"
"github.com/sevagh/goat/execute"
"github.com/sevagh/goat/pkg/driveutil"
"github.com/sevagh/goat/pkg/execute"
)

//CreateRaidArray runs the appropriate mdadm command for the given list of EbsVol that should be raided together. It takes dryRun as a boolean, where it tells you which mdadm it would have run
Expand Down
File renamed without changes.

0 comments on commit 3efc37b

Please sign in to comment.