Roll versions after J-Relase (master branch)
[nonrtric/plt/sme.git] / servicemanager / internal / publishserviceapi / typeupdate.go
index 451f54b..d7246bd 100644 (file)
@@ -38,26 +38,30 @@ func (sd *ServiceAPIDescription) PrepareNewService() {
        sd.ApiId = &apiName
 }
 
-func (sd *ServiceAPIDescription) RegisterKong(kongDomain string,
-               kongProtocol string,
-               kongIPv4 common29122.Ipv4Addr,
-               kongDataPlanePort common29122.Port,
+func (sd *ServiceAPIDescription) RegisterKong(
+               kongDomain                       string,
+               kongProtocol             string,
+               kongControlPlaneIPv4 common29122.Ipv4Addr,
                kongControlPlanePort common29122.Port,
-               apfId string) (int, error) {
+               kongDataPlaneIPv4        common29122.Ipv4Addr,
+               kongDataPlanePort        common29122.Port,
+               apfId                            string) (int, error) {
 
        log.Trace("entering RegisterKong")
+       log.Debugf("RegisterKong kongDataPlaneIPv4 %s", kongDataPlaneIPv4)
+
        var (
                statusCode int
                err        error
        )
-       kongControlPlaneURL := fmt.Sprintf("%s://%s:%d", kongProtocol, kongIPv4, kongControlPlanePort)
+       kongControlPlaneURL := fmt.Sprintf("%s://%s:%d", kongProtocol, kongControlPlaneIPv4, kongControlPlanePort)
 
        statusCode, err = sd.createKongRoutes(kongControlPlaneURL, apfId)
        if (err != nil) || (statusCode != http.StatusCreated) {
                return statusCode, err
        }
 
-       sd.updateInterfaceDescription(kongIPv4, kongDataPlanePort, kongDomain)
+       sd.updateInterfaceDescription(kongDataPlaneIPv4, kongDataPlanePort, kongDomain)
 
        log.Trace("exiting from RegisterKong")
        return statusCode, nil
@@ -145,7 +149,8 @@ func (sd *ServiceAPIDescription) createKongRoute(
        if resp.StatusCode() == http.StatusCreated {
                log.Infof("kong route %s created successfully", routeName)
        } else {
-               err = fmt.Errorf("the Kong service already exists. Status code: %d", resp.StatusCode())
+               log.Debugf("kongRoutesURL %s", kongRoutesURL)
+               err = fmt.Errorf("error creating Kong route. Status code: %d", resp.StatusCode())
                log.Error(err.Error())
                log.Errorf("response body: %s", resp.Body())
                return resp.StatusCode(), err
@@ -237,7 +242,7 @@ func (sd *ServiceAPIDescription) createKongService(kongControlPlaneURL string, k
        } else if resp.StatusCode() == http.StatusConflict {
                log.Errorf("kong service already exists. Status code: %d", resp.StatusCode())
                err = fmt.Errorf("service with identical apiName is already published") // for compatibilty with Capif error message on a duplicate service
-               statusCode = http.StatusForbidden // for compatibilty with the spec, TS29222_CAPIF_Publish_Service_API
+               statusCode = http.StatusForbidden                                       // for compatibilty with the spec, TS29222_CAPIF_Publish_Service_API
        } else {
                err = fmt.Errorf("error creating Kong service. Status code: %d", resp.StatusCode())
        }
@@ -271,10 +276,12 @@ func (sd *ServiceAPIDescription) findFirstAEFProfile() (common29122.Ipv4Addr, co
 }
 
 // Update our exposures to point to Kong by replacing in incoming interface description with Kong interface descriptions.
-func (sd *ServiceAPIDescription) updateInterfaceDescription(kongIPv4 common29122.Ipv4Addr, kongDataPlanePort common29122.Port, kongDomain string) {
+func (sd *ServiceAPIDescription) updateInterfaceDescription(kongDataPlaneIPv4 common29122.Ipv4Addr, kongDataPlanePort common29122.Port, kongDomain string) {
        log.Trace("updating InterfaceDescriptions")
+       log.Debugf("InterfaceDescriptions kongDataPlaneIPv4 %s", kongDataPlaneIPv4)
+
        interfaceDesc := InterfaceDescription{
-               Ipv4Addr: &kongIPv4,
+               Ipv4Addr: &kongDataPlaneIPv4,
                Port:     &kongDataPlanePort,
        }
        interfaceDescs := []InterfaceDescription{interfaceDesc}
@@ -287,14 +294,14 @@ func (sd *ServiceAPIDescription) updateInterfaceDescription(kongIPv4 common29122
        }
 }
 
-func (sd *ServiceAPIDescription) UnregisterKong(kongDomain string, kongProtocol string, kongIPv4 common29122.Ipv4Addr, kongDataPlanePort common29122.Port, kongControlPlanePort common29122.Port) (int, error) {
+func (sd *ServiceAPIDescription) UnregisterKong(kongDomain string, kongProtocol string, kongControlPlaneIPv4 common29122.Ipv4Addr, kongControlPlanePort common29122.Port) (int, error) {
        log.Trace("entering UnregisterKong")
 
        var (
                statusCode int
                err        error
        )
-       kongControlPlaneURL := fmt.Sprintf("%s://%s:%d", kongProtocol, kongIPv4, kongControlPlanePort)
+       kongControlPlaneURL := fmt.Sprintf("%s://%s:%d", kongProtocol, kongControlPlaneIPv4, kongControlPlanePort)
 
        statusCode, err = sd.deleteKongRoutes(kongControlPlaneURL)
        if (err != nil) || (statusCode != http.StatusNoContent) {
@@ -350,6 +357,7 @@ func (sd *ServiceAPIDescription) deleteKongRoute(kongControlPlaneURL string, cli
        if resp.StatusCode() == http.StatusNoContent {
                log.Infof("kong route %s deleted successfully", routeName)
        } else {
+               log.Debugf("kongRoutesURL: %s", kongRoutesURL)
                log.Errorf("error deleting Kong route. Status code: %d", resp.StatusCode())
                log.Errorf("response body: %s", resp.Body())
                return resp.StatusCode(), err
@@ -386,6 +394,7 @@ func (sd *ServiceAPIDescription) deleteKongService(kongControlPlaneURL string, s
        if resp.StatusCode() == http.StatusNoContent {
                log.Infof("kong service %s deleted successfully", serviceName)
        } else {
+               log.Debugf("kongServicesURL: %s", kongServicesURL)
                log.Errorf("deleting Kong service, status code: %d", resp.StatusCode())
                log.Errorf("response body: %s", resp.Body())
        }