[ci skip] more suggested improvements
This commit is contained in:
@@ -3,7 +3,6 @@ package handler
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"vctp/db/queries"
|
||||
"vctp/internal/vcenter"
|
||||
@@ -13,9 +12,9 @@ import (
|
||||
// @Summary Refresh VM details
|
||||
// @Description Queries vCenter and updates inventory records with missing details.
|
||||
// @Tags inventory
|
||||
// @Produce text/plain
|
||||
// @Success 200 {string} string "Update completed"
|
||||
// @Failure 500 {string} string "Server error"
|
||||
// @Produce json
|
||||
// @Success 200 {object} models.StatusMessageResponse "Update completed"
|
||||
// @Failure 500 {object} models.ErrorResponse "Server error"
|
||||
// @Router /api/inventory/vm/update [post]
|
||||
func (h *Handler) VmUpdateDetails(w http.ResponseWriter, r *http.Request) {
|
||||
var matchFound bool
|
||||
@@ -42,8 +41,8 @@ func (h *Handler) VmUpdateDetails(w http.ResponseWriter, r *http.Request) {
|
||||
results, err := h.Database.Queries().GetInventoryByVcenter(ctx, url)
|
||||
if err != nil {
|
||||
h.Logger.Error("Unable to query inventory table", "error", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
fmt.Fprintf(w, "Unable to query inventory table %s\n", err)
|
||||
writeJSONError(w, http.StatusInternalServerError, "Unable to query inventory table")
|
||||
return
|
||||
}
|
||||
|
||||
if len(results) == 0 {
|
||||
@@ -115,7 +114,5 @@ func (h *Handler) VmUpdateDetails(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
h.Logger.Debug("Processed vm update successfully")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
// TODO - return some JSON
|
||||
fmt.Fprintf(w, "Processed vm update successfully")
|
||||
writeJSONOKMessage(w, "Processed vm update successfully")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user