Skip to content
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
8 changes: 4 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ func LoadConfigFromEnv() (*Config, error) {
config.TrustLevel = trustLevel
}

if dryRun := os.Getenv("DRY_RUN"); dryRun == "true" || dryRun == "1" {
config.DryRun = true
if dryRun, ok := os.LookupEnv("DRY_RUN"); ok {
config.DryRun = dryRun == "true" || dryRun == "1"
}

if endpoints := os.Getenv("GITOPIA_GRPC_ENDPOINTS"); endpoints != "" {
Expand All @@ -156,8 +156,8 @@ func LoadConfigFromEnv() (*Config, error) {
config.HTTPPort = port
}

if v := os.Getenv("APPROVAL_MODE"); v == "true" || v == "1" {
config.ApprovalMode = true
if v, ok := os.LookupEnv("APPROVAL_MODE"); ok {
config.ApprovalMode = v == "true" || v == "1"
}

if v := os.Getenv("APPROVAL_TTL"); v != "" {
Expand Down
18 changes: 18 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ func TestLoadConfigFromEnv_ApprovalMode_False(t *testing.T) {
assert.False(t, cfg.ApprovalMode)
}

func TestLoadConfigFromEnv_BooleanOverridesCanDisableFileValues(t *testing.T) {
tmpDir := t.TempDir()
cfgPath := filepath.Join(tmpDir, "config.json")
require.NoError(t, os.WriteFile(cfgPath, []byte(`{
"dry_run": true,
"approval_mode": true
}`), 0644))

t.Setenv("MCP_CONFIG_FILE", cfgPath)
t.Setenv("DRY_RUN", "false")
t.Setenv("APPROVAL_MODE", "false")

cfg, err := LoadConfigFromEnv()
require.NoError(t, err)
assert.False(t, cfg.DryRun)
assert.False(t, cfg.ApprovalMode)
}

func TestLoadConfigFromEnv_ApprovalTTL(t *testing.T) {
t.Setenv("APPROVAL_TTL", "10m")
cfg, err := LoadConfigFromEnv()
Expand Down