-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
193 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
dist/ | ||
goat | ||
bin/ | ||
rpm-package/ebs/goat-ebs | ||
rpm-package/eni/goat-eni |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
VERSION:=0.4.1 | ||
VERSION:=0.5.0 | ||
GOAT_FILES?=$$(find . -name '*.go' | grep -v vendor) | ||
GOAT_NAME=$(notdir $(shell pwd)) | ||
GOAT_CMDS=$(shell find cmd/ -maxdepth 1 -mindepth 1 -type d) | ||
|
||
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: builddir deps | ||
@cd cmd/goat && go build $(DYNAMIC_FLAGS) -o ../../$(BIN_DIR)/$(GOAT_NAME) | ||
|
||
build_static: builddir deps | ||
@cd cmd/goat && go build $(STATIC_FLAGS) -o ../../$(BIN_DIR)/$(GOAT_NAME) | ||
build: deps | ||
@$(foreach cmd,$(GOAT_CMDS),\ | ||
cd $(cmd) &&\ | ||
$(STATIC_ENV) go build $(STATIC_FLAGS) \ | ||
-o ../../bin/$(notdir $(cmd)) &&\ | ||
cd - 2>&1 >/dev/null;) | ||
|
||
release: builddir deps | ||
@cd cmd/goat && go build $(RELEASE_FLAGS) -o ../../$(BIN_DIR)/$(GOAT_NAME) | ||
|
||
deps: | ||
@go get -u github.com/golang/dep/cmd/dep | ||
@dep ensure | ||
release: deps | ||
@$(foreach cmd,$(GOAT_CMDS),\ | ||
cd $(cmd) &&\ | ||
$(STATIC_ENV) go build $(RELEASE_FLAGS) \ | ||
-o ../../bin/$(notdir $(cmd)) &&\ | ||
cd - 2>&1 >/dev/null;) | ||
|
||
test: | ||
@$(foreach cmd,$(GOAT_CMDS),\ | ||
go vet ./$(cmd) &&\ | ||
go test -v ./$(cmd);) | ||
@go vet ./pkg/... | ||
@go vet ./cmd/goat/... | ||
@go test -v ./pkg/... | ||
@go test -v ./cmd/goat/... | ||
|
||
lint: lintsetup | ||
deps: | ||
@command -v dep 2>&1 >/dev/null || go get -u github.com/golang/dep/cmd/dep | ||
@dep ensure | ||
|
||
lint: | ||
@gofmt -s -w $(GOAT_FILES) | ||
@gometalinter.v2 --enable-all $(GOAT_FILES) --exclude=_test.go | ||
-gometalinter.v2 --enable-all $(GOAT_FILES) --exclude=_test.go | ||
|
||
lintsetup: | ||
@go get -u gopkg.in/alecthomas/gometalinter.v2 | ||
@gometalinter.v2 --install 2>&1 >/dev/null | ||
|
||
clean: | ||
-rm -rf build | ||
-rm -rf bin | ||
|
||
package: | ||
@GOAT_VERSION=$(VERSION) $(MAKE) -C ./centos-package/ | ||
package: release | ||
@GOAT_VERSION=$(VERSION) $(MAKE) -C ./rpm-package/ | ||
|
||
.PHONY: clean test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package ebs | ||
package main | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package eni | ||
package main | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/docopt/docopt-go" | ||
log "github.com/sirupsen/logrus" | ||
"os" | ||
) | ||
|
||
//Goat version substituted by the Makefile | ||
var VERSION string | ||
|
||
func main() { | ||
usage := `goat - ENI attach utility | ||
Usage: | ||
goat [--log-level=<log-level>] [--dry] [--debug] | ||
goat -h | --help | ||
goat --version | ||
Options: | ||
--log-level=<level> Log level (debug, info, warn, error, fatal) [default: info] | ||
--dry Dry run | ||
--debug Interactive prompts to continue between phases | ||
-h --help Show this screen. | ||
--version Show version.` | ||
arguments, _ := docopt.Parse(usage, nil, true, fmt.Sprintf("goat %s", VERSION), false) | ||
|
||
log.SetOutput(os.Stderr) | ||
logLevel := arguments["--log-level"].(string) | ||
if level, err := log.ParseLevel(logLevel); err != nil { | ||
log.Fatalf("%v", err) | ||
} else { | ||
log.SetLevel(level) | ||
} | ||
|
||
log.SetFormatter(&log.TextFormatter{}) | ||
|
||
dryRun := arguments["--dry"].(bool) | ||
debug := arguments["--debug"].(bool) | ||
|
||
log.Printf("Running goat for ENI") | ||
GoatEni(dryRun, debug) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
all: ebs eni | ||
|
||
ebs: | ||
-rpmlint ebs/specfile.spec | ||
@cd ebs && cp ../../bin/goat-ebs . &&\ | ||
rpmbuild -ba specfile.spec --define "_sourcedir $$PWD" --define "_version $$GOAT_VERSION" | ||
|
||
eni: | ||
-rpmlint eni/specfile.spec | ||
@cd eni && cp ../../bin/goat-eni . &&\ | ||
rpmbuild -ba specfile.spec --define "_sourcedir $$PWD" --define "_version $$GOAT_VERSION" | ||
|
||
.PHONY: ebs eni |
8 changes: 4 additions & 4 deletions
8
centos-package/goat@.service → rpm-package/ebs/goat-ebs.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
[Unit] | ||
Description=GOAT: EC2-%i attach utility | ||
Description=GOAT: EC2-EBS attach utility | ||
Documentation=https://github.com/sevagh/goat | ||
Requires=network.target remote-fs.target | ||
After=network.target remote-fs.target | ||
ConditionPathExists=/usr/bin/goat | ||
ConditionPathExists=/usr/bin/goat-ebs | ||
|
||
[Service] | ||
Type=oneshot | ||
User=root | ||
Group=root | ||
ExecStart=/usr/bin/goat "%i" --log-level=info | ||
SyslogIdentifier=goat | ||
ExecStart=/usr/bin/goat-ebs --log-level=info | ||
SyslogIdentifier=goat-ebs | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
%define pkgname goat-ebs | ||
|
||
Name: %{pkgname} | ||
Version: %{_version} | ||
Release: 1%{?dist} | ||
Summary: Attach and mount elastic block store volumes | ||
|
||
License: BSD 3-clause | ||
URL: https://github.com/sevagh/goat | ||
Source0: %{pkgname} | ||
Source1: %{pkgname}.service | ||
|
||
Requires: systemd mdadm | ||
|
||
|
||
%description | ||
Automatically attach AWS resources to a running EC2 instance. | ||
|
||
|
||
#%prep | ||
#%setup | ||
#%build | ||
|
||
|
||
%install | ||
%{__mkdir} -p %{buildroot}/%{_bindir} | ||
%{__mkdir} -p %{buildroot}/%{_unitdir} | ||
%{__install} -m0775 %{SOURCE0} %{buildroot}/%{_bindir}/%{pkgname} | ||
%{__install} -m0777 %{SOURCE1} %{buildroot}/%{_unitdir}/%{pkgname}.service | ||
|
||
|
||
%files | ||
%{_bindir}/%{pkgname} | ||
%{_unitdir}/%{pkgname}.service | ||
|
||
|
||
%post | ||
if [ $1 -eq 1 ]; then | ||
/bin/systemctl daemon-reload >/dev/null 2>&1 || : | ||
fi | ||
|
||
|
||
%preun | ||
if [ $1 -eq 0 ] ; then | ||
# Package removal, not upgrade | ||
/bin/systemctl disable %{pkgname}.service >/dev/null 2>&1 || : | ||
/bin/systemctl stop %{pkgname}.service >/dev/null 2>&1 || : | ||
fi | ||
|
||
|
||
%postun | ||
/bin/systemctl daemon-reload >/dev/null 2>&1 || : | ||
|
||
|
||
%changelog | ||
* Tue Mar 06 2018 Sevag Hanssian <sevag.hanssian@gmail.com> | ||
- Split subcommands into two binaries | ||
* Thu Aug 10 2017 Sevag Hanssian <sevag.hanssian@gmail.com> | ||
- Goat subcommands | ||
* Tue Jul 11 2017 Sevag Hanssian <sevag.hanssian@gmail.com> | ||
- First RPM package for goat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=GOAT: EC2-ENI attach utility | ||
Documentation=https://github.com/sevagh/goat | ||
Requires=network.target remote-fs.target | ||
After=network.target remote-fs.target | ||
ConditionPathExists=/usr/bin/goat-eni | ||
|
||
[Service] | ||
Type=oneshot | ||
User=root | ||
Group=root | ||
ExecStart=/usr/bin/goat-eni --log-level=info | ||
SyslogIdentifier=goat-eni | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
Oops, something went wrong.