mirror of
https://github.com/gravitl/netmaker.git
synced 2026-01-17 00:08:42 +08:00
* feat(go): define flow events; * feat(go): improve structure; * feat(go): improve structure; * feat(go): remove old flow definitions; * feat(sql): add clickhouse init scripts; * feat(sql): add protobuf spec; * fix(sql): store ip as string; * feat(go): move proto def to grpc dir; * feat(go): use node instead of host as type; optimize protobuf defs; * feat(go): add clickhouse db support; add endpoint to query flows; * fix(go): fix clickhouse config; * fix(go): use error response structure to report error; * feat(go): pass flow logging status to netclient; * feat(go): add peer ip identity map to host peer info; * feat(go): remove prefix from participant obj fields; * feat(go): add flow logs enabled field to host; * feat(go): add filtering to get flow api; * feat(go): fix record struct; * feat(go): add exporter url to server config; * feat(go): add exporter url to server config; * feat(go): enable flow logs by default; * feat(go): update nm-quick.sh; * feat(go): update nm-quick.sh; * feat(go): update nm-quick.sh; * feat(go): update nm-quick.sh; * feat(go): add db initialization logic; * feat(go): filter by network id; * fix(go): connection issue; * fix(go): connection issue; * fix(go): golang builder version; * feat(go): add server settings for flow logs; * feat(go): initialize clickhouse in pro; check for retention; * feat(go): add exporter feature flags; * feat(go): add grpc behind caddy; * feat(go): expose ports correctly; * fix(go): grpc caddyfile config; * fix(go): publish exporter feature flags on license validation; * fix(go): set server name for netmaker exporter; * fix(go): set server name for netmaker exporter; * fix(go): check for nil cancel func; * fix(go): add flow logs field to api host; * fix(go): add flow logs field to api host; * fix(go): remove port from grpc setting; * chore(go): tabs; * feat(go): introduce egress range participant type;. * feat(go): rename egress range to egress route for uniform language; * feat(go): rename egress range to egress route for uniform language; * feat: add peer addr identity map to host peer update; * feat: add address identity map to host peer update; * feat: add address identity map to host peer update; * feat: set correct from and to args; * feat: add support for filtering by node; * feat: use corresponding base image; * feat: update dockerfile base image version; * fix: disable flow logs for all host when global settings are changed;
74 lines
1.6 KiB
Go
74 lines
1.6 KiB
Go
package servercfg
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/gravitl/netmaker/config"
|
|
)
|
|
|
|
func GetSQLConf() config.SQLConfig {
|
|
var cfg config.SQLConfig
|
|
cfg.Host = GetSQLHost()
|
|
cfg.Port = GetSQLPort()
|
|
cfg.Username = GetSQLUser()
|
|
cfg.Password = GetSQLPass()
|
|
cfg.DB = GetSQLDB()
|
|
cfg.SSLMode = GetSQLSSLMode()
|
|
return cfg
|
|
}
|
|
func GetSQLHost() string {
|
|
host := "localhost"
|
|
if os.Getenv("SQL_HOST") != "" {
|
|
host = os.Getenv("SQL_HOST")
|
|
} else if config.Config.SQL.Host != "" {
|
|
host = config.Config.SQL.Host
|
|
}
|
|
return host
|
|
}
|
|
func GetSQLPort() int32 {
|
|
port := int32(5432)
|
|
envport, err := strconv.Atoi(os.Getenv("SQL_PORT"))
|
|
if err == nil && envport != 0 {
|
|
port = int32(envport)
|
|
} else if config.Config.SQL.Port != 0 {
|
|
port = config.Config.SQL.Port
|
|
}
|
|
return port
|
|
}
|
|
func GetSQLUser() string {
|
|
user := "postgres"
|
|
if os.Getenv("SQL_USER") != "" {
|
|
user = os.Getenv("SQL_USER")
|
|
} else if config.Config.SQL.Username != "" {
|
|
user = config.Config.SQL.Username
|
|
}
|
|
return user
|
|
}
|
|
func GetSQLPass() string {
|
|
pass := "nopass"
|
|
if os.Getenv("SQL_PASS") != "" {
|
|
pass = os.Getenv("SQL_PASS")
|
|
} else if config.Config.SQL.Password != "" {
|
|
pass = config.Config.SQL.Password
|
|
}
|
|
return pass
|
|
}
|
|
func GetSQLDB() string {
|
|
db := "netmaker"
|
|
if os.Getenv("SQL_DB") != "" {
|
|
db = os.Getenv("SQL_DB")
|
|
} else if config.Config.SQL.DB != "" {
|
|
db = config.Config.SQL.DB
|
|
}
|
|
return db
|
|
}
|
|
func GetSQLSSLMode() string {
|
|
sslmode := "disable"
|
|
if os.Getenv("SQL_SSL_MODE") != "" {
|
|
sslmode = os.Getenv("SQL_SSL_MODE")
|
|
} else if config.Config.SQL.SSLMode != "" {
|
|
sslmode = config.Config.SQL.SSLMode
|
|
}
|
|
return sslmode
|
|
}
|