register fix

This commit is contained in:
Piotr Biernat 2022-12-01 19:43:35 +01:00
parent 0b035dfcc9
commit ceaeecf1b4

View File

@ -5,6 +5,7 @@ import (
"log" "log"
"net/http" "net/http"
"strconv" "strconv"
"strings"
"time" "time"
consul "github.com/hashicorp/consul/api" consul "github.com/hashicorp/consul/api"
@ -58,7 +59,7 @@ func (s *Service) GetFullAddr() string {
func (s *Service) Register() error { func (s *Service) Register() error {
def := &consul.AgentServiceRegistration{ def := &consul.AgentServiceRegistration{
ID: s.GetID(), ID: s.GetID(),
Name: s.Name, Name: strings.Replace(s.Name, "-", "_", -1),
Address: s.IP, Address: s.IP,
Port: s.Port, Port: s.Port,
Tags: s.getTags(), Tags: s.getTags(),