Commit 7e895d8b authored by Mudassar Khan's avatar Mudassar Khan
Browse files

bug: fix uris published on OCF platform

parent fff61d99
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -383,14 +383,33 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) {
				}
				deleteCapifMapping(sInfo.SerInstanceId)
			}
			// Use transportInfo.endpoint.uris[0] as the service endpoint for CAPIF.
			// Fall back to the hostUrl-based URI if no transport URI is available.
			host := hostUrl.Hostname()
			port := 443
			if hostUrl.Port() != "" {
			uri := basePath + "applications/" + appId + "/services/" + sInfo.SerInstanceId
			if sInfo.TransportInfo != nil &&
				sInfo.TransportInfo.Endpoint != nil &&
				len(sInfo.TransportInfo.Endpoint.EndPointInfoUris.Uris) > 0 {
				transportURI := sInfo.TransportInfo.Endpoint.EndPointInfoUris.Uris[0]
				if parsed, err := url.Parse(transportURI); err == nil {
					host = parsed.Hostname()
					uri = parsed.Path
					if parsed.Port() != "" {
						if p, err := strconv.Atoi(parsed.Port()); err == nil {
							port = p
						}
					} else if parsed.Scheme == "https" {
						port = 443
					} else {
						port = 80
					}
				}
			} else if hostUrl.Port() != "" {
				if p, err := strconv.Atoi(hostUrl.Port()); err == nil {
					port = p
				}
			}
			uri := basePath + "applications/" + appId + "/services/" + sInfo.SerInstanceId
			apiId, err := capifClient.PublishServiceAPI(
				sInfo.SerName+"-"+sandboxName,
				sInfo.Version,