Files
go-sip/internal/config/mock_agent_endpoint.go
T

26 lines
806 B
Go

package config
import (
"errors"
"strings"
)
// LoadMockAgentEndpoint accepts exactly the one deployment-owned local
// Agent assigned to the isolated Dispatcher. SaaS task data cannot override it.
func LoadMockAgentEndpoint(filename string) (AgentEndpoint, error) {
if strings.TrimSpace(filename) == "" {
return AgentEndpoint{}, errors.New("DISPATCHER_AGENT_ENDPOINTS_FILE is required")
}
endpoints, err := LoadAgentEndpoints(filename)
if err != nil {
return AgentEndpoint{}, err
}
if len(endpoints) != 1 {
return AgentEndpoint{}, errors.New("Mock Dispatcher requires exactly one assigned Agent endpoint")
}
if !localGRPCAddress(endpoints[0].Address, false) {
return AgentEndpoint{}, errors.New("Mock Agent endpoint must be local with an explicit port")
}
return endpoints[0], nil
}