refactor(config): prioritize ENV variable for branch detection and update firewall script
- Update PostBootScripts to use firewalld.sh instead of ufw.sh - Refactor NewConfig to prioritize ENV=dev environment variable over version-based detection - Improve code clarity with explicit if/else structure for branch selection - Add comments explaining precedence rules for environment-based configuration
- commit
- c1bd4927cb80bc79361e46d9cd592ba970d1d7e2
- author
- brice · · 2026-01-25 18:00 UTC
- parent
- d57f4db
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +16 -10
M internal/config/config.go +16 -10
| @@ -188,7 +188,7 @@ const ( | |||
| 188 | 188 | var PostBootScripts = []string{ | |
| 189 | 189 | "all.sh", | |
| 190 | 190 | "snapper.sh", | |
| 191 | - | "ufw.sh", | |
| 191 | + | "firewalld.sh", | |
| 192 | 192 | "ssh-keygen.sh", | |
| 193 | 193 | "archup-cli.sh", | |
| 194 | 194 | "blesh.sh", | |
| @@ -249,18 +249,24 @@ type Config struct { | |||
| 249 | 249 | ||
| 250 | 250 | // NewConfig creates a new Config with sensible defaults | |
| 251 | 251 | // version parameter determines which branch to use for downloads (dev builds use dev branch) | |
| 252 | + | // ENV=dev environment variable takes precedence over version-based detection | |
| 252 | 253 | func NewConfig(version string) *Config { | |
| 253 | - | // Determine which branch to use based on version | |
| 254 | + | // Determine which branch to use | |
| 255 | + | // ENV=dev takes precedence, then fall back to version-based detection | |
| 254 | 256 | var branch string | |
| 255 | - | switch { | |
| 256 | - | case version == "dev" || version == "": | |
| 257 | + | if os.Getenv("ENV") == "dev" { | |
| 257 | 258 | branch = "dev" | |
| 258 | - | case strings.Contains(version, "-dev"): | |
| 259 | - | branch = "dev" | |
| 260 | - | case strings.Contains(version, "-next"): | |
| 261 | - | branch = "dev" | |
| 262 | - | default: | |
| 263 | - | branch = "main" | |
| 259 | + | } else { | |
| 260 | + | switch { | |
| 261 | + | case version == "dev" || version == "": | |
| 262 | + | branch = "dev" | |
| 263 | + | case strings.Contains(version, "-dev"): | |
| 264 | + | branch = "dev" | |
| 265 | + | case strings.Contains(version, "-next"): | |
| 266 | + | branch = "dev" | |
| 267 | + | default: | |
| 268 | + | branch = "main" | |
| 269 | + | } | |
| 264 | 270 | } | |
| 265 | 271 | ||
| 266 | 272 | return &Config{ | |
| @@ -188,7 +188,7 @@ const ( | |||||
| 188 | var PostBootScripts = []string{ | 188 | var PostBootScripts = []string{ | ||
| 189 | "all.sh", | 189 | "all.sh", | ||
| 190 | "snapper.sh", | 190 | "snapper.sh", | ||
| 191 | - | "ufw.sh", | 191 | + | "firewalld.sh", |
| 192 | "ssh-keygen.sh", | 192 | "ssh-keygen.sh", | ||
| 193 | "archup-cli.sh", | 193 | "archup-cli.sh", | ||
| 194 | "blesh.sh", | 194 | "blesh.sh", | ||
| @@ -249,18 +249,24 @@ type Config struct { | |||||
| 249 | 249 | ||||
| 250 | // NewConfig creates a new Config with sensible defaults | 250 | // NewConfig creates a new Config with sensible defaults | ||
| 251 | // version parameter determines which branch to use for downloads (dev builds use dev branch) | 251 | // version parameter determines which branch to use for downloads (dev builds use dev branch) | ||
| 252 | + | // ENV=dev environment variable takes precedence over version-based detection | |||
| 252 | func NewConfig(version string) *Config { | 253 | func NewConfig(version string) *Config { | ||
| 253 | - | // Determine which branch to use based on version | 254 | + | // Determine which branch to use |
| 255 | + | // ENV=dev takes precedence, then fall back to version-based detection | |||
| 254 | var branch string | 256 | var branch string | ||
| 255 | - | switch { | 257 | + | if os.Getenv("ENV") == "dev" { |
| 256 | - | case version == "dev" || version == "": | |||
| 257 | branch = "dev" | 258 | branch = "dev" | ||
| 258 | - | case strings.Contains(version, "-dev"): | 259 | + | } else { |
| 259 | - | branch = "dev" | 260 | + | switch { |
| 260 | - | case strings.Contains(version, "-next"): | 261 | + | case version == "dev" || version == "": |
| 261 | - | branch = "dev" | 262 | + | branch = "dev" |
| 262 | - | default: | 263 | + | case strings.Contains(version, "-dev"): |
| 263 | - | branch = "main" | 264 | + | branch = "dev" |
| 265 | + | case strings.Contains(version, "-next"): | |||
| 266 | + | branch = "dev" | |||
| 267 | + | default: | |||
| 268 | + | branch = "main" | |||
| 269 | + | } | |||
| 264 | } | 270 | } | ||
| 265 | 271 | ||||
| 266 | return &Config{ | 272 | return &Config{ | ||