diff --git a/Procfile b/Procfile
deleted file mode 100644
index 85ca4dd..0000000
--- a/Procfile
+++ /dev/null
@@ -1 +0,0 @@
-web: bin/boilerplate-go
diff --git a/build/package/project.dockerfile b/build/package/project.dockerfile
deleted file mode 100644
index ea0b875..0000000
--- a/build/package/project.dockerfile
+++ /dev/null
@@ -1,5 +0,0 @@
-FROM alpine
-
-COPY bin/boilerplate-go .
-COPY tpl tpl
-CMD ["/boilerplate-go"]
diff --git a/cmd/boilerplate-go/handle.go b/cmd/boilerplate-go/handle.go
deleted file mode 100644
index 2b1bbb2..0000000
--- a/cmd/boilerplate-go/handle.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package main
-
-import (
- "context"
- "net/http"
-
- "github.com/and07/boilerplate-go/internal/pkg/template"
-)
-
-func hiHandler(ctx context.Context, tpl *template.Template) func(w http.ResponseWriter, r *http.Request) {
-
- return func(w http.ResponseWriter, r *http.Request) {
- //span, _ := opentracing.StartSpanFromContext(ctx, "Scratch.hiHandler")
- //defer span.Finish()
- counter.Inc()
-
- tpl.RenderTemplate(w, "main.html", "Hi")
- }
-}
-
-func publicHandle(ctx context.Context, tpl *template.Template) *http.ServeMux {
- rPublic := http.NewServeMux()
- rPublic.HandleFunc("/", hiHandler(ctx, tpl))
- return rPublic
-}
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..3961d99
--- /dev/null
+++ b/main.go
@@ -0,0 +1,26 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/temp-lib/templater"
+)
+
+func main() {
+ if len(os.Args) != 3 {
+ fmt.Println("usage : app serviceName user")
+ return
+ }
+ cfg := templater.Config{
+ ServiceName: os.Args[1],
+ User: os.Args[2],
+ IgnorePatterns: []string{".html", ".yml", ".yaml", ".tpl", ".txt", "js.map"},
+ }
+ templtr := templater.New(cfg)
+ err := templtr.BuildService(`./template/{{.ServiceName}}`,
+ `./`)
+ if err != nil {
+ fmt.Println(err)
+ }
+}
diff --git a/.env b/template/{{.ServiceName}}/.env
similarity index 100%
rename from .env
rename to template/{{.ServiceName}}/.env
diff --git a/template/{{.ServiceName}}/.github/workflows/main.yml b/template/{{.ServiceName}}/.github/workflows/main.yml
new file mode 100644
index 0000000..83e0f18
--- /dev/null
+++ b/template/{{.ServiceName}}/.github/workflows/main.yml
@@ -0,0 +1,109 @@
+name: Build and Test
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+
+jobs:
+
+ lint:
+ name: Lint
+ strategy:
+ matrix:
+ go-version: [1.14.x]
+ platform: [ubuntu-latest, macos-latest, windows-latest]
+ runs-on: ${{ matrix.platform }}
+ steps:
+ - name: Set up Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ matrix.go-version }}
+
+ - name: Check out code
+ uses: actions/checkout@v2
+
+ - name: Lint Go Code
+ run: |
+ make lint
+
+ test:
+ name: Test
+ strategy:
+ matrix:
+ go-version: [1.14.x]
+ platform: [ubuntu-latest, macos-latest, windows-latest]
+ runs-on: ${{ matrix.platform }}
+ steps:
+ - name: Set up Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ matrix.go-version }}
+
+ - name: Check out code
+ uses: actions/checkout@v2
+
+ - name: Run Unit tests.
+ run: make test
+
+ slint:
+ name: Super Linter
+ strategy:
+ matrix:
+ go-version: [1.14.x]
+ platform: [ubuntu-latest]
+ runs-on: ${{ matrix.platform }}
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v2
+
+ # - name: Super-Linter
+ # uses: github/super-linter@v2.2.0
+ # with:
+ # fail_ci_if_error: true
+
+ test-coverage:
+ name: Test Coverage
+ strategy:
+ matrix:
+ go-version: [1.14.x]
+ platform: [ubuntu-latest]
+ runs-on: ${{ matrix.platform }}
+ steps:
+ - name: Set up Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ matrix.go-version }}
+
+ - name: Check out code
+ uses: actions/checkout@v2
+
+ - name: Run tests coverage.
+ run: make test-coverage
+
+ - name: Upload Coverage report to CodeCov
+ uses: codecov/codecov-action@v1.0.0
+ with:
+ token: ${{secrets.CODECOV_TOKEN}}
+ file: ./coverage.txt
+ # fail_ci_if_error: true
+
+ build:
+ name: Build
+ strategy:
+ matrix:
+ go-version: [1.14.x]
+ platform: [ubuntu-latest, macos-latest, windows-latest]
+ runs-on: ${{ matrix.platform }}
+ needs: [lint, test]
+ steps:
+ - name: Set up Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ matrix.go-version }}
+
+ - name: Check out code
+ uses: actions/checkout@v2
+
+ - name: Build
+ run: make build
diff --git a/template/{{.ServiceName}}/.gitignore b/template/{{.ServiceName}}/.gitignore
new file mode 100644
index 0000000..dcdfe75
--- /dev/null
+++ b/template/{{.ServiceName}}/.gitignore
@@ -0,0 +1,28 @@
+# Mac OS X files
+.DS_Store
+
+#.env
+
+# Binaries for programs and plugins
+*.exe
+*.dll
+*.so
+*.dylib
+
+# Test binary, build with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
+.glide/
+
+deployments/redis-persistence/*
+bin/*
+logs/*
+
+/vendor
+/vendor.pb
+/.idea
+/.vscode
diff --git a/.gitlab-ci.yml b/template/{{.ServiceName}}/.gitlab-ci.yml
similarity index 90%
rename from .gitlab-ci.yml
rename to template/{{.ServiceName}}/.gitlab-ci.yml
index 6790431..dcdae74 100644
--- a/.gitlab-ci.yml
+++ b/template/{{.ServiceName}}/.gitlab-ci.yml
@@ -11,8 +11,8 @@ stages:
variables:
KUBECONFIG: /etc/deploy/config
- REPOSITORY: and07/boilerplate-go
- NAMESPACE: boilerplate-go
+ REPOSITORY: {{.User}}/{{.ServiceName}}
+ NAMESPACE: {{.ServiceName}}
TAG: ${CI_BUILD_REF_NAME}_${CI_BUILD_REF}
CONTAINER_IMAGE: docker.io/${REPOSITORY}:${CI_BUILD_REF_NAME}_${CI_BUILD_REF}
CONTAINER_IMAGE_LATEST: docker.io/${REPOSITORY}:latest
@@ -41,7 +41,7 @@ lint:
# - echo ${kube_config} | base64 -d > ${KUBECONFIG}
# - helm init --client-only
# script:
-# - cd deployments/kubernetes/boilerplate-go-chart
+# - cd deployments/kubernetes/{{.ServiceName}}-chart
# - export DEPLOYS=$(helm ls | grep $NAMESPACE | wc -l)
# - >
# if [ ${DEPLOYS} -eq 0 ]; then
diff --git a/.golangci.pipeline.yaml b/template/{{.ServiceName}}/.golangci.pipeline.yaml
similarity index 100%
rename from .golangci.pipeline.yaml
rename to template/{{.ServiceName}}/.golangci.pipeline.yaml
diff --git a/.golangci.yaml b/template/{{.ServiceName}}/.golangci.yaml
similarity index 100%
rename from .golangci.yaml
rename to template/{{.ServiceName}}/.golangci.yaml
diff --git a/LICENSE b/template/{{.ServiceName}}/LICENSE
similarity index 97%
rename from LICENSE
rename to template/{{.ServiceName}}/LICENSE
index a5c7cc3..5307594 100644
--- a/LICENSE
+++ b/template/{{.ServiceName}}/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2020 and07
+Copyright (c) 2020 {{.User}}
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Makefile b/template/{{.ServiceName}}/Makefile
similarity index 93%
rename from Makefile
rename to template/{{.ServiceName}}/Makefile
index 7fa474d..bebde4e 100644
--- a/Makefile
+++ b/template/{{.ServiceName}}/Makefile
@@ -1,8 +1,8 @@
# note: call scripts from /scripts
-SERVICE_NAME=boilerplate-go
-USER=and07
+.ServiceName={{.ServiceName}}
+USER={{.User}}
VERSION=latest
-REPOSITORY="$(USER)/$(SERVICE_NAME)"
+REPOSITORY="$(USER)/$(.ServiceName)"
QUAYVERSION = "${REPOSITORY}:$(VERSION)"
TAG=${CI_BUILD_REF_NAME}_${CI_BUILD_REF}
@@ -47,10 +47,10 @@ export GO111MODULE=on
SHELL=/bin/bash -o pipefail
-APP?=$(SERVICE_NAME)
-PROJECT?=github.com/$(USER)/$(SERVICE_NAME)
+APP?=$(.ServiceName)
+PROJECT?=github.com/$(USER)/$(.ServiceName)
-LDFLAGS:=-X '${PROJECT}/version.Name=$(SERVICE_NAME)'\
+LDFLAGS:=-X '${PROJECT}/version.Name=$(.ServiceName)'\
-X '${PROJECT}/version.ProjectID=$(CI_PROJECT_ID)'\
-X '${PROJECT}/version.Version=$(APP_VERSION)'\
-X '${PROJECT}/version.GoVersion=$(GO_VERSION_SHORT)'\
@@ -125,14 +125,14 @@ install-protoc: ## Install protoc
github.com/golang/protobuf/protoc-gen-go
gen-protoc: ## protoc generation
- mkdir -p "./api/gen-${SERVICE_NAME}"
+ mkdir -p "./api/gen-${.ServiceName}"
protoc -I/usr/local/include -I. \
-I${GOPATH}/src \
-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \
- --grpc-gateway_out=logtostderr=true:./api/gen-$(SERVICE_NAME) \
+ --grpc-gateway_out=logtostderr=true:./api/gen-$(.ServiceName) \
--swagger_out=allow_merge=true,merge_file_name=api:./assets/swaggerui \
- --go_out=plugins=grpc:./api/gen-$(SERVICE_NAME) ./api/*.proto
+ --go_out=plugins=grpc:./api/gen-$(.ServiceName) ./api/*.proto
.PHONY: install-lint
@@ -201,7 +201,7 @@ docker-logs: ## Docker logs
mkdir -p ./logs || true
#docker logs postgres-$${CI_JOB_ID:-local} >& logs/postgres.log
#docker logs pg-migrations-$${CI_JOB_ID:-local} >& logs/pg-migrations.log
- docker logs $${SERVICE_NAME}-$${CI_JOB_ID:-local} >& logs/$${SERVICE_NAME}.log
+ docker logs $${.ServiceName}-$${CI_JOB_ID:-local} >& logs/$${.ServiceName}.log
docker logs redis-$${CI_JOB_ID:-local} >& logs/redis.log
docker logs rabbitmq-$${CI_JOB_ID:-local} >& logs/rabbitmq.log
docker logs elasticsearch-$${CI_JOB_ID:-local} >& logs/elasticsearch.log
@@ -219,8 +219,8 @@ docker-clean:
docker rm -f $$(docker ps -a -f status=exited -q) || true
@echo Очистка dangling образов
docker rmi -f $$(docker images -f "dangling=true" -q) || true
- @echo Очистка $${SERVICE_NAME} образов
- docker rmi -f $$(docker images --filter=reference='$${SERVICE_NAME}*' -q) || true
+ @echo Очистка $${.ServiceName} образов
+ docker rmi -f $$(docker images --filter=reference='$${.ServiceName}*' -q) || true
#@echo Очистка itest образов
#docker rmi -f $$(docker images --filter=reference='itest*' -q) || true
#@echo Очистка pg-migrations образов
diff --git a/template/{{.ServiceName}}/Procfile b/template/{{.ServiceName}}/Procfile
new file mode 100644
index 0000000..0d4104c
--- /dev/null
+++ b/template/{{.ServiceName}}/Procfile
@@ -0,0 +1 @@
+web: bin/{{.ServiceName}}
diff --git a/README.md b/template/{{.ServiceName}}/README.md
similarity index 76%
rename from README.md
rename to template/{{.ServiceName}}/README.md
index c9f297c..3f7bbf1 100644
--- a/README.md
+++ b/template/{{.ServiceName}}/README.md
@@ -1,8 +1,8 @@
-[![Go Report Card](https://goreportcard.com/badge/github.com/and07/boilerplate-go)](https://goreportcard.com/report/github.com/and07/boilerplate-go)
-[![codecov](https://codecov.io/gh/and07/boilerplate-go/branch/master/graph/badge.svg)](https://codecov.io/gh/and07/boilerplate-go)
-[![Actions Status](https://github.com/and07/boilerplate-go/workflows/Build%20and%20Test/badge.svg)](https://github.com/and07/boilerplate-go/actions)
+[![Go Report Card](https://goreportcard.com/badge/github.com/{{.User}}/{{.ServiceName}})](https://goreportcard.com/report/github.com/{{.User}}/{{.ServiceName}})
+[![codecov](https://codecov.io/gh/{{.User}}/{{.ServiceName}}/branch/master/graph/badge.svg)](https://codecov.io/gh/{{.User}}/{{.ServiceName}})
+[![Actions Status](https://github.com/{{.User}}/{{.ServiceName}}/workflows/Build%20and%20Test/badge.svg)](https://github.com/{{.User}}/{{.ServiceName}}/actions)
[![MIT License](http://img.shields.io/:license-mit-blue.svg)](LICENSE)
-[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fand07%2Fboilerplate-go.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fand07%2Fboilerplate-go?ref=badge_shield)
+[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2F{{.User}}%2F{{.ServiceName}}.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2F{{.User}}%2F{{.ServiceName}}?ref=badge_shield)
# Standard Go Project Layout (Boilerplate-GO)
@@ -30,13 +30,13 @@ $ echo "$(minikube ip) private-boi.minikube" | sudo tee -a /etc/hosts
```sh
helm package jaeger --debug
-helm package boilerplate-go-chart --debug
+helm package {{.ServiceName}}-chart --debug
```
```sh
$ helm install --name jaeger jaeger-0.1.0.tgz
-$ helm install --name boi boilerplate-go-chart-0.1.0.tgz
+$ helm install --name boi {{.ServiceName}}-chart-0.1.0.tgz
$ helm install --name prometheus --namespace monitoring -f prometheus-values.yaml stable/prometheus
diff --git a/api/.keep b/template/{{.ServiceName}}/api/.keep
similarity index 100%
rename from api/.keep
rename to template/{{.ServiceName}}/api/.keep
diff --git a/api/README.md b/template/{{.ServiceName}}/api/README.md
similarity index 100%
rename from api/README.md
rename to template/{{.ServiceName}}/api/README.md
diff --git a/api/api.proto b/template/{{.ServiceName}}/api/api.proto
similarity index 100%
rename from api/api.proto
rename to template/{{.ServiceName}}/api/api.proto
diff --git a/api/gen-boilerplate-go/api/api.pb.go b/template/{{.ServiceName}}/api/gen-{{.ServiceName}}/api/api.pb.go
similarity index 100%
rename from api/gen-boilerplate-go/api/api.pb.go
rename to template/{{.ServiceName}}/api/gen-{{.ServiceName}}/api/api.pb.go
diff --git a/api/gen-boilerplate-go/api/api.pb.gw.go b/template/{{.ServiceName}}/api/gen-{{.ServiceName}}/api/api.pb.gw.go
similarity index 100%
rename from api/gen-boilerplate-go/api/api.pb.gw.go
rename to template/{{.ServiceName}}/api/gen-{{.ServiceName}}/api/api.pb.gw.go
diff --git a/api/gen-boilerplate-go/api/swagger.pb.go b/template/{{.ServiceName}}/api/gen-{{.ServiceName}}/api/swagger.pb.go
similarity index 100%
rename from api/gen-boilerplate-go/api/swagger.pb.go
rename to template/{{.ServiceName}}/api/gen-{{.ServiceName}}/api/swagger.pb.go
diff --git a/api/swagger.proto b/template/{{.ServiceName}}/api/swagger.proto
similarity index 84%
rename from api/swagger.proto
rename to template/{{.ServiceName}}/api/swagger.proto
index 8e5bd6f..c175612 100644
--- a/api/swagger.proto
+++ b/template/{{.ServiceName}}/api/swagger.proto
@@ -6,11 +6,11 @@ package api;
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
info: {
- title: "My boilerplate-go"
+ title: "My {{.ServiceName}}"
version: "1.0"
contact: {
- name: "and07"
- url: "https://github.com/and07"
+ name: "{{.User}}"
+ url: "https://github.com/{{.User}}"
email: ""
};
};
diff --git a/assets/.keep b/template/{{.ServiceName}}/assets/.keep
similarity index 100%
rename from assets/.keep
rename to template/{{.ServiceName}}/assets/.keep
diff --git a/assets/README.md b/template/{{.ServiceName}}/assets/README.md
similarity index 100%
rename from assets/README.md
rename to template/{{.ServiceName}}/assets/README.md
diff --git a/assets/swaggerui/api.swagger.json b/template/{{.ServiceName}}/assets/swaggerui/api.swagger.json
similarity index 99%
rename from assets/swaggerui/api.swagger.json
rename to template/{{.ServiceName}}/assets/swaggerui/api.swagger.json
index f1959c3..d6524ab 100644
--- a/assets/swaggerui/api.swagger.json
+++ b/template/{{.ServiceName}}/assets/swaggerui/api.swagger.json
@@ -1,11 +1,11 @@
{
"swagger": "2.0",
"info": {
- "title": "My boilerplate-go",
+ "title": "My {{.ServiceName}}",
"version": "1.0",
"contact": {
- "name": "and07",
- "url": "https://github.com/and07"
+ "name": "{{.User}}",
+ "url": "https://github.com/{{.User}}"
}
},
"host": "localhost:8843",
diff --git a/assets/swaggerui/favicon-16x16.png b/template/{{.ServiceName}}/assets/swaggerui/favicon-16x16.png
similarity index 100%
rename from assets/swaggerui/favicon-16x16.png
rename to template/{{.ServiceName}}/assets/swaggerui/favicon-16x16.png
diff --git a/assets/swaggerui/favicon-32x32.png b/template/{{.ServiceName}}/assets/swaggerui/favicon-32x32.png
similarity index 100%
rename from assets/swaggerui/favicon-32x32.png
rename to template/{{.ServiceName}}/assets/swaggerui/favicon-32x32.png
diff --git a/assets/swaggerui/index.html b/template/{{.ServiceName}}/assets/swaggerui/index.html
similarity index 100%
rename from assets/swaggerui/index.html
rename to template/{{.ServiceName}}/assets/swaggerui/index.html
diff --git a/assets/swaggerui/oauth2-redirect.html b/template/{{.ServiceName}}/assets/swaggerui/oauth2-redirect.html
similarity index 100%
rename from assets/swaggerui/oauth2-redirect.html
rename to template/{{.ServiceName}}/assets/swaggerui/oauth2-redirect.html
diff --git a/assets/swaggerui/swagger-ui-bundle.js b/template/{{.ServiceName}}/assets/swaggerui/swagger-ui-bundle.js
similarity index 100%
rename from assets/swaggerui/swagger-ui-bundle.js
rename to template/{{.ServiceName}}/assets/swaggerui/swagger-ui-bundle.js
diff --git a/assets/swaggerui/swagger-ui-bundle.js.map b/template/{{.ServiceName}}/assets/swaggerui/swagger-ui-bundle.js.map
similarity index 100%
rename from assets/swaggerui/swagger-ui-bundle.js.map
rename to template/{{.ServiceName}}/assets/swaggerui/swagger-ui-bundle.js.map
diff --git a/assets/swaggerui/swagger-ui-standalone-preset.js b/template/{{.ServiceName}}/assets/swaggerui/swagger-ui-standalone-preset.js
similarity index 100%
rename from assets/swaggerui/swagger-ui-standalone-preset.js
rename to template/{{.ServiceName}}/assets/swaggerui/swagger-ui-standalone-preset.js
diff --git a/assets/swaggerui/swagger-ui-standalone-preset.js.map b/template/{{.ServiceName}}/assets/swaggerui/swagger-ui-standalone-preset.js.map
similarity index 100%
rename from assets/swaggerui/swagger-ui-standalone-preset.js.map
rename to template/{{.ServiceName}}/assets/swaggerui/swagger-ui-standalone-preset.js.map
diff --git a/assets/swaggerui/swagger-ui.css b/template/{{.ServiceName}}/assets/swaggerui/swagger-ui.css
similarity index 100%
rename from assets/swaggerui/swagger-ui.css
rename to template/{{.ServiceName}}/assets/swaggerui/swagger-ui.css
diff --git a/assets/swaggerui/swagger-ui.css.map b/template/{{.ServiceName}}/assets/swaggerui/swagger-ui.css.map
similarity index 100%
rename from assets/swaggerui/swagger-ui.css.map
rename to template/{{.ServiceName}}/assets/swaggerui/swagger-ui.css.map
diff --git a/assets/swaggerui/swagger-ui.js b/template/{{.ServiceName}}/assets/swaggerui/swagger-ui.js
similarity index 100%
rename from assets/swaggerui/swagger-ui.js
rename to template/{{.ServiceName}}/assets/swaggerui/swagger-ui.js
diff --git a/assets/swaggerui/swagger-ui.js.map b/template/{{.ServiceName}}/assets/swaggerui/swagger-ui.js.map
similarity index 100%
rename from assets/swaggerui/swagger-ui.js.map
rename to template/{{.ServiceName}}/assets/swaggerui/swagger-ui.js.map
diff --git a/build/README.md b/template/{{.ServiceName}}/build/README.md
similarity index 100%
rename from build/README.md
rename to template/{{.ServiceName}}/build/README.md
diff --git a/build/ci/.keep b/template/{{.ServiceName}}/build/ci/.keep
similarity index 100%
rename from build/ci/.keep
rename to template/{{.ServiceName}}/build/ci/.keep
diff --git a/build/package/.keep b/template/{{.ServiceName}}/build/package/.keep
similarity index 100%
rename from build/package/.keep
rename to template/{{.ServiceName}}/build/package/.keep
diff --git a/template/{{.ServiceName}}/build/package/project.dockerfile b/template/{{.ServiceName}}/build/package/project.dockerfile
new file mode 100644
index 0000000..e2d3946
--- /dev/null
+++ b/template/{{.ServiceName}}/build/package/project.dockerfile
@@ -0,0 +1,5 @@
+FROM alpine
+
+COPY bin/{{.ServiceName}} .
+COPY tpl tpl
+CMD ["/{{.ServiceName}}"]
diff --git a/cmd/README.md b/template/{{.ServiceName}}/cmd/README.md
similarity index 100%
rename from cmd/README.md
rename to template/{{.ServiceName}}/cmd/README.md
diff --git a/cmd/boilerplate-go/.keep b/template/{{.ServiceName}}/cmd/{{.ServiceName}}/.keep
similarity index 100%
rename from cmd/boilerplate-go/.keep
rename to template/{{.ServiceName}}/cmd/{{.ServiceName}}/.keep
diff --git a/cmd/boilerplate-go/config.go b/template/{{.ServiceName}}/cmd/{{.ServiceName}}/config.go
similarity index 100%
rename from cmd/boilerplate-go/config.go
rename to template/{{.ServiceName}}/cmd/{{.ServiceName}}/config.go
diff --git a/template/{{.ServiceName}}/cmd/{{.ServiceName}}/handle.go b/template/{{.ServiceName}}/cmd/{{.ServiceName}}/handle.go
new file mode 100644
index 0000000..ed34f93
--- /dev/null
+++ b/template/{{.ServiceName}}/cmd/{{.ServiceName}}/handle.go
@@ -0,0 +1,25 @@
+package main
+
+import (
+ "context"
+ "net/http"
+
+ "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/template"
+)
+
+func hiHandler(ctx context.Context, tpl *template.Template, tmplData interface{}) func(w http.ResponseWriter, r *http.Request) {
+
+ return func(w http.ResponseWriter, r *http.Request) {
+ //span, _ := opentracing.StartSpanFromContext(ctx, "Scratch.hiHandler")
+ //defer span.Finish()
+ counter.Inc()
+
+ tpl.RenderTemplate(w, "main.html", tmplData)
+ }
+}
+
+func publicHandle(ctx context.Context, tpl *template.Template, tmplData interface{}) *http.ServeMux {
+ rPublic := http.NewServeMux()
+ rPublic.HandleFunc("/", hiHandler(ctx, tpl, tmplData))
+ return rPublic
+}
diff --git a/cmd/boilerplate-go/main.go b/template/{{.ServiceName}}/cmd/{{.ServiceName}}/main.go
similarity index 74%
rename from cmd/boilerplate-go/main.go
rename to template/{{.ServiceName}}/cmd/{{.ServiceName}}/main.go
index e6fc449..5f7f606 100644
--- a/cmd/boilerplate-go/main.go
+++ b/template/{{.ServiceName}}/cmd/{{.ServiceName}}/main.go
@@ -3,13 +3,13 @@ package main
import (
"context"
"time"
-
- "github.com/and07/boilerplate-go/api/gen-boilerplate-go/api"
- "github.com/and07/boilerplate-go/internal/app/boilerplate"
- "github.com/and07/boilerplate-go/internal/app/serv"
- log "github.com/and07/boilerplate-go/internal/pkg/logger"
- "github.com/and07/boilerplate-go/internal/pkg/template"
- "github.com/and07/boilerplate-go/internal/pkg/tracing"
+ "io/ioutil"
+ "github.com/{{.User}}/{{.ServiceName}}/api/gen-{{.ServiceName}}/api"
+ app "github.com/{{.User}}/{{.ServiceName}}/internal/app/{{.ServiceName}}"
+ "github.com/{{.User}}/{{.ServiceName}}/internal/app/serv"
+ log "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/logger"
+ "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/template"
+ "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/tracing"
"github.com/caarlos0/env"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
@@ -36,7 +36,7 @@ func main() {
ctx := context.Background()
- tracer, closer := tracing.Init("boilerplate-go")
+ tracer, closer := tracing.Init("{{.ServiceName}}")
defer closer.Close()
opentracing.SetGlobalTracer(tracer)
@@ -104,19 +104,22 @@ func main() {
if cfg.PortGRPC == "" {
cfg.PortGRPC = "8842"
}
-
- tpl := template.NewTemplate("tpl/layouts/", "tpl/", `{{define "main" }} {{ template "base" . }} {{ end }}`)
+ templateRaw, err := ioutil.ReadFile("tpl/public_hundle.html")
+ if err != nil{
+ log.Error(err)
+ }
+ tpl := template.NewTemplate("tpl/layouts/", "tpl/", string(templateRaw))
tpl.Init()
hw := func(grpcSrv *grpc.Server) {
- impl := boilerplate.New(ctx)
+ impl := app.New(ctx)
api.RegisterHttpBodyExampleServiceServer(grpcSrv, impl)
}
eventBus := make(chan interface{})
bc := func(grpcSrv *grpc.Server) {
- api.RegisterBlockchainServiceServer(grpcSrv, boilerplate.NewBlockchainServer(eventBus))
+ api.RegisterBlockchainServiceServer(grpcSrv, app.NewBlockchainServer(eventBus))
}
srv := serv.New(ctx,
@@ -147,6 +150,13 @@ func main() {
}
}()
- srv.Run(ctx, publicHandle(ctx, tpl), api.RegisterBlockchainServiceHandlerFromEndpoint, api.RegisterHttpBodyExampleServiceHandlerFromEndpoint)
+ tplData := struct{
+ Hi string
+ User string
+ }{
+ Hi : "Hi",
+ User : "{{.User}}",
+ }
+ srv.Run(ctx, publicHandle(ctx, tpl, tplData), api.RegisterBlockchainServiceHandlerFromEndpoint, api.RegisterHttpBodyExampleServiceHandlerFromEndpoint)
}
diff --git a/configs/.keep b/template/{{.ServiceName}}/configs/.keep
similarity index 100%
rename from configs/.keep
rename to template/{{.ServiceName}}/configs/.keep
diff --git a/configs/README.md b/template/{{.ServiceName}}/configs/README.md
similarity index 100%
rename from configs/README.md
rename to template/{{.ServiceName}}/configs/README.md
diff --git a/deployments/.keep b/template/{{.ServiceName}}/deployments/.keep
similarity index 100%
rename from deployments/.keep
rename to template/{{.ServiceName}}/deployments/.keep
diff --git a/deployments/README.md b/template/{{.ServiceName}}/deployments/README.md
similarity index 100%
rename from deployments/README.md
rename to template/{{.ServiceName}}/deployments/README.md
diff --git a/deployments/clickhouse-config.xml b/template/{{.ServiceName}}/deployments/clickhouse-config.xml
similarity index 100%
rename from deployments/clickhouse-config.xml
rename to template/{{.ServiceName}}/deployments/clickhouse-config.xml
diff --git a/deployments/docker-compose-kafka.yml b/template/{{.ServiceName}}/deployments/docker-compose-kafka.yml
similarity index 100%
rename from deployments/docker-compose-kafka.yml
rename to template/{{.ServiceName}}/deployments/docker-compose-kafka.yml
diff --git a/deployments/docker-compose.yml b/template/{{.ServiceName}}/deployments/docker-compose.yml
similarity index 97%
rename from deployments/docker-compose.yml
rename to template/{{.ServiceName}}/deployments/docker-compose.yml
index 0ed8776..c972d93 100644
--- a/deployments/docker-compose.yml
+++ b/template/{{.ServiceName}}/deployments/docker-compose.yml
@@ -138,8 +138,8 @@ services:
# project:
- # image: "and07/boilerplate-go:latest"
- # container_name: "boilerplate-go-${CI_JOB_ID:-local}"
+ # image: "{{.User}}/{{.ServiceName}}:latest"
+ # container_name: "{{.ServiceName}}-${CI_JOB_ID:-local}"
# #links:
# #- 'rabbitmq:rabbitmq'
# ports:
diff --git a/deployments/elasticsearch.yml b/template/{{.ServiceName}}/deployments/elasticsearch.yml
similarity index 100%
rename from deployments/elasticsearch.yml
rename to template/{{.ServiceName}}/deployments/elasticsearch.yml
diff --git a/deployments/enabled_plugins b/template/{{.ServiceName}}/deployments/enabled_plugins
similarity index 100%
rename from deployments/enabled_plugins
rename to template/{{.ServiceName}}/deployments/enabled_plugins
diff --git a/deployments/kubernetes/grafana-values.yaml b/template/{{.ServiceName}}/deployments/kubernetes/grafana-values.yaml
similarity index 100%
rename from deployments/kubernetes/grafana-values.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/grafana-values.yaml
diff --git a/deployments/kubernetes/ingress_p.yaml b/template/{{.ServiceName}}/deployments/kubernetes/ingress_p.yaml
similarity index 85%
rename from deployments/kubernetes/ingress_p.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/ingress_p.yaml
index 4efe7d1..ba353c2 100644
--- a/deployments/kubernetes/ingress_p.yaml
+++ b/template/{{.ServiceName}}/deployments/kubernetes/ingress_p.yaml
@@ -1,8 +1,8 @@
---
{{- if .Values.ingress.enabled }}
-{{- $fullName := include "boilerplate-go-chart.fullname" . }}
-{{ $chartName := include "boilerplate-go-chart.name" . }}
-{{ $chart := include "boilerplate-go-chart.chart" . }}
+{{- $fullName := include "{{.ServiceName}}-chart.fullname" . }}
+{{ $chartName := include "{{.ServiceName}}-chart.name" . }}
+{{ $chart := include "{{.ServiceName}}-chart.chart" . }}
{{ $releaseName := .Release.Name }}
{{ $releaseService := .Release.Service }}
{{- range .Values.service.ports }}
diff --git a/deployments/kubernetes/jaeger-values.yaml b/template/{{.ServiceName}}/deployments/kubernetes/jaeger-values.yaml
similarity index 100%
rename from deployments/kubernetes/jaeger-values.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/jaeger-values.yaml
diff --git a/deployments/kubernetes/jaeger/.helmignore b/template/{{.ServiceName}}/deployments/kubernetes/jaeger/.helmignore
similarity index 100%
rename from deployments/kubernetes/jaeger/.helmignore
rename to template/{{.ServiceName}}/deployments/kubernetes/jaeger/.helmignore
diff --git a/deployments/kubernetes/jaeger/Chart.yaml b/template/{{.ServiceName}}/deployments/kubernetes/jaeger/Chart.yaml
similarity index 100%
rename from deployments/kubernetes/jaeger/Chart.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/jaeger/Chart.yaml
diff --git a/deployments/kubernetes/jaeger/templates/NOTES.txt b/template/{{.ServiceName}}/deployments/kubernetes/jaeger/templates/NOTES.txt
similarity index 100%
rename from deployments/kubernetes/jaeger/templates/NOTES.txt
rename to template/{{.ServiceName}}/deployments/kubernetes/jaeger/templates/NOTES.txt
diff --git a/deployments/kubernetes/jaeger/templates/jaeger.yaml b/template/{{.ServiceName}}/deployments/kubernetes/jaeger/templates/jaeger.yaml
similarity index 100%
rename from deployments/kubernetes/jaeger/templates/jaeger.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/jaeger/templates/jaeger.yaml
diff --git a/deployments/kubernetes/jaeger/values.yaml b/template/{{.ServiceName}}/deployments/kubernetes/jaeger/values.yaml
similarity index 100%
rename from deployments/kubernetes/jaeger/values.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/jaeger/values.yaml
diff --git a/deployments/kubernetes/prometheus-values.yaml b/template/{{.ServiceName}}/deployments/kubernetes/prometheus-values.yaml
similarity index 99%
rename from deployments/kubernetes/prometheus-values.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/prometheus-values.yaml
index 90360f2..47d5d1a 100644
--- a/deployments/kubernetes/prometheus-values.yaml
+++ b/template/{{.ServiceName}}/deployments/kubernetes/prometheus-values.yaml
@@ -1039,7 +1039,7 @@ serverFiles:
# will add targets for each API server which Kubernetes adds an endpoint to
# the default/kubernetes service.
relabel_configs:
- - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
+ - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_.ServiceName, __meta_kubernetes_endpoint_port_name]
action: keep
regex: default;kubernetes;https
@@ -1159,7 +1159,7 @@ serverFiles:
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- - source_labels: [__meta_kubernetes_service_name]
+ - source_labels: [__meta_kubernetes_.ServiceName]
action: replace
target_label: kubernetes_name
- source_labels: [__meta_kubernetes_pod_node_name]
@@ -1206,7 +1206,7 @@ serverFiles:
regex: __meta_kubernetes_service_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
target_label: kubernetes_namespace
- - source_labels: [__meta_kubernetes_service_name]
+ - source_labels: [__meta_kubernetes_.ServiceName]
target_label: kubernetes_name
# Example scrape config for pods
diff --git a/deployments/kubernetes/boilerplate-go-chart/.helmignore b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/.helmignore
similarity index 100%
rename from deployments/kubernetes/boilerplate-go-chart/.helmignore
rename to template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/.helmignore
diff --git a/deployments/kubernetes/boilerplate-go-chart/Chart.yaml b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/Chart.yaml
similarity index 71%
rename from deployments/kubernetes/boilerplate-go-chart/Chart.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/Chart.yaml
index a6b39ca..311a918 100644
--- a/deployments/kubernetes/boilerplate-go-chart/Chart.yaml
+++ b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/Chart.yaml
@@ -1,4 +1,4 @@
apiVersion: v1
description: A Helm chart for Kubernetes
-name: boilerplate-go-chart
+name: {{.ServiceName}}-chart
version: 0.1.0
diff --git a/deployments/kubernetes/boilerplate-go-chart/templates/NOTES.txt b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/NOTES.txt
similarity index 73%
rename from deployments/kubernetes/boilerplate-go-chart/templates/NOTES.txt
rename to template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/NOTES.txt
index f6b8847..a7d38d7 100644
--- a/deployments/kubernetes/boilerplate-go-chart/templates/NOTES.txt
+++ b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/NOTES.txt
@@ -6,16 +6,16 @@
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
- export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "boilerplate-go-chart.fullname" . }})
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "{{.ServiceName}}-chart.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
- You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "boilerplate-go-chart.fullname" . }}'
- export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "boilerplate-go-chart.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "{{.ServiceName}}-chart.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "{{.ServiceName}}-chart.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
{{- else if contains "ClusterIP" .Values.service.type }}
- export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "boilerplate-go-chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "{{.ServiceName}}-chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }}
{{- end }}
\ No newline at end of file
diff --git a/deployments/kubernetes/boilerplate-go-chart/templates/_helpers.tpl b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/_helpers.tpl
similarity index 87%
rename from deployments/kubernetes/boilerplate-go-chart/templates/_helpers.tpl
rename to template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/_helpers.tpl
index e7d98d8..a3c3996 100644
--- a/deployments/kubernetes/boilerplate-go-chart/templates/_helpers.tpl
+++ b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/_helpers.tpl
@@ -2,7 +2,7 @@
{{/*
Expand the name of the chart.
*/}}
-{{- define "boilerplate-go-chart.name" -}}
+{{- define "{{.ServiceName}}-chart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
@@ -11,7 +11,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
-{{- define "boilerplate-go-chart.fullname" -}}
+{{- define "{{.ServiceName}}-chart.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
@@ -27,6 +27,6 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
-{{- define "boilerplate-go-chart.chart" -}}
+{{- define "{{.ServiceName}}-chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
diff --git a/deployments/kubernetes/boilerplate-go-chart/templates/deployment.yaml b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/deployment.yaml
similarity index 85%
rename from deployments/kubernetes/boilerplate-go-chart/templates/deployment.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/deployment.yaml
index 8e7a572..462e1c6 100644
--- a/deployments/kubernetes/boilerplate-go-chart/templates/deployment.yaml
+++ b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/deployment.yaml
@@ -2,22 +2,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- name: {{ include "boilerplate-go-chart.fullname" . }}
+ name: {{ include "{{.ServiceName}}-chart.fullname" . }}
labels:
- app.kubernetes.io/name: {{ include "boilerplate-go-chart.name" . }}
- helm.sh/chart: {{ include "boilerplate-go-chart.chart" . }}
+ app.kubernetes.io/name: {{ include "{{.ServiceName}}-chart.name" . }}
+ helm.sh/chart: {{ include "{{.ServiceName}}-chart.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
- app.kubernetes.io/name: {{ include "boilerplate-go-chart.name" . }}
+ app.kubernetes.io/name: {{ include "{{.ServiceName}}-chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
- app.kubernetes.io/name: {{ include "boilerplate-go-chart.name" . }}
+ app.kubernetes.io/name: {{ include "{{.ServiceName}}-chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app: {{ .Values.app }}
componentType: app
diff --git a/deployments/kubernetes/boilerplate-go-chart/templates/ingress.yaml b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/ingress.yaml
similarity index 81%
rename from deployments/kubernetes/boilerplate-go-chart/templates/ingress.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/ingress.yaml
index 80b0e2a..4329ed2 100644
--- a/deployments/kubernetes/boilerplate-go-chart/templates/ingress.yaml
+++ b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/ingress.yaml
@@ -1,13 +1,13 @@
---
{{- if .Values.ingress.enabled }}
-{{- $fullName := include "boilerplate-go-chart.fullname" . }}
+{{- $fullName := include "{{.ServiceName}}-chart.fullname" . }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
- app.kubernetes.io/name: {{ include "boilerplate-go-chart.name" . }}
- helm.sh/chart: {{ include "boilerplate-go-chart.chart" . }}
+ app.kubernetes.io/name: {{ include "{{.ServiceName}}-chart.name" . }}
+ helm.sh/chart: {{ include "{{.ServiceName}}-chart.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
diff --git a/deployments/kubernetes/boilerplate-go-chart/templates/service.yaml b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/service.yaml
similarity index 68%
rename from deployments/kubernetes/boilerplate-go-chart/templates/service.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/service.yaml
index ef658b5..b5a1136 100644
--- a/deployments/kubernetes/boilerplate-go-chart/templates/service.yaml
+++ b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/templates/service.yaml
@@ -1,10 +1,10 @@
apiVersion: v1
kind: Service
metadata:
- name: {{ include "boilerplate-go-chart.fullname" . }}
+ name: {{ include "{{.ServiceName}}-chart.fullname" . }}
labels:
- app.kubernetes.io/name: {{ include "boilerplate-go-chart.name" . }}
- helm.sh/chart: {{ include "boilerplate-go-chart.chart" . }}
+ app.kubernetes.io/name: {{ include "{{.ServiceName}}-chart.name" . }}
+ helm.sh/chart: {{ include "{{.ServiceName}}-chart.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
@@ -19,5 +19,5 @@ spec:
protocol: TCP
name: {{ .Values.service.namePrivate }}
selector:
- app.kubernetes.io/name: {{ include "boilerplate-go-chart.name" . }}
+ app.kubernetes.io/name: {{ include "{{.ServiceName}}-chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
diff --git a/deployments/kubernetes/boilerplate-go-chart/values.yaml b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/values.yaml
similarity index 91%
rename from deployments/kubernetes/boilerplate-go-chart/values.yaml
rename to template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/values.yaml
index d6f84b8..f6f8bb0 100644
--- a/deployments/kubernetes/boilerplate-go-chart/values.yaml
+++ b/template/{{.ServiceName}}/deployments/kubernetes/{{.ServiceName}}-chart/values.yaml
@@ -1,7 +1,7 @@
-app: boilerplate-go
+app: {{.ServiceName}}
replicaCount: 1
image:
- repository: and07/boilerplate-go
+ repository: {{.User}}/{{.ServiceName}}
tag: latest
pullPolicy: IfNotPresent
@@ -9,8 +9,8 @@ nameOverride: ""
fullnameOverride: ""
service:
- name: boilerplate-go
- namePrivate: boilerplate-go-private
+ name: {{.ServiceName}}
+ namePrivate: {{.ServiceName}}-private
type: ClusterIP
externalPort: 8080
internalPort: 8080
diff --git a/deployments/log4j2.properties b/template/{{.ServiceName}}/deployments/log4j2.properties
similarity index 100%
rename from deployments/log4j2.properties
rename to template/{{.ServiceName}}/deployments/log4j2.properties
diff --git a/deployments/monitor/prometheus.yml b/template/{{.ServiceName}}/deployments/monitor/prometheus.yml
similarity index 100%
rename from deployments/monitor/prometheus.yml
rename to template/{{.ServiceName}}/deployments/monitor/prometheus.yml
diff --git a/docs/.keep b/template/{{.ServiceName}}/docs/.keep
similarity index 100%
rename from docs/.keep
rename to template/{{.ServiceName}}/docs/.keep
diff --git a/docs/README.md b/template/{{.ServiceName}}/docs/README.md
similarity index 100%
rename from docs/README.md
rename to template/{{.ServiceName}}/docs/README.md
diff --git a/examples/.keep b/template/{{.ServiceName}}/examples/.keep
similarity index 100%
rename from examples/.keep
rename to template/{{.ServiceName}}/examples/.keep
diff --git a/examples/README.md b/template/{{.ServiceName}}/examples/README.md
similarity index 100%
rename from examples/README.md
rename to template/{{.ServiceName}}/examples/README.md
diff --git a/githooks/.keep b/template/{{.ServiceName}}/githooks/.keep
similarity index 100%
rename from githooks/.keep
rename to template/{{.ServiceName}}/githooks/.keep
diff --git a/githooks/README.md b/template/{{.ServiceName}}/githooks/README.md
similarity index 100%
rename from githooks/README.md
rename to template/{{.ServiceName}}/githooks/README.md
diff --git a/go.mod b/template/{{.ServiceName}}/go.mod
similarity index 97%
rename from go.mod
rename to template/{{.ServiceName}}/go.mod
index e4db94d..4bad76d 100644
--- a/go.mod
+++ b/template/{{.ServiceName}}/go.mod
@@ -1,7 +1,7 @@
// +heroku goVersion go1.14
// +heroku install ./cmd/...
-module github.com/and07/boilerplate-go
+module github.com/{{.User}}/{{.ServiceName}}
go 1.14
diff --git a/go.sum b/template/{{.ServiceName}}/go.sum
similarity index 100%
rename from go.sum
rename to template/{{.ServiceName}}/go.sum
diff --git a/init/.keep b/template/{{.ServiceName}}/init/.keep
similarity index 100%
rename from init/.keep
rename to template/{{.ServiceName}}/init/.keep
diff --git a/init/README.md b/template/{{.ServiceName}}/init/README.md
similarity index 100%
rename from init/README.md
rename to template/{{.ServiceName}}/init/README.md
diff --git a/internal/README.md b/template/{{.ServiceName}}/internal/README.md
similarity index 100%
rename from internal/README.md
rename to template/{{.ServiceName}}/internal/README.md
diff --git a/internal/app/fastsrv/graceful.go b/template/{{.ServiceName}}/internal/app/fastsrv/graceful.go
similarity index 93%
rename from internal/app/fastsrv/graceful.go
rename to template/{{.ServiceName}}/internal/app/fastsrv/graceful.go
index fde535b..d25d606 100644
--- a/internal/app/fastsrv/graceful.go
+++ b/template/{{.ServiceName}}/internal/app/fastsrv/graceful.go
@@ -7,7 +7,7 @@ import (
"os/signal"
"syscall"
- log "github.com/and07/boilerplate-go/internal/pkg/logger"
+ log "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/logger"
"github.com/valyala/fasthttp"
)
diff --git a/internal/app/fastsrv/handle.go b/template/{{.ServiceName}}/internal/app/fastsrv/handle.go
similarity index 100%
rename from internal/app/fastsrv/handle.go
rename to template/{{.ServiceName}}/internal/app/fastsrv/handle.go
diff --git a/internal/app/fastsrv/srv.go b/template/{{.ServiceName}}/internal/app/fastsrv/srv.go
similarity index 95%
rename from internal/app/fastsrv/srv.go
rename to template/{{.ServiceName}}/internal/app/fastsrv/srv.go
index b82f9e7..4af7b7b 100644
--- a/internal/app/fastsrv/srv.go
+++ b/template/{{.ServiceName}}/internal/app/fastsrv/srv.go
@@ -4,7 +4,7 @@ import (
"context"
"net/http"
- log "github.com/and07/boilerplate-go/internal/pkg/logger"
+ log "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/logger"
"github.com/opentracing/opentracing-go"
"github.com/valyala/fasthttp"
)
diff --git a/internal/app/grpc/grpc.go b/template/{{.ServiceName}}/internal/app/grpc/grpc.go
similarity index 96%
rename from internal/app/grpc/grpc.go
rename to template/{{.ServiceName}}/internal/app/grpc/grpc.go
index 84b2a9a..d44b12b 100644
--- a/internal/app/grpc/grpc.go
+++ b/template/{{.ServiceName}}/internal/app/grpc/grpc.go
@@ -12,8 +12,8 @@ import (
"github.com/tmc/grpc-websocket-proxy/wsproxy"
"golang.org/x/sync/errgroup"
- //"github.com/and07/boilerplate-go/service"
- log "github.com/and07/boilerplate-go/internal/pkg/logger"
+ //"github.com/{{.User}}/{{.ServiceName}}/service"
+ log "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/logger"
_ "github.com/jnewmano/grpc-json-proxy/codec" // GRPC Proxy
"go.elastic.co/apm/module/apmgrpc"
"go.uber.org/zap"
diff --git a/internal/app/serv/.keep b/template/{{.ServiceName}}/internal/app/serv/.keep
similarity index 100%
rename from internal/app/serv/.keep
rename to template/{{.ServiceName}}/internal/app/serv/.keep
diff --git a/internal/app/serv/graceful.go b/template/{{.ServiceName}}/internal/app/serv/graceful.go
similarity index 100%
rename from internal/app/serv/graceful.go
rename to template/{{.ServiceName}}/internal/app/serv/graceful.go
diff --git a/internal/app/serv/handle.go b/template/{{.ServiceName}}/internal/app/serv/handle.go
similarity index 100%
rename from internal/app/serv/handle.go
rename to template/{{.ServiceName}}/internal/app/serv/handle.go
diff --git a/internal/app/serv/serv.go b/template/{{.ServiceName}}/internal/app/serv/serv.go
similarity index 95%
rename from internal/app/serv/serv.go
rename to template/{{.ServiceName}}/internal/app/serv/serv.go
index efcd184..188617e 100644
--- a/internal/app/serv/serv.go
+++ b/template/{{.ServiceName}}/internal/app/serv/serv.go
@@ -4,8 +4,8 @@ import (
"context"
"net/http"
- g "github.com/and07/boilerplate-go/internal/app/grpc"
- log "github.com/and07/boilerplate-go/internal/pkg/logger"
+ g "github.com/{{.User}}/{{.ServiceName}}/internal/app/grpc"
+ log "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/logger"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/opentracing/opentracing-go"
"golang.org/x/sync/errgroup"
diff --git a/internal/app/boilerplate/blockchain.go b/template/{{.ServiceName}}/internal/app/{{.ServiceName}}/blockchain.go
similarity index 94%
rename from internal/app/boilerplate/blockchain.go
rename to template/{{.ServiceName}}/internal/app/{{.ServiceName}}/blockchain.go
index aee7d5b..e58fdcb 100644
--- a/internal/app/boilerplate/blockchain.go
+++ b/template/{{.ServiceName}}/internal/app/{{.ServiceName}}/blockchain.go
@@ -1,4 +1,4 @@
-package boilerplate
+package {{.ServiceName}}
import (
"bytes"
@@ -6,7 +6,7 @@ import (
"encoding/json"
"time"
- "github.com/and07/boilerplate-go/api/gen-boilerplate-go/api"
+ "github.com/{{.User}}/{{.ServiceName}}/api/gen-{{.ServiceName}}/api"
"github.com/golang/protobuf/jsonpb"
_struct "github.com/golang/protobuf/ptypes/struct"
"google.golang.org/grpc/codes"
diff --git a/internal/app/boilerplate/boilerplate.go b/template/{{.ServiceName}}/internal/app/{{.ServiceName}}/boilerplate.go
similarity index 88%
rename from internal/app/boilerplate/boilerplate.go
rename to template/{{.ServiceName}}/internal/app/{{.ServiceName}}/boilerplate.go
index 3ad087c..d9bb368 100644
--- a/internal/app/boilerplate/boilerplate.go
+++ b/template/{{.ServiceName}}/internal/app/{{.ServiceName}}/boilerplate.go
@@ -1,9 +1,9 @@
-package boilerplate
+package {{.ServiceName}}
import (
"context"
- log "github.com/and07/boilerplate-go/internal/pkg/logger"
+ log "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/logger"
empty "github.com/golang/protobuf/ptypes/empty"
httpbody "google.golang.org/genproto/googleapis/api/httpbody"
)
diff --git a/internal/pkg/clickhouse/client.go b/template/{{.ServiceName}}/internal/pkg/clickhouse/client.go
similarity index 100%
rename from internal/pkg/clickhouse/client.go
rename to template/{{.ServiceName}}/internal/pkg/clickhouse/client.go
diff --git a/internal/pkg/elastic/client.go b/template/{{.ServiceName}}/internal/pkg/elastic/client.go
similarity index 100%
rename from internal/pkg/elastic/client.go
rename to template/{{.ServiceName}}/internal/pkg/elastic/client.go
diff --git a/internal/pkg/logger/logger.go b/template/{{.ServiceName}}/internal/pkg/logger/logger.go
similarity index 100%
rename from internal/pkg/logger/logger.go
rename to template/{{.ServiceName}}/internal/pkg/logger/logger.go
diff --git a/internal/pkg/logger/logrus/logger.go b/template/{{.ServiceName}}/internal/pkg/logger/logrus/logger.go
similarity index 100%
rename from internal/pkg/logger/logrus/logger.go
rename to template/{{.ServiceName}}/internal/pkg/logger/logrus/logger.go
diff --git a/internal/pkg/pubsub/pubsub.go b/template/{{.ServiceName}}/internal/pkg/pubsub/pubsub.go
similarity index 100%
rename from internal/pkg/pubsub/pubsub.go
rename to template/{{.ServiceName}}/internal/pkg/pubsub/pubsub.go
diff --git a/internal/pkg/pubsub/rabbitmq/client.go b/template/{{.ServiceName}}/internal/pkg/pubsub/rabbitmq/client.go
similarity index 98%
rename from internal/pkg/pubsub/rabbitmq/client.go
rename to template/{{.ServiceName}}/internal/pkg/pubsub/rabbitmq/client.go
index 7f14959..83d4a66 100644
--- a/internal/pkg/pubsub/rabbitmq/client.go
+++ b/template/{{.ServiceName}}/internal/pkg/pubsub/rabbitmq/client.go
@@ -4,7 +4,7 @@ import (
"context"
"log"
- "github.com/and07/boilerplate-go/internal/pkg/pubsub"
+ "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/pubsub"
"github.com/opentracing/opentracing-go"
"github.com/streadway/amqp"
)
diff --git a/internal/pkg/redis/.keep b/template/{{.ServiceName}}/internal/pkg/redis/.keep
similarity index 100%
rename from internal/pkg/redis/.keep
rename to template/{{.ServiceName}}/internal/pkg/redis/.keep
diff --git a/internal/pkg/redis/client.go b/template/{{.ServiceName}}/internal/pkg/redis/client.go
similarity index 100%
rename from internal/pkg/redis/client.go
rename to template/{{.ServiceName}}/internal/pkg/redis/client.go
diff --git a/internal/pkg/redis/dummy.go b/template/{{.ServiceName}}/internal/pkg/redis/dummy.go
similarity index 100%
rename from internal/pkg/redis/dummy.go
rename to template/{{.ServiceName}}/internal/pkg/redis/dummy.go
diff --git a/internal/pkg/template/template.go b/template/{{.ServiceName}}/internal/pkg/template/template.go
similarity index 98%
rename from internal/pkg/template/template.go
rename to template/{{.ServiceName}}/internal/pkg/template/template.go
index 8c65365..6a7e62f 100644
--- a/internal/pkg/template/template.go
+++ b/template/{{.ServiceName}}/internal/pkg/template/template.go
@@ -7,7 +7,7 @@ import (
"path/filepath"
"time"
- log "github.com/and07/boilerplate-go/internal/pkg/logger"
+ log "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/logger"
"github.com/oxtoacart/bpool"
)
diff --git a/internal/pkg/tracing/tracing.go b/template/{{.ServiceName}}/internal/pkg/tracing/tracing.go
similarity index 92%
rename from internal/pkg/tracing/tracing.go
rename to template/{{.ServiceName}}/internal/pkg/tracing/tracing.go
index ac9caa8..3abe88b 100644
--- a/internal/pkg/tracing/tracing.go
+++ b/template/{{.ServiceName}}/internal/pkg/tracing/tracing.go
@@ -5,7 +5,7 @@ import (
"io"
"time"
- log "github.com/and07/boilerplate-go/internal/pkg/logger"
+ log "github.com/{{.User}}/{{.ServiceName}}/internal/pkg/logger"
opentracing "github.com/opentracing/opentracing-go"
config "github.com/uber/jaeger-client-go/config"
)
diff --git a/internal/pkg/uaparser/uaparser.go b/template/{{.ServiceName}}/internal/pkg/uaparser/uaparser.go
similarity index 100%
rename from internal/pkg/uaparser/uaparser.go
rename to template/{{.ServiceName}}/internal/pkg/uaparser/uaparser.go
diff --git a/pkg/README.md b/template/{{.ServiceName}}/pkg/README.md
similarity index 100%
rename from pkg/README.md
rename to template/{{.ServiceName}}/pkg/README.md
diff --git a/pkg/_your_public_lib_/.keep b/template/{{.ServiceName}}/pkg/_your_public_lib_/.keep
similarity index 100%
rename from pkg/_your_public_lib_/.keep
rename to template/{{.ServiceName}}/pkg/_your_public_lib_/.keep
diff --git a/pkg/version/version.go b/template/{{.ServiceName}}/pkg/version/version.go
similarity index 100%
rename from pkg/version/version.go
rename to template/{{.ServiceName}}/pkg/version/version.go
diff --git a/scripts/.keep b/template/{{.ServiceName}}/scripts/.keep
similarity index 100%
rename from scripts/.keep
rename to template/{{.ServiceName}}/scripts/.keep
diff --git a/scripts/README.md b/template/{{.ServiceName}}/scripts/README.md
similarity index 100%
rename from scripts/README.md
rename to template/{{.ServiceName}}/scripts/README.md
diff --git a/test/.keep b/template/{{.ServiceName}}/test/.keep
similarity index 100%
rename from test/.keep
rename to template/{{.ServiceName}}/test/.keep
diff --git a/test/README.md b/template/{{.ServiceName}}/test/README.md
similarity index 100%
rename from test/README.md
rename to template/{{.ServiceName}}/test/README.md
diff --git a/third_party/.keep b/template/{{.ServiceName}}/third_party/.keep
similarity index 100%
rename from third_party/.keep
rename to template/{{.ServiceName}}/third_party/.keep
diff --git a/third_party/README.md b/template/{{.ServiceName}}/third_party/README.md
similarity index 100%
rename from third_party/README.md
rename to template/{{.ServiceName}}/third_party/README.md
diff --git a/tools/.keep b/template/{{.ServiceName}}/tools/.keep
similarity index 100%
rename from tools/.keep
rename to template/{{.ServiceName}}/tools/.keep
diff --git a/tools/README.md b/template/{{.ServiceName}}/tools/README.md
similarity index 100%
rename from tools/README.md
rename to template/{{.ServiceName}}/tools/README.md
diff --git a/tools/tools.go b/template/{{.ServiceName}}/tools/tools.go
similarity index 100%
rename from tools/tools.go
rename to template/{{.ServiceName}}/tools/tools.go
diff --git a/tpl/layouts/base.html b/template/{{.ServiceName}}/tpl/layouts/base.html
similarity index 94%
rename from tpl/layouts/base.html
rename to template/{{.ServiceName}}/tpl/layouts/base.html
index f3d64a0..d6f595d 100644
--- a/tpl/layouts/base.html
+++ b/template/{{.ServiceName}}/tpl/layouts/base.html
@@ -30,7 +30,7 @@