force-update does not require consumer URLs (ErrNoConsumer sentinel)

This commit is contained in:
mram
2026-09-21 09:05:46 +02:00
parent e46e92bee8
commit cedf28a809
3 changed files with 14 additions and 1 deletions
+3
View File
@@ -299,6 +299,9 @@ func forceUpdateCommand(configPath string, elevatedChild bool) int {
defer waitForEnter()
}
cfg, err := loadMergedConfig(configPath)
if errors.Is(err, config.ErrNoConsumer) {
err = nil // update settings do not depend on a consumer URL
}
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n\ngpu-turnstile: %v\n", versionLine(), err)
return 1
+7 -1
View File
@@ -4,6 +4,7 @@ package config
import (
"bufio"
"errors"
"fmt"
"io"
"log/slog"
@@ -84,6 +85,11 @@ func Defaults() Config {
}
}
// ErrNoConsumer is returned by Load when neither OLLAMA_URL nor COMFY_URL
// is set. Commands that never talk to an upstream (--force-update) may
// ignore it and proceed with the rest of the configuration.
var ErrNoConsumer = errors.New("at least one of OLLAMA_URL or COMFY_URL must be set (each URL enables its consumer)")
// ParseEnvFile parses a .env-style file: KEY=VALUE lines, blank lines and
// #-comments are ignored, no quoting. A line without '=' is an error.
func ParseEnvFile(r io.Reader) (map[string]string, error) {
@@ -219,7 +225,7 @@ func Load(getenv func(string) string) (Config, error) {
return cfg, fmt.Errorf("LOG_FORMAT: must be \"text\" or \"json\"")
}
if cfg.OllamaURL == "" && cfg.ComfyURL == "" {
return cfg, fmt.Errorf("at least one of OLLAMA_URL or COMFY_URL must be set (each URL enables its consumer)")
return cfg, ErrNoConsumer
}
return cfg, nil
}
+4
View File
@@ -1,6 +1,7 @@
package config
import (
"errors"
"log/slog"
"strings"
"testing"
@@ -39,6 +40,9 @@ func TestLoadRequiresConsumer(t *testing.T) {
if err == nil || !strings.Contains(err.Error(), "OLLAMA_URL") {
t.Fatalf("err = %v, want missing-consumer error", err)
}
if !errors.Is(err, ErrNoConsumer) {
t.Fatalf("err = %v, want errors.Is(err, ErrNoConsumer)", err)
}
}
func TestParseEnvFile(t *testing.T) {