package cloudmap import "strings" type RegistryDocument struct { Namespace string `json:"namespace"` Service string `json:"service"` UpdatedAt string `json:"updated_at"` Instances []RegistryInstance `json:"instances"` } type RegistryInstance struct { AgentID string `json:"agent_id"` DNSName string `json:"dns_name"` IP string `json:"ip"` FetchURL string `json:"fetch_url"` Port int `json:"port"` Healthy bool `json:"healthy"` } func SeederDNSName(service, namespace string) string { if strings.TrimSpace(service) == "" { service = "seeder" } if strings.TrimSpace(namespace) == "" { namespace = "prod.local" } return strings.TrimSpace(service) + ".svc." + strings.TrimSpace(namespace) } func NormalizeRegistryDocument(doc RegistryDocument) (RegistryDocument, bool) { doc.Namespace = strings.TrimSpace(doc.Namespace) doc.Service = strings.TrimSpace(doc.Service) if doc.Namespace == "" { doc.Namespace = "prod.local" } if doc.Service == "" { doc.Service = "seeder" } return doc, doc.Namespace != "" && doc.Service != "" }