Skip to content

Commit 9aaffd5

Browse files
committed
config/config.go: Re-enable individual variables but prefer CLUSTERS if set.
I had, at some point, deprecated the code but I never updated the instructions. For the sake of being compatible with DXClusterAPI re-enabled these variables. This fixes #34
1 parent d5441fd commit 9aaffd5

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

config/config.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ type Config struct {
102102
RawClustersJSON string `env:"CLUSTERS"`
103103
Clusters []ClusterConfig `env:"-"` // Will be populated from RawClustersJSON
104104

105+
// Single-cluster shorthand — used when CLUSTERS JSON is not set
106+
DXHost string `env:"DXHOST"`
107+
DXPort string `env:"DXPORT" envDefault:"7300"`
108+
105109
// Global CALLSIGN - used for all clusters that don't specify their own
106110
Callsign string `env:"CALLSIGN"`
107111

@@ -158,12 +162,24 @@ func LoadConfig() (*Config, error) {
158162
}
159163

160164
// --- DX Cluster Configuration Logic ---
161-
// Only use CLUSTERS JSON - no more legacy support
165+
// If CLUSTERS JSON is provided it takes full precedence.
166+
// Otherwise fall back to the single-cluster DXHOST/DXPORT/CALLSIGN shorthand.
162167
if cfg.RawClustersJSON != "" {
163-
// Use CLUSTERS JSON if provided
164168
if err := json.Unmarshal([]byte(cfg.RawClustersJSON), &cfg.Clusters); err != nil {
165169
return nil, fmt.Errorf("failed to parse CLUSTERS JSON: %w", err)
166170
}
171+
} else if cfg.DXHost != "" {
172+
port := cfg.DXPort
173+
if port == "" {
174+
port = DefaultDXCPort
175+
}
176+
cfg.Clusters = []ClusterConfig{
177+
{
178+
Host: cfg.DXHost,
179+
Port: FlexiblePort(port),
180+
Callsign: cfg.Callsign,
181+
},
182+
}
167183
}
168184

169185
// Apply global callsign to clusters that don't have one

0 commit comments

Comments
 (0)