Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelo Correia committed Aug 2, 2018
2 parents 84ebc38 + 362d1fc commit 16fdf75
Show file tree
Hide file tree
Showing 17 changed files with 460 additions and 245 deletions.
97 changes: 64 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
include env.mk pipeline.mk go.mk
APP_NAME := go-template-engine
GITHUB_USER := marcelocorreia
GOARCH :=amd64
GOOS := darwin
GOPATH := /go
NAMESPACE := github.com/marcelocorreia
OUTPUT_FILE := ./bin/$(APP_NAME)
REPO_NAME := $(APP_NAME)
REPO_URL := [email protected]:$(GITHUB_USER)/$(APP_NAME).git
TEST_OUTPUT_DIR := tmp
#VERSION := $(shell make get-last-release)
WORKDIR := $(GOPATH)/src/$(NAMESPACE)/$(REPO_NAME)
HOMEBREW_REPO := [email protected]:marcelocorreia/homebrew-taps.git
HOMEBREW_BINARY := dist/$(APP_NAME)-darwin-amd64-$(VERSION).zip
#HOMEBREW_BINARY_SUM := $(shell shasum -a 256 $(HOMEBREW_BINARY) | awk '{print $$1}')
HOMEBREW_REPO_PATH ?= /Users/marcelo/IdeaProjects/tardis/homebrew-taps
DOCS_DIR := docs

include go.mk



pipeline:
fly -t main set-pipeline \
-n -p $(APP_NAME) \
-c ./ci/pipeline.yml \
-l $(HOME)/.ssh/ci-credentials.yml \
-l ci/properties.yml

fly -t main unpause-pipeline -p $(APP_NAME)
.PHONY: pipeline

test-full: clean_docs _docs-check cover-tests cover-out cover-html cover-cleanup

Expand All @@ -20,7 +50,7 @@ build:
$(call build,GOOS=$(GOOS) GOARCH=$(GOARCH),$(APP_NAME))

define build
$1 go build -o ./bin/$(APP_NAME) -ldflags "-X main.VERSION=dev" -v
$1 go build -o ./bin/$(APP_NAME) -ldflags "-X main.VERSION=dev-mc2" -v ./main.go
endef

_validate-version:
Expand All @@ -38,14 +68,6 @@ GITHUB_USER := marcelocorreia
get-last-release:
@curl -s https://api.github.com/repos/$(GITHUB_USER)/$(APP_NAME)/tags | jq ".[]|.name" | head -n1 | sed 's/\"//g' | sed 's/v*//g'

homebrew-tap:
go-template-engine \
--source ci/go-template-engine.rb \
--var dist_file=dist/go-template-engine-darwin-amd64-1.39.0.zip \
--var version=1.39.0 \
--var hash_sum=123 \
> /Users/marcelo/IdeaProjects/tardis/homebrew-taps/go-template-engine.rb


get-version:
@git checkout origin/version -- version && \
Expand All @@ -55,34 +77,43 @@ get-version:
_docs-check:
@[ -f $(DOCS_DIR) ] && echo $(DOCS_DIR) folder found || mkdir -p $(DOCS_DIR)

concourse-pull:
cd ci && docker-compose pull
concourse-up:
cd ci && CONCOURSE_EXTERNAL_URL=http://localhost:8080 docker-compose up -d

concourse-down:
cd ci && docker-compose down
_validate-app-name:
ifndef APP_NAME
$(error APP_NAME is required)
endif

concourse-stop:
cd ci && docker-compose stop
update_brew: _validate-app-name
./update-brew.sh $(APP_NAME)

concourse-start:
cd ci && docker-compose start
git-push:
git add . ; git commit -m "updating pipeline"; git push

concourse-logs:
cd ci && docker-compose logs -f
pipeline-full: git-push pipeline

concourse-keys:
@[ -f ./ci/keys ] && echo ./ci/keys folder found || $(call create-concourse-keys)
_prepare:
@echo $(GOPATH) - $(shell pwd)
@mkdir -p /go/src/$(NAMESPACE)/$(APP_NAME)/dist
@cp -R * /go/src/$(NAMESPACE)/$(APP_NAME)/
@$(call ci_make,deps)

define create-concourse-keys
echo "Creating Concourse keys"
mkdir -p ./ci/keys/web ./ci/keys/worker;
ssh-keygen -t rsa -f ./ci/keys/web/tsa_host_key -N ''
ssh-keygen -t rsa -f ./ci/keys/web/session_signing_key -N ''
ssh-keygen -t rsa -f ./ci/keys/worker/worker_key -N ''
cp ./ci/keys/worker/worker_key.pub ./ci/keys/web/authorized_worker_keys
cp ./ci/keys/web/tsa_host_key.pub ./ci/keys/worker
endef
_build:
@$(call ci_make,lint build GOOS=linux)

_test:
@$(call ci_make, test GOOS=linux)

_release: _validate-version
@$(call ci_make,release)
pwd
cp $(GOPATH)/src/$(NAMESPACE)/$(APP_NAME)/dist/*zip ../output/

define ci_make
echo ""
echo "*** $1::Begin ***"
cd $(GOPATH)/src/$(NAMESPACE)/$(APP_NAME) && \
make $1
echo "*** $1::End ***"
echo ""
cd -
endef
146 changes: 144 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Based on Golang templates text SDK.

## TLDR;

- Added support to [HCL](https://github.com/hashicorp/hcl) formart for variables file input
- Added support to all [Masterminds Sprig](https://github.com/Masterminds/sprig) functions
- Added static file include. Tag {{staticInclude "path/to/file.txt"}}
- Added replace tag. Tag {{replace .var "FROM_THIS" "TO_THIS"}}
- Accepts JSON and YAML variables files
Expand All @@ -19,6 +20,146 @@ Based on Golang templates text SDK.
- Can be extended
- ```$> go get github.com/marcelocorreia/go-template-engine/template-engine```

### Custom functions
|Function|Source|Desc|
|--------|------|----|
|abbrev|[spring](https://github.com/Masterminds/sprig)|na|
|abbrevboth|[spring](https://github.com/Masterminds/sprig)|na|
|add|[spring](https://github.com/Masterminds/sprig)|na|
|add1|[spring](https://github.com/Masterminds/sprig)|na|
|ago|[spring](https://github.com/Masterminds/sprig)|na|
|append|[spring](https://github.com/Masterminds/sprig)|na|
|atoi|[spring](https://github.com/Masterminds/sprig)|na|
|b32dec|[spring](https://github.com/Masterminds/sprig)|na|
|b32enc|[spring](https://github.com/Masterminds/sprig)|na|
|b64dec|[spring](https://github.com/Masterminds/sprig)|na|
|b64enc|[spring](https://github.com/Masterminds/sprig)|na|
|base|[spring](https://github.com/Masterminds/sprig)|na|
|biggest|[spring](https://github.com/Masterminds/sprig)|na|
|buildCustomCert|[spring](https://github.com/Masterminds/sprig)|na|
|camelcase|[spring](https://github.com/Masterminds/sprig)|na|
|cat|[spring](https://github.com/Masterminds/sprig)|na|
|ceil|[spring](https://github.com/Masterminds/sprig)|na|
|clean|[spring](https://github.com/Masterminds/sprig)|na|
|coalesce|[spring](https://github.com/Masterminds/sprig)|na|
|compact|[spring](https://github.com/Masterminds/sprig)|na|
|contains|[spring](https://github.com/Masterminds/sprig)|na|
|date|[spring](https://github.com/Masterminds/sprig)|na|
|dateInZone|[spring](https://github.com/Masterminds/sprig)|na|
|dateModify|[spring](https://github.com/Masterminds/sprig)|na|
|date_in_zone|[spring](https://github.com/Masterminds/sprig)|na|
|date_modify|[spring](https://github.com/Masterminds/sprig)|na|
|default|[spring](https://github.com/Masterminds/sprig)|na|
|derivePassword|[spring](https://github.com/Masterminds/sprig)|na|
|dict|[spring](https://github.com/Masterminds/sprig)|na|
|dir|[spring](https://github.com/Masterminds/sprig)|na|
|div|[spring](https://github.com/Masterminds/sprig)|na|
|empty|[spring](https://github.com/Masterminds/sprig)|na|
|env|[spring](https://github.com/Masterminds/sprig)|na|
|expandenv|[spring](https://github.com/Masterminds/sprig)|na|
|ext|[spring](https://github.com/Masterminds/sprig)|na|
|fail|[spring](https://github.com/Masterminds/sprig)|na|
|first|[spring](https://github.com/Masterminds/sprig)|na|
|float64|[spring](https://github.com/Masterminds/sprig)|na|
|floor|[spring](https://github.com/Masterminds/sprig)|na|
|genCA|[spring](https://github.com/Masterminds/sprig)|na|
|genPrivateKey|[spring](https://github.com/Masterminds/sprig)|na|
|genSelfSignedCert|[spring](https://github.com/Masterminds/sprig)|na|
|genSignedCert|[spring](https://github.com/Masterminds/sprig)|na|
|has|[spring](https://github.com/Masterminds/sprig)|na|
|hasKey|[spring](https://github.com/Masterminds/sprig)|na|
|hasPrefix|[spring](https://github.com/Masterminds/sprig)|na|
|hasSuffix|[spring](https://github.com/Masterminds/sprig)|na|
|hello|[spring](https://github.com/Masterminds/sprig)|na|
|htmlDate|[spring](https://github.com/Masterminds/sprig)|na|
|htmlDateInZone|[spring](https://github.com/Masterminds/sprig)|na|
|indent|[spring](https://github.com/Masterminds/sprig)|na|
|initial|[spring](https://github.com/Masterminds/sprig)|na|
|initials|[spring](https://github.com/Masterminds/sprig)|na|
|int|[spring](https://github.com/Masterminds/sprig)|na|
|int64|[spring](https://github.com/Masterminds/sprig)|na|
|isAbs|[spring](https://github.com/Masterminds/sprig)|na|
|join|[spring](https://github.com/Masterminds/sprig)|na|
|keys|[spring](https://github.com/Masterminds/sprig)|na|
|kindIs|[spring](https://github.com/Masterminds/sprig)|na|
|kindOf|[spring](https://github.com/Masterminds/sprig)|na|
|last|[spring](https://github.com/Masterminds/sprig)|na|
|list|[spring](https://github.com/Masterminds/sprig)|na|
|lower|[spring](https://github.com/Masterminds/sprig)|na|
|max|[spring](https://github.com/Masterminds/sprig)|na|
|merge|[spring](https://github.com/Masterminds/sprig)|na|
|min|[spring](https://github.com/Masterminds/sprig)|na|
|mod|[spring](https://github.com/Masterminds/sprig)|na|
|mul|[spring](https://github.com/Masterminds/sprig)|na|
|nindent|[spring](https://github.com/Masterminds/sprig)|na|
|nospace|[spring](https://github.com/Masterminds/sprig)|na|
|now|[spring](https://github.com/Masterminds/sprig)|na|
|omit|[spring](https://github.com/Masterminds/sprig)|na|
|pick|[spring](https://github.com/Masterminds/sprig)|na|
|pluck|[spring](https://github.com/Masterminds/sprig)|na|
|plural|[spring](https://github.com/Masterminds/sprig)|na|
|prepend|[spring](https://github.com/Masterminds/sprig)|na|
|push|[spring](https://github.com/Masterminds/sprig)|na|
|quote|[spring](https://github.com/Masterminds/sprig)|na|
|randAlpha|[spring](https://github.com/Masterminds/sprig)|na|
|randAlphaNum|[spring](https://github.com/Masterminds/sprig)|na|
|randAscii|[spring](https://github.com/Masterminds/sprig)|na|
|randNumeric|[spring](https://github.com/Masterminds/sprig)|na|
|regexFind|[spring](https://github.com/Masterminds/sprig)|na|
|regexFindAll|[spring](https://github.com/Masterminds/sprig)|na|
|regexMatch|[spring](https://github.com/Masterminds/sprig)|na|
|regexReplaceAll|[spring](https://github.com/Masterminds/sprig)|na|
|regexReplaceAllLiteral|[spring](https://github.com/Masterminds/sprig)|na|
|regexSplit|[spring](https://github.com/Masterminds/sprig)|na|
|repeat|[spring](https://github.com/Masterminds/sprig)|na|
|replace|GTE|na|
|rest|[spring](https://github.com/Masterminds/sprig)|na|
|reverse|[spring](https://github.com/Masterminds/sprig)|na|
|round|[spring](https://github.com/Masterminds/sprig)|na|
|semver|[spring](https://github.com/Masterminds/sprig)|na|
|semverCompare|[spring](https://github.com/Masterminds/sprig)|na|
|set|[spring](https://github.com/Masterminds/sprig)|na|
|sha1sum|[spring](https://github.com/Masterminds/sprig)|na|
|sha256sum|[spring](https://github.com/Masterminds/sprig)|na|
|shuffle|[spring](https://github.com/Masterminds/sprig)|na|
|snakecase|[spring](https://github.com/Masterminds/sprig)|na|
|sortAlpha|[spring](https://github.com/Masterminds/sprig)|na|
|split|[spring](https://github.com/Masterminds/sprig)|na|
|splitList|[spring](https://github.com/Masterminds/sprig)|na|
|squote|[spring](https://github.com/Masterminds/sprig)|na|
|staticInclude|GTE|na|
|sub|[spring](https://github.com/Masterminds/sprig)|na|
|substr|[spring](https://github.com/Masterminds/sprig)|na|
|swapcase|[spring](https://github.com/Masterminds/sprig)|na|
|ternary|[spring](https://github.com/Masterminds/sprig)|na|
|title|[spring](https://github.com/Masterminds/sprig)|na|
|toDate|[spring](https://github.com/Masterminds/sprig)|na|
|toJson|[spring](https://github.com/Masterminds/sprig)|na|
|toPrettyJson|[spring](https://github.com/Masterminds/sprig)|na|
|toString|[spring](https://github.com/Masterminds/sprig)|na|
|toStrings|[spring](https://github.com/Masterminds/sprig)|na|
|trim|[spring](https://github.com/Masterminds/sprig)|na|
|trimAll|[spring](https://github.com/Masterminds/sprig)|na|
|trimPrefix|[spring](https://github.com/Masterminds/sprig)|na|
|trimSuffix|[spring](https://github.com/Masterminds/sprig)|na|
|trimall|[spring](https://github.com/Masterminds/sprig)|na|
|trunc|[spring](https://github.com/Masterminds/sprig)|na|
|tuple|[spring](https://github.com/Masterminds/sprig)|na|
|typeIs|[spring](https://github.com/Masterminds/sprig)|na|
|typeIsLike|[spring](https://github.com/Masterminds/sprig)|na|
|typeOf|[spring](https://github.com/Masterminds/sprig)|na|
|uniq|[spring](https://github.com/Masterminds/sprig)|na|
|unset|[spring](https://github.com/Masterminds/sprig)|na|
|until|[spring](https://github.com/Masterminds/sprig)|na|
|untilStep|[spring](https://github.com/Masterminds/sprig)|na|
|untitle|[spring](https://github.com/Masterminds/sprig)|na|
|upper|[spring](https://github.com/Masterminds/sprig)|na|
|uuidv4|[spring](https://github.com/Masterminds/sprig)|na|
|without|[spring](https://github.com/Masterminds/sprig)|na|
|wrap|[spring](https://github.com/Masterminds/sprig)|na|
|wrapWith|[spring](https://github.com/Masterminds/sprig)|na|


### Options
```
$> go-template-engine --help
Expand Down Expand Up @@ -340,4 +481,5 @@ outJson, _ := engine.ParseTemplateFile("test_fixtures/bb.txt.tpl", varsJson)
- [x] Recursive processing
- [x] Custom Delimeters
- [x] Static Include tag
- [x] Replace tag
- [x] Replace tag
- [x] Extra functions(tons.... thanks to [Masterminds Spring](https://github.com/Masterminds/sprig)
24 changes: 22 additions & 2 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ resources:
private_key: {{git_private_key}}
username: {{github_user}}

- name: git-repo-homebrew
type: git
source:
uri: {{git_repo_url}}
branch: dev
private_key: {{git_private_key}}
username: {{github_user}}

- name: app-resource-version
type: semver
source:
Expand All @@ -38,8 +46,8 @@ resources:
type: s3
source:
bucket: {{s3_bucket}}
access_key_id: {{aws_access_key_id}}
secret_access_key: {{aws_secret_access_key}}
access_key_id: {{labs_aws_access_key_id}}
secret_access_key: {{labs_aws_secret_access_key}}
region_name: ap-southeast-2
regexp: (.*).zip

Expand Down Expand Up @@ -86,3 +94,15 @@ jobs:
file: output/*linux*zip
acl: public-read

- name: update-homebrew-tap
build_logs_to_retain: 10
serial: true
plan:
- get: git-repo-homebrew
trigger: true

- task: update
file: git-repo-master/ci/release.yml
params:
MAKE_TARGETS: _prepare deps _build _release

17 changes: 0 additions & 17 deletions env.mk
Original file line number Diff line number Diff line change
@@ -1,17 +0,0 @@
APP_NAME=go-template-engine
GITHUB_USER=marcelocorreia
GOARCH?=amd64
GOOS?=darwin
GOPATH?=/go
NAMESPACE=github.com/marcelocorreia
OUTPUT_FILE=./bin/$(APP_NAME)
REPO_NAME=$(APP_NAME)
REPO_URL[email protected]:$(GITHUB_USER)/$(APP_NAME).git
TEST_OUTPUT_DIR=tmp
VERSION=$(shell make get-version)
WORKDIR=$(GOPATH)/src/$(NAMESPACE)/$(REPO_NAME)
HOMEBREW_REPO[email protected]:marcelocorreia/homebrew-taps.git
HOMEBREW_BINARY=dist/$(APP_NAME)-darwin-amd64-$(VERSION).zip
HOMEBREW_BINARY_SUM=$(shell shasum -a 256 $(HOMEBREW_BINARY) | awk '{print $$1}')
HOMEBREW_REPO_PATH?=/Users/marcelo/IdeaProjects/tardis/homebrew-taps
DOCS_DIR=docs
Loading

0 comments on commit 16fdf75

Please sign in to comment.