Skip to content

Commit b5d8cb7

Browse files
committed
init code
1 parent 2e4f288 commit b5d8cb7

File tree

37 files changed

+493
-92
lines changed

37 files changed

+493
-92
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* linguist-language=GO

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.buildpath
2+
.hgignore.swp
3+
.project
4+
.orig
5+
.swp
6+
.idea/
7+
.settings/
8+
.vscode/
9+
bin/
10+
**/.DS_Store
11+
main
12+
output/
13+
manifest/output/
14+
temp/

Makefile

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
ROOT_DIR = $(shell pwd)
2+
NAMESPACE = "default"
3+
DEPLOY_NAME = "template-single"
4+
DOCKER_NAME = "template-single"
5+
6+
# Install/Update to the latest CLI tool.
7+
.PHONY: cli
8+
cli:
9+
@set -e; \
10+
wget -O gf https://github.com/gogf/gf/releases/latest/download/gf_$(shell go env GOOS)_$(shell go env GOARCH) && \
11+
chmod +x gf && \
12+
./gf install -y && \
13+
rm ./gf
14+
15+
16+
# Check and install CLI tool.
17+
.PHONY: cli.install
18+
cli.install:
19+
@set -e; \
20+
gf -v > /dev/null 2>&1 || if [[ "$?" -ne "0" ]]; then \
21+
echo "GoFame CLI is not installed, start proceeding auto installation..."; \
22+
make cli; \
23+
fi;
24+
25+
26+
# Generate Go files for DAO/DO/Entity.
27+
.PHONY: dao
28+
dao: cli.install
29+
@gf gen dao
30+
31+
# Generate Go files for Service.
32+
.PHONY: service
33+
service: cli.install
34+
@gf gen service
35+
36+
# Build image, deploy image and yaml to current kubectl environment and make port forward to local machine.
37+
.PHONY: start
38+
start:
39+
@set -e; \
40+
make image; \
41+
make deploy; \
42+
make port;
43+
44+
# Build docker image.
45+
.PHONY: image
46+
image: cli.install
47+
$(eval _TAG = $(shell git log -1 --format="%cd.%h" --date=format:"%Y%m%d%H%M%S"))
48+
ifneq (, $(shell git status --porcelain 2>/dev/null))
49+
$(eval _TAG = $(_TAG).dirty)
50+
endif
51+
$(eval _TAG = $(if ${TAG}, ${TAG}, $(_TAG)))
52+
$(eval _PUSH = $(if ${PUSH}, ${PUSH}, ))
53+
@gf docker -p -b "-a amd64 -s linux -p temp" -tn $(DOCKER_NAME):${_TAG};
54+
55+
56+
# Build docker image and automatically push to docker repo.
57+
.PHONY: image.push
58+
image.push:
59+
@make image PUSH=-p;
60+
61+
62+
# Deploy image and yaml to current kubectl environment.
63+
.PHONY: deploy
64+
deploy:
65+
$(eval _TAG = $(if ${TAG}, ${TAG}, develop))
66+
67+
@set -e; \
68+
mkdir -p $(ROOT_DIR)/temp/kustomize;\
69+
cd $(ROOT_DIR)/manifest/deploy/kustomize/overlays/${_TAG};\
70+
kustomize build > $(ROOT_DIR)/temp/kustomize.yaml;\
71+
kubectl apply -f $(ROOT_DIR)/temp/kustomize.yaml; \
72+
kubectl patch -n $(NAMESPACE) deployment/$(DEPLOY_NAME) -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"$(shell date +%s)\"}}}}}";
73+
74+

README.md

+9-92
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,9 @@
1-
# Seifu Gateway
2-
3-
4-
5-
## Getting started
6-
7-
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8-
9-
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10-
11-
## Add your files
12-
13-
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14-
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15-
16-
```
17-
cd existing_repo
18-
git remote add origin https://my.sbchild.top:81/gl/server-awesome/gateway/seifu-gateway.git
19-
git branch -M main
20-
git push -uf origin main
21-
```
22-
23-
## Integrate with your tools
24-
25-
- [ ] [Set up project integrations](https://my.sbchild.top:81/gl/server-awesome/gateway/seifu-gateway/-/settings/integrations)
26-
27-
## Collaborate with your team
28-
29-
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33-
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34-
35-
## Test and Deploy
36-
37-
Use the built-in continuous integration in GitLab.
38-
39-
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40-
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41-
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42-
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44-
45-
***
46-
47-
# Editing this README
48-
49-
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
50-
51-
## Suggestions for a good README
52-
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
53-
54-
## Name
55-
Choose a self-explaining name for your project.
56-
57-
## Description
58-
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
59-
60-
## Badges
61-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
62-
63-
## Visuals
64-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
65-
66-
## Installation
67-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
68-
69-
## Usage
70-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
71-
72-
## Support
73-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
74-
75-
## Roadmap
76-
If you have ideas for releases in the future, it is a good idea to list them in the README.
77-
78-
## Contributing
79-
State if you are open to contributions and what your requirements are for accepting them.
80-
81-
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
82-
83-
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
84-
85-
## Authors and acknowledgment
86-
Show your appreciation to those who have contributed to the project.
87-
88-
## License
89-
For open source projects, say how it is licensed.
90-
91-
## Project status
92-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
1+
# GoFrame Template For SingleRepo
2+
3+
Project Makefile Commands:
4+
- `make cli`: Install or Update to the latest GoFrame CLI tool.
5+
- `make dao`: Generate go files for `Entity/DAO/DO` according to the configuration file from `hack` folder.
6+
- `make service`: Parse `logic` folder to generate interface go files into `service` folder.
7+
- `make image TAG=xxx`: Run `docker build` to build image according `manifest/docker`.
8+
- `make image.push TAG=xxx`: Run `docker build` and `docker push` to build and push image according `manifest/docker`.
9+
- `make deploy TAG=xxx`: Run `kustomize build` to build and deploy deployment to kubernetes server group according `manifest/deploy`.

api/v1/hello.go

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package v1
2+
3+
import (
4+
"github.com/gogf/gf/v2/frame/g"
5+
)
6+
7+
type HelloReq struct {
8+
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"`
9+
}
10+
type HelloRes struct {
11+
g.Meta `mime:"text/html" example:"string"`
12+
}

go.mod

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module seifu-gw
2+
3+
go 1.20
4+
5+
require github.com/gogf/gf/v2 v2.3.2
6+
7+
require (
8+
github.com/BurntSushi/toml v1.2.1 // indirect
9+
github.com/clbanning/mxj/v2 v2.5.7 // indirect
10+
github.com/fatih/color v1.14.1 // indirect
11+
github.com/fsnotify/fsnotify v1.6.0 // indirect
12+
github.com/go-logr/logr v1.2.3 // indirect
13+
github.com/go-logr/stdr v1.2.2 // indirect
14+
github.com/gorilla/websocket v1.5.0 // indirect
15+
github.com/grokify/html-strip-tags-go v0.0.1 // indirect
16+
github.com/magiconair/properties v1.8.7 // indirect
17+
github.com/mattn/go-colorable v0.1.13 // indirect
18+
github.com/mattn/go-isatty v0.0.17 // indirect
19+
github.com/mattn/go-runewidth v0.0.14 // indirect
20+
github.com/olekukonko/tablewriter v0.0.5 // indirect
21+
github.com/rivo/uniseg v0.4.4 // indirect
22+
go.opentelemetry.io/otel v1.14.0 // indirect
23+
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
24+
go.opentelemetry.io/otel/trace v1.14.0 // indirect
25+
golang.org/x/net v0.7.0 // indirect
26+
golang.org/x/sys v0.5.0 // indirect
27+
golang.org/x/text v0.7.0 // indirect
28+
gopkg.in/yaml.v3 v3.0.1 // indirect
29+
)

0 commit comments

Comments
 (0)