X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Fsubscription.go;h=4ecc2624aec601eebd23c2d587a76c26be728c82;hb=b8b191fe31602c53414f8086381aef1a48e8be09;hp=cf8dc04a57c723c47d0e21a600617f62b4d3aaca;hpb=5953f7e372df54c71f526e9519e8eb0ee7ee6f72;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/subscription.go b/pkg/xapp/subscription.go index cf8dc04..4ecc262 100755 --- a/pkg/xapp/subscription.go +++ b/pkg/xapp/subscription.go @@ -29,8 +29,9 @@ import ( "github.com/go-openapi/strfmt" "github.com/spf13/viper" "io/ioutil" + "net" "net/http" - "strings" + "os" "time" apiclient "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi" @@ -66,7 +67,11 @@ type Subscriber struct { func NewSubscriber(host string, timo int) *Subscriber { if host == "" { - host = "service-ricplt-submgr-http:8088" + pltnamespace := os.Getenv("PLT_NAMESPACE") + if pltnamespace == "" { + pltnamespace = "ricplt" + } + host = fmt.Sprintf("service-%s-submgr-http.%s:8088", pltnamespace, pltnamespace) } if timo == 0 { @@ -164,8 +169,9 @@ func (r *Subscriber) Notify(resp *models.SubscriptionResponse, clientEndpoint st return err } - port := strings.Split(viper.GetString("local.host"), ":")[1] - clientUrl := fmt.Sprintf("http://%s:%s%s", clientEndpoint, port, r.clientUrl) + ep, _, _ := net.SplitHostPort(clientEndpoint) + _, port, _ := net.SplitHostPort(fmt.Sprintf(":%d", GetPortData("http").Port)) + clientUrl := fmt.Sprintf("http://%s:%s%s", ep, port, r.clientUrl) retries := viper.GetInt("subscription.retryCount") if retries == 0 {