From 5a1a88543ba3e2b533b5adbf5224d9426a827e15 Mon Sep 17 00:00:00 2001 From: shuwu Date: Sun, 4 Feb 2024 17:26:57 +0800 Subject: [PATCH 1/3] config tips and distinctions --- .idea/.gitignore | 8 +++++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ .idea/weave.iml | 9 ++++++ README.md | 2 +- README_zh.md | 2 +- config/{app.yaml => dev_config.yaml} | 0 config/prod_config.yaml | 45 ++++++++++++++++++++++++++++ main.go | 9 ++++-- pkg/version/version.go | 4 +++ 10 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/weave.iml rename config/{app.yaml => dev_config.yaml} (100%) create mode 100644 config/prod_config.yaml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..a21421f0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 数据源本地存储已忽略文件 +/../../../../../../:\Program Files\goWorkSpace\src\weave\.idea/dataSources/ +/dataSources.local.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..c75838b0 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/weave.iml b/.idea/weave.iml new file mode 100644 index 00000000..5e764c4f --- /dev/null +++ b/.idea/weave.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index fc615a5b..7121dea6 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,6 @@ More ui in [img](./document/img/) ### Documents - [Contributing](./CONTRIBUTING.md), contributing details -- [Config](./config/app.yaml), your can enable docker/kubernetes in config +- [Config](config/dev_config.yaml), your can enable docker/kubernetes in config - [OAuth](./document/oauth.md) - [RBAC](./document/authentication.md) diff --git a/README_zh.md b/README_zh.md index 331004a4..3e40b053 100644 --- a/README_zh.md +++ b/README_zh.md @@ -191,6 +191,6 @@ make docker-run-ui ### 文档 - [Contributing](./CONTRIBUTING.md),为此项目提交贡献 -- [Config](./config/app.yaml), 配置对应功能是否开启 +- [Config](config/dev_config.yaml), 配置对应功能是否开启 - [OAuth](./document/oauth.md) - [RBAC](./document/authentication.md) diff --git a/config/app.yaml b/config/dev_config.yaml similarity index 100% rename from config/app.yaml rename to config/dev_config.yaml diff --git a/config/prod_config.yaml b/config/prod_config.yaml new file mode 100644 index 00000000..139c07c5 --- /dev/null +++ b/config/prod_config.yaml @@ -0,0 +1,45 @@ +server: + env: "debug" + address: "127.0.0.1" + port: 8080 + gracefulShutdownPeriod: 30 + rateLimits: + - limitType: "server" + burst: 500 + qps: 100 + cacheSize: 1 + - limitType: "ip" + burst: 50 + qps: 10 + cacheSize: 2048 + jwtSecret: weaveserver + +docker: + enable: true # enable docker, start dockerd at first + host: unix:///var/run/docker.sock + +kubernetes: + enable: true # set `KUBECONFIG` env or flag --kubeconfig at first + watchResources: + - "Deployment.v1.apps" + - "Pod.v1." + - "Namespace.v1." + +db: + port: 5432 + host: "localhost" + name: "weave" + user: "postgres" + password: "123456" + migrate: true + +redis: + enable: true + port: 6379 + host: "localhost" + password: "123456" + +oauth: + github: + clientId: "85db232fde2c9320ece7" # set your client id + clientSecret: "" # set your client secret diff --git a/main.go b/main.go index 775f83c6..2683bbdf 100644 --- a/main.go +++ b/main.go @@ -12,8 +12,9 @@ import ( ) var ( - printVersion = flag.Bool("v", false, "print version") - appConfig = flag.String("config", "config/app.yaml", "application config path") + defaultConfigPath = "config/dev_config.yaml" + printVersion = flag.Bool("v", false, "print version") + appConfig = flag.String("config", defaultConfigPath, "application config path") ) // @title Weave Server API @@ -45,6 +46,10 @@ func main() { logger.Fatalf("Failed to parse config: %v", err) } + if *appConfig != defaultConfigPath { + version.ConfigPathPrint() + } + s, err := server.New(conf, logger) if err != nil { logger.Fatalf("Init server failed: %v", err) diff --git a/pkg/version/version.go b/pkg/version/version.go index b84424d2..083874cb 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -48,3 +48,7 @@ func Print() { func Get() *Version { return version } + +func ConfigPathPrint() { + fmt.Println("setting application config path successfully!") +} From eff5710429914351d1ab645e91e28fc3e2dde441 Mon Sep 17 00:00:00 2001 From: shuwu Date: Sun, 4 Feb 2024 17:28:00 +0800 Subject: [PATCH 2/3] config tips and distinctions --- .idea/.gitignore | 8 -------- .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ .idea/weave.iml | 9 --------- 4 files changed, 31 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/weave.iml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index a21421f0..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 默认忽略的文件 -/shelf/ -/workspace.xml -# 数据源本地存储已忽略文件 -/../../../../../../:\Program Files\goWorkSpace\src\weave\.idea/dataSources/ -/dataSources.local.xml -# 基于编辑器的 HTTP 客户端请求 -/httpRequests/ diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index c75838b0..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/weave.iml b/.idea/weave.iml deleted file mode 100644 index 5e764c4f..00000000 --- a/.idea/weave.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file From efde9868590f5e14bc3bb6136b99ba9c251c5e46 Mon Sep 17 00:00:00 2001 From: shuwu Date: Mon, 5 Feb 2024 09:25:54 +0800 Subject: [PATCH 3/3] - --- .gitignore | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index 0160c662..b321d069 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,14 @@ /bin cover.out coverage.txt + +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Go workspace file +go.work +.idea/