feat: use env prefix
This commit is contained in:
parent
b5f8488af3
commit
809c99e398
1 changed files with 10 additions and 8 deletions
|
|
@ -6,19 +6,21 @@ import (
|
||||||
|
|
||||||
// Config holds the application configuration
|
// Config holds the application configuration
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ServerAddress string `env:"MCP_REGISTRY_SERVER_ADDRESS" envDefault:":8080"`
|
ServerAddress string `env:"SERVER_ADDRESS" envDefault:":8080"`
|
||||||
DatabaseURL string `env:"MCP_REGISTRY_DATABASE_URL" envDefault:"mongodb://localhost:27017"`
|
DatabaseURL string `env:"DATABASE_URL" envDefault:"mongodb://localhost:27017"`
|
||||||
DatabaseName string `env:"MCP_REGISTRY_DATABASE_NAME" envDefault:"mcp-registry"`
|
DatabaseName string `env:"DATABASE_NAME" envDefault:"mcp-registry"`
|
||||||
CollectionName string `env:"MCP_REGISTRY_COLLECTION_NAME" envDefault:"servers_v2"`
|
CollectionName string `env:"COLLECTION_NAME" envDefault:"servers_v2"`
|
||||||
LogLevel string `env:"MCP_REGISTRY_LOG_LEVEL" envDefault:"info"`
|
LogLevel string `env:"LOG_LEVEL" envDefault:"info"`
|
||||||
Environment string `env:"MCP_REGISTRY_ENVIRONMENT" envDefault:"production"`
|
Environment string `env:"ENVIRONMENT" envDefault:"production"`
|
||||||
Version string `env:"MCP_REGISTRY_VERSION" envDefault:"dev"`
|
Version string `env:"VERSION" envDefault:"dev"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfig creates a new configuration with default values
|
// NewConfig creates a new configuration with default values
|
||||||
func NewConfig() *Config {
|
func NewConfig() *Config {
|
||||||
var cfg Config
|
var cfg Config
|
||||||
err := env.Parse(&cfg)
|
err := env.ParseWithOptions(&cfg, env.Options{
|
||||||
|
Prefix: "MCP_REGISTRY_",
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue