Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move all scaffolding repo to devstream/staging/ #1338

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/best-practices/gitops.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ tools:
repoType: github
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-python
repo: dtm-repo-scaffolding-python
repoType: github
vars:
imageRepo: [[ dockerUser ]]/[[ app ]]
Expand Down
2 changes: 1 addition & 1 deletion docs/best-practices/gitops.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ tools:
repoType: github
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-python
repo: dtm-repo-scaffolding-python
repoType: github
vars:
imageRepo: [[ dockerUser ]]/[[ app ]]
Expand Down
8 changes: 4 additions & 4 deletions docs/core-concepts/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ tools:
repoType: github
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-python
repo: dtm-repo-scaffolding-python
repoType: github
vars:
imageRepo: [[ dockerUser ]]/[[ app ]]
Expand Down Expand Up @@ -182,7 +182,7 @@ apps:
scmType: github
owner: devstream-io
org: devstream-io # either owner or org must exist
name: dtm-scaffolding-golang
name: dtm-repo-scaffolding-golang
url: github.com/devstream-io/repo-name # optional. if exists, no need for the scm/owner/org/name sections
vars: # optional
foo: bar # variables used for repoTemplate specifically
Expand Down Expand Up @@ -211,7 +211,7 @@ apps:
repo:
url: github.com/ironcore864/myapp1
repoTemplate:
url: github.com/devstream-io/dtm-scaffolding-python
url: github.com/devstream-io/dtm-repo-scaffolding-python
ci:
- type: githubactions
cd:
Expand Down Expand Up @@ -276,7 +276,7 @@ apps:
repo:
url: github.com/ironcore864/myapp1
repoTemplate:
url: github.com/devstream-io/dtm-scaffolding-python
url: github.com/devstream-io/dtm-repo-scaffolding-python
ci:
- type: githubactions
cd:
Expand Down
2 changes: 1 addition & 1 deletion docs/core-concepts/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ tools:
imageRepo: "ironcore864/golang-demo"
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-golang
repo: dtm-repo-scaffolding-golang
repoType: github
- name: argocd
instanceID: default
Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/argocdapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ tools:
imageRepo: "[[ dockerhubUsername ]]/[[ repoName ]]"
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-golang
repo: dtm-repo-scaffolding-golang
repoType: github
- name: go-webapp-argocd-deploy
plugin: argocdapp
Expand Down
8 changes: 4 additions & 4 deletions docs/plugins/repo-scaffolding.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ These repos are official scaffolding repo to use for `sourceRepo` config, You ca

| language | org | repo |
|-------------|---------------|----------------------------|
| Golang | devstream-io | dtm-scaffolding-golang |
| Golang | devstream-io | dtm-scaffolding-golang-cli |
| Golang | devstream-io | dtm-repo-scaffolding-golang |
| Golang | devstream-io | dtm-repo-scaffolding-golang-cli |
| Java Spring | spring-guides | gs-spring-boot |


Expand All @@ -113,7 +113,7 @@ tools:
scmType: github
sourceRepo:
org: devstream-io
name: dtm-scaffolding-golang
name: dtm-repo-scaffolding-golang
scmType: github
vars:
imageRepo: dtm-test/golang-repo
Expand All @@ -136,7 +136,7 @@ tools:
scmType: github
sourceRepo:
org: devstream-io
name: dtm-scaffolding-golang-cli
name: dtm-repo-scaffolding-golang-cli
scmType: github
```

Expand Down
2 changes: 1 addition & 1 deletion examples/gitops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tools:
repoType: github
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-golang
repo: dtm-repo-scaffolding-golang
repoType: github
vars:
imageRepo: "[[ dockerhubUsername ]]/[[ repoName ]]"
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tools:
repoType: github
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-golang
repo: dtm-repo-scaffolding-golang
repoType: github
vars:
imageRepo: YOUR_DOCKER_USERNAME/go-webapp-devstream-demo
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/configmanager/configmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ apps:
scmType: github
owner: devstream-io
org: devstream-io # choose between owner and org
name: dtm-scaffolding-golang
url: github.com/devstream-io/dtm-scaffolding-golang # optional,if url is specified,we can infer scm/owner/org/name from url
name: dtm-repo-scaffolding-golang
url: github.com/devstream-io/dtm-repo-scaffolding-golang # optional,if url is specified,we can infer scm/owner/org/name from url
ci:
- type: template
templateName: ci-pipeline-for-gh-actions
Expand Down Expand Up @@ -199,9 +199,9 @@ pipelineTemplates:
},
"sourceRepo": RawOptions{
"scmType": "github",
"url": git.ScmURL("github.com/devstream-io/dtm-scaffolding-golang"),
"url": git.ScmURL("github.com/devstream-io/dtm-repo-scaffolding-golang"),
"owner": "devstream-io",
"name": "dtm-scaffolding-golang",
"name": "dtm-repo-scaffolding-golang",
"org": "devstream-io",
},
"vars": RawOptions{},
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/show/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ tools:
repoType: github
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-golang
repo: dtm-repo-scaffolding-golang
repoType: github
2 changes: 1 addition & 1 deletion internal/pkg/show/config/templates/gitops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tools:
repoType: github
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-golang
repo: dtm-repo-scaffolding-golang
repoType: github
vars:
imageRepo: "[[ dockerhubUsername ]]/[[ repoName ]]"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/show/config/templates/quickstart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tools:
repoType: github
sourceRepo:
org: devstream-io
repo: dtm-scaffolding-golang
repo: dtm-repo-scaffolding-golang
repoType: github
vars:
imageRepo: YOUR_DOCKER_USERNAME/go-webapp-devstream-demo
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/scm/github/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (c *Client) DownloadAsset(tagName, assetName, fileName string) error {
}

// 3. get download url
// format: https://github.com/merico-dev/dtm-scaffolding-golang/releases/download/v0.0.1/dtm-scaffolding-golang-v0.0.1.tar.gz
// format: https://github.com/merico-dev/dtm-repo-scaffolding-golang/releases/download/v0.0.1/dtm-repo-scaffolding-golang-v0.0.1.tar.gz
var downloadUrl string
for _, a := range assets {
if a.GetName() == assetName {
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/scm/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ var (
OptNotNeedAuth = &git.RepoInfo{
Owner: "",
Org: "devstream-io",
Repo: "dtm-scaffolding-golang",
Repo: "dtm-repo-scaffolding-golang",
}
OptNeedAuth = &git.RepoInfo{
Owner: "",
Org: "devstream-io",
Repo: "dtm-scaffolding-golang",
Repo: "dtm-repo-scaffolding-golang",
NeedAuth: true,
}
)
Expand Down
7 changes: 6 additions & 1 deletion staging/dtm-repo-scaffolding-golang-cli/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dtm-scaffolding-golang
# dtm-repo-scaffolding-golang-cli

This repo contains templates used by DevStream plugin "repo-scaffolding" (thereafter: the plugin).

Expand Down Expand Up @@ -26,3 +26,8 @@ Repo:
Owner: ironcore864
Name: my-hello-world
```

## Where does this repo come from?

`dtm-repo-scaffolding-golang-cli` is synced from https://github.com/devstream-io/devstream/blob/main/staging/dtm-repo-scaffolding-golang-cli.
Code changes are made in that location, merged into `devstream-io/devstream` and later synced here.
15 changes: 15 additions & 0 deletions staging/dtm-repo-scaffolding-golang-gin/.gitignore
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/
12 changes: 12 additions & 0 deletions staging/dtm-repo-scaffolding-golang-gin/Dockerfile.tpl
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
22 changes: 22 additions & 0 deletions staging/dtm-repo-scaffolding-golang-gin/Makefile.tpl
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
36 changes: 36 additions & 0 deletions staging/dtm-repo-scaffolding-golang-gin/README.md
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.
11 changes: 11 additions & 0 deletions staging/dtm-repo-scaffolding-golang-gin/README.md.tpl
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 staging/dtm-repo-scaffolding-golang-gin/cmd/_app_name_/main.go.tpl
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")
}
22 changes: 22 additions & 0 deletions staging/dtm-repo-scaffolding-golang-gin/go.mod.tpl
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
)
Loading