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

config tips and config distinctions & help reminder #100

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
File renamed without changes.
45 changes: 45 additions & 0 deletions config/prod_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
server:
env: "debug"
address: "127.0.0.1"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this a production config, we need modify some params.
env: release
address: 0.0.0.0

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
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultConfigPath -> defaultConfig

printVersion = flag.Bool("v", false, "print version")
appConfig = flag.String("config", defaultConfigPath, "application config path")
)

// @title Weave Server API
Expand Down Expand Up @@ -45,6 +46,10 @@ func main() {
logger.Fatalf("Failed to parse config: %v", err)
}

if *appConfig != defaultConfigPath {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better print config path rather than a info

if appConfig != nil {
  logger.Info(App config from "%s", *appConfig)
}

version.ConfigPathPrint()
}

s, err := server.New(conf, logger)
if err != nil {
logger.Fatalf("Init server failed: %v", err)
Expand Down
4 changes: 4 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ func Print() {
func Get() *Version {
return version
}

func ConfigPathPrint() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We donot need to change this file, just print info in main.go

fmt.Println("setting application config path successfully!")
}