fix(gateway): drop services.gateway.mode, remote is the only transport
Mode had exactly one legal value after the previous commit deleted the in-process path, which made it dead config surface that could only confuse an operator into thinking there was still a real choice. ServiceConnection is now just a target address; composeChatContract only checks it's non-blank, defaulting to 127.0.0.1:8585.
This commit is contained in:
1 parent
bec9caa24e
commit
bf482f9d56
11 files changed
+14
-51
No files matched your search
@@ -59,8 +59,7 @@ const (
|
||||
// input was to not call them. Splitting them means defaults can be applied,
|
||||
// inspected, and reasoned about independently of whether the result is valid.
|
||||
func (l *Loader) applyDefaults(cfg *config.Config) {
|
||||
if cfg.Services.Gateway.Mode == "" {
|
||||
cfg.Services.Gateway.Mode = "remote"
|
||||
if cfg.Services.Gateway.Target == "" {
|
||||
cfg.Services.Gateway.Target = "127.0.0.1:8585"
|
||||
}
|
||||
l.applyGeneralDefaults(cfg)
|
||||
|
||||
@@ -6,17 +6,12 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadGatewayServiceMode(t *testing.T) {
|
||||
func TestLoadGatewayServiceTarget(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
name, section string
|
||||
wantError bool
|
||||
wantTarget string
|
||||
name, section, wantTarget string
|
||||
}{
|
||||
{name: "default", wantTarget: "127.0.0.1:8585"},
|
||||
{name: "remote", section: "[services.gateway]\nmode = 'remote'\ntarget = 'dns:///gateway:8443'", wantTarget: "dns:///gateway:8443"},
|
||||
{name: "invalid mode", section: "[services.gateway]\nmode = 'typo'", wantError: true},
|
||||
{name: "inproc removed", section: "[services.gateway]\nmode = 'inproc'", wantError: true},
|
||||
{name: "remote without target", section: "[services.gateway]\nmode = 'remote'", wantError: true},
|
||||
{name: "explicit target", section: "[services.gateway]\ntarget = 'dns:///gateway:8443'", wantTarget: "dns:///gateway:8443"},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.toml")
|
||||
@@ -24,16 +19,11 @@ func TestLoadGatewayServiceMode(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg, err := loadFile(path)
|
||||
if (err != nil) != tt.wantError {
|
||||
t.Fatalf("load error = %v, want error %v", err, tt.wantError)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err == nil {
|
||||
if cfg.Services.Gateway.Mode != "remote" {
|
||||
t.Fatalf("mode = %q, want %q", cfg.Services.Gateway.Mode, "remote")
|
||||
}
|
||||
if cfg.Services.Gateway.Target != tt.wantTarget {
|
||||
t.Fatalf("target = %q, want %q", cfg.Services.Gateway.Target, tt.wantTarget)
|
||||
}
|
||||
if cfg.Services.Gateway.Target != tt.wantTarget {
|
||||
t.Fatalf("target = %q, want %q", cfg.Services.Gateway.Target, tt.wantTarget)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -59,9 +59,6 @@ func Validate(cfg *config.Config) error {
|
||||
// validate reports the first problem that would stop the daemon running.
|
||||
// It does not modify cfg -- run applyDefaults first.
|
||||
func validate(cfg *config.Config) error {
|
||||
if err := validateGatewayService(cfg.Services.Gateway); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateDispatch(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -96,18 +93,6 @@ func validate(cfg *config.Config) error {
|
||||
return validateCapture(cfg)
|
||||
}
|
||||
|
||||
func validateGatewayService(service config.ServiceConnection) error {
|
||||
switch service.Mode {
|
||||
case "remote":
|
||||
if strings.TrimSpace(service.Target) == "" {
|
||||
return fmt.Errorf("%w: services.gateway.target is required in remote mode", ErrInvalidInput)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("%w: services.gateway.mode must be remote", ErrInvalidInput)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateImage rejects an enabled hosted provider with no class or no
|
||||
// resolvable credential, and a Default naming a provider that is not both
|
||||
// present and enabled -- either would let /image silently fall back to
|
||||
|
||||
@@ -27,7 +27,7 @@ func minimalValidConfig() config.Config {
|
||||
Image: "ghcr.io/samcharles93/archie-agent:latest",
|
||||
},
|
||||
Services: config.Services{
|
||||
Gateway: config.ServiceConnection{Mode: "remote", Target: "127.0.0.1:8585"},
|
||||
Gateway: config.ServiceConnection{Target: "127.0.0.1:8585"},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user