-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1338 from merico-dev/chore-ht
refactor: move all scaffolding repo to devstream/staging/
- Loading branch information
Showing
59 changed files
with
636 additions
and
31 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
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
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
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
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
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
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
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,15 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ |
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,12 @@ | ||
FROM golang:alpine AS build-env | ||
WORKDIR $GOPATH/src/github.com/[[.Repo.Owner]]/[[.Repo.Name]] | ||
COPY . . | ||
RUN apk add git | ||
RUN go get ./... && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app cmd/[[.AppName]]/main.go | ||
|
||
FROM alpine | ||
WORKDIR /app | ||
COPY --from=build-env /go/src/github.com/[[.Repo.Owner]]/[[.Repo.Name]]/app /app/ | ||
CMD ["./app"] | ||
USER 1000 | ||
EXPOSE 8080/tcp |
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,22 @@ | ||
SHELL := /bin/bash | ||
BASEDIR = $(shell pwd) | ||
|
||
.PHONY: help | ||
help: | ||
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: install | ||
install: ## Install dependencies | ||
@go mod download | ||
@go mod vendor | ||
|
||
.PHONY: dev | ||
dev: ## Run with Dev | ||
@go run cmd/[[.AppName]]/main.go | ||
|
||
.PHONY: build | ||
build: ## Build todomvc | ||
@go build -o build/[[.AppName]] cmd/[[.AppName]]/main.go | ||
|
||
clean: ### Remove build dir | ||
@rm -rf build |
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,36 @@ | ||
# dtm-repo-scaffolding-golang-gin | ||
|
||
This repo contains templates used by DevStream plugin "repo-scaffolding" (thereafter: the plugin). | ||
|
||
This repo isn't intended to be used directly without DevStream. It should only be consumed by the plugin automatically. | ||
|
||
The plugin (together with this repo of templates) can create a repo in GitHub and set up the project layout and initialize the reop with necessary files that are typical for a Go web app. The followings can be created automatically: | ||
|
||
- a Go web app example (source code from [here](https://go.dev/doc/tutorial/web-service-gin)) with the [Gin Web Framework](https://github.com/gin-gonic/gin) | ||
- directory structure, following [Standard Go Project Layout](https://github.com/golang-standards/project-layout) best practice | ||
- `.gitignore`, generated by [Toptal | gitignore.io](https://www.toptal.com/developers/gitignore/api/go,vim,macos,visualstudiocode) with minimum changes | ||
- Makefile, with install/dev/build/clean | ||
- Dockerfile, with multistage build | ||
- a simplified Helm chart with Deployment and Service | ||
|
||
## Usage | ||
|
||
- Render all files using go template whose name end with `.tpl` suffix. | ||
- Files whose name don't end with `.tpl` extension don't need to be rendered. | ||
- subdirectory "helm/**_app_name_**" (the **_app_name_** part) should be rendered with `AppName` | ||
- subdicrectory "cmd/**_app_name_**" (the **_app_name_** part) should be rendered with `AppName` | ||
|
||
Example of required parameters to render these templates: | ||
|
||
```yaml | ||
AppName: my-hello-world | ||
Repo: | ||
Owner: ironcore864 | ||
Name: my-hello-world | ||
ImageRepo: ironcore864/my-hello-world # dockerhub | ||
``` | ||
## Where does this repo come from? | ||
`dtm-repo-scaffolding-golang-gin` is synced from https://github.com/devstream-io/devstream/blob/main/staging/dtm-repo-scaffolding-golang-gin. | ||
Code changes are made in that location, merged into `devstream-io/devstream` and later synced here. |
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,11 @@ | ||
# [[.AppName]] | ||
|
||
This is a repo for app [[.AppName]]; bootstrapped by DevStream. | ||
|
||
By default, the automatically generated scaffolding contains: | ||
|
||
- a piece of sample go web app code using the [Gin Web Framework](https://github.com/gin-gonic/gin) | ||
- .gitignore | ||
- Makefile | ||
- Dockerfile | ||
- Helm chart |
17 changes: 17 additions & 0 deletions
17
staging/dtm-repo-scaffolding-golang-gin/cmd/_app_name_/main.go.tpl
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,17 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
|
||
"github.com/[[.Repo.Owner]]/[[.Repo.Name]]/internal/pkg/album" | ||
) | ||
|
||
func main() { | ||
router := gin.Default() | ||
router.GET("/albums", album.GetAlbums) | ||
router.GET("/albums/:id", album.GetAlbumByID) | ||
router.POST("/albums", album.PostAlbums) | ||
router.Run("localhost:8080") | ||
} |
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,22 @@ | ||
module github.com/[[.Repo.Owner]]/[[.Repo.Name]] | ||
|
||
go 1.17 | ||
|
||
require github.com/gin-gonic/gin v1.7.7 | ||
|
||
require ( | ||
github.com/gin-contrib/sse v0.1.0 // indirect | ||
github.com/go-playground/locales v0.13.0 // indirect | ||
github.com/go-playground/universal-translator v0.17.0 // indirect | ||
github.com/go-playground/validator/v10 v10.4.1 // indirect | ||
github.com/golang/protobuf v1.3.3 // indirect | ||
github.com/json-iterator/go v1.1.9 // indirect | ||
github.com/leodido/go-urn v1.2.0 // indirect | ||
github.com/mattn/go-isatty v0.0.12 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect | ||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect | ||
github.com/ugorji/go/codec v1.1.7 // indirect | ||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect | ||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect | ||
gopkg.in/yaml.v2 v2.2.8 // indirect | ||
) |
Oops, something went wrong.