-
Notifications
You must be signed in to change notification settings - Fork 0
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
8 changed files
with
122 additions
and
4 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
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 +1 @@ | ||
build | ||
dists |
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 @@ | ||
GO ?= go | ||
GOFMT ?= $(GO)fmt | ||
|
||
VERSION ?= $(shell cat VERSION) | ||
GIT_BRANCH ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) | ||
GIT_COMMIT ?= $(shell git rev-parse HEAD) | ||
USER ?= $(shell echo $USER) | ||
DATE ?= $(shell echo `date`) | ||
|
||
APP_BIN ?= dists/aws-dynamodb-cache-lambda-extension | ||
APP_SRC ?= main.go | ||
|
||
|
||
.PHONY: build | ||
build: go-vet | ||
@echo ">> building binary file" | ||
@go build \ | ||
-ldflags "-X 'github.com/nthienan/aws-dynamodb-cache-lambda-extension/internal/version.Version=$(VERSION)' \ | ||
-X 'github.com/nthienan/aws-dynamodb-cache-lambda-extension/internal/version.Revision=$(GIT_COMMIT)' \ | ||
-X 'github.com/nthienan/aws-dynamodb-cache-lambda-extension/internal/version.Branch=$(GIT_BRANCH)' \ | ||
-X 'github.com/nthienan/aws-dynamodb-cache-lambda-extension/internal/version.BuildUser=$(USER)' \ | ||
-X 'github.com/nthienan/aws-dynamodb-cache-lambda-extension/internal/version.BuildDate=$(DATE)'" \ | ||
-o $(APP_BIN) $(APP_SRC) | ||
|
||
|
||
.PHONY: go-run | ||
go-run: go-vet | ||
@go run $(APP_SRC) | ||
|
||
|
||
.PHONY: go-fmt | ||
go-fmt: | ||
@echo ">> checking code style" | ||
@fmtRes=$$($(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print)); \ | ||
if [ -n "$${fmtRes}" ]; then \ | ||
echo "go fmt checking failed!"; echo "$${fmtRes}"; echo; \ | ||
exit 1; \ | ||
fi | ||
|
||
|
||
.PHONY: go-vet | ||
go-vet: | ||
@echo ">> vetting code" | ||
$(GO) vet $(GOOPTS) ./... |
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 @@ | ||
0.2.0 |
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,11 +1,17 @@ | ||
module github.com/nthienan/aws-dynamodb-cache-lambda-extension | ||
|
||
go 1.19 | ||
go 1.20 | ||
|
||
require ( | ||
github.com/aws/aws-sdk-go v1.44.239 | ||
github.com/gorilla/mux v1.8.0 | ||
gopkg.in/yaml.v2 v2.4.0 | ||
) | ||
|
||
require github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
require ( | ||
github.com/alecthomas/kingpin/v2 v2.3.2 // indirect | ||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect | ||
) |
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 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,48 @@ | ||
package version | ||
|
||
import ( | ||
"bytes" | ||
"runtime" | ||
"strings" | ||
"text/template" | ||
) | ||
|
||
var ( | ||
Version string | ||
Revision string | ||
Branch string | ||
BuildUser string | ||
BuildDate string | ||
GoVersion = runtime.Version() | ||
GoOS = runtime.GOOS | ||
GoArch = runtime.GOARCH | ||
) | ||
|
||
func Print(program string) string { | ||
var versionTemplate = ` | ||
{{.program}}, version: {{.version}} (branch: {{.branch}}, revision: {{.revision}}) | ||
build user: {{.buildUser}} | ||
build date: {{.buildDate}} | ||
go version: {{.goVersion}} | ||
platform: {{.platform}} | ||
` | ||
|
||
m := map[string]string{ | ||
"program": program, | ||
"version": Version, | ||
"branch": Branch, | ||
"revision": Revision, | ||
"buildUser": BuildUser, | ||
"buildDate": BuildDate, | ||
"goVersion": GoVersion, | ||
"platform": GoOS + "/" + GoArch, | ||
} | ||
|
||
t := template.Must(template.New("version").Parse(versionTemplate)) | ||
var buffer bytes.Buffer | ||
if err := t.ExecuteTemplate(&buffer, "version", m); err != nil { | ||
panic(err) | ||
} | ||
|
||
return strings.TrimSpace(buffer.String()) | ||
} |
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