Skip to content

[MEDIUM] Hardcoded Configuration Values Should Be Configurable #7

@MacJediWizard

Description

@MacJediWizard

Description

Several configuration values are hardcoded throughout the codebase instead of being configurable via config file or environment variables.

Locations

HTTP Client settings

`internal/client/client.go` lines 27-29

client.SetTimeout(30 * time.Second)  // Hardcoded timeout
client.SetRetryCount(3)              // Hardcoded retry count
client.SetRetryWaitTime(2 * time.Second)  // Hardcoded retry wait

Docker socket path

`internal/integrations/docker/docker.go` line 20

dockerSocketPath = "/var/run/docker.sock"  // Should support custom paths

WebSocket settings

`cmd/patchmon-agent/commands/serve.go` lines 310-318, 374, 382-384

// Hardcoded backoff values
time.Sleep(1 * time.Second)  // Initial backoff
// Max backoff 30 seconds
// Ping interval 30 seconds
// Read deadline 90 seconds

Recommended Fix

  1. Add configuration options to `config.yml`:
http:
  timeout: 30s
  retry_count: 3
  retry_wait: 2s

docker:
  socket_path: /var/run/docker.sock

websocket:
  initial_backoff: 1s
  max_backoff: 30s
  ping_interval: 30s
  read_deadline: 90s
  1. Load values from config with sensible defaults:
timeout := cfg.HTTP.Timeout
if timeout == 0 {
    timeout = 30 * time.Second  // Default
}
client.SetTimeout(timeout)

Severity

🟡 MEDIUM - Operational flexibility

Labels

enhancement, medium, code-quality

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions