Skip to content

Commit

Permalink
chore: Add blank lines between logical blocks
Browse files Browse the repository at this point in the history
Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici committed Dec 9, 2024
1 parent 8672438 commit ed5dee2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions producer/nf_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ func HandleUpdateNFInstanceRequest(request *httpwrapper.Request) *httpwrapper.Re
logger.ManagementLog.Errorln("nfInstanceID is missing")
return httpwrapper.NewResponse(http.StatusBadRequest, nil, map[string]string{"error": "Missing nfInstanceID"})
}

patchJSON, ok := request.Body.([]byte)
if !ok {
logger.ManagementLog.Errorln("invalid body format")
return httpwrapper.NewResponse(http.StatusBadRequest, nil, map[string]string{"error": "Invalid body format"})
}

response, err := UpdateNFInstanceProcedure(nfInstanceID, patchJSON)
if err != nil {
logger.ManagementLog.Errorln("UpdateNFInstanceProcedure failed:", err)
Expand All @@ -106,11 +108,13 @@ func HandleUpdateNFInstanceRequest(request *httpwrapper.Request) *httpwrapper.Re
logger.ManagementLog.Errorln("received nil response after update procedure")
return httpwrapper.NewResponse(http.StatusInternalServerError, nil, map[string]string{"error": "Update procedure returned nil response"})
}

nfType, ok := response["nfType"].(string)
if !ok {
logger.ManagementLog.Warnln("response missing 'nfType' or wrong format")
nfType = "unknown"
}

stats.IncrementNrfRegistrationsStats("update", nfType, "SUCCESS")
return httpwrapper.NewResponse(http.StatusOK, nil, response)

Expand Down Expand Up @@ -361,6 +365,7 @@ func UpdateNFInstanceProcedure(nfInstanceID string, patchJSON []byte) (response
logger.ManagementLog.Errorln("patch error in UpdateNFInstanceProcedure:", patchError)
return nil, fmt.Errorf("patch error: %v", patchError)
}

// Get the updated NF Instance
nf, getErr := dbadapter.DBClient.RestfulAPIGetOne(collName, filter)
if getErr != nil || nf == nil {
Expand Down Expand Up @@ -390,6 +395,7 @@ func UpdateNFInstanceProcedure(nfInstanceID string, patchJSON []byte) (response
timein := time.Now().Local().Add(time.Second * time.Duration(factory.NrfConfig.Configuration.NfKeepAliveTime*3))
nf["expireAt"] = timein
}

// Put the updated NF instance
_, putErr := dbadapter.DBClient.RestfulAPIPutOne(collName, filter, nf)
if putErr != nil {
Expand Down

0 comments on commit ed5dee2

Please sign in to comment.