mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-05-13 12:46:59 +00:00
* Basenine MongoDB mess
* Fix more
* Fix the `mongodb` container arguments
* Add Basenine ARM64 binary
* Make the changes related to `leftOff` becoming a string value
* Make `leftOffTop` state string
* Handle `CloseConnection` in `Fetch`
* Upgrade Basenine to `0.7.0`
* Revert the changes in `package.json` and `package-lock.json`
* Fix the `Dockerfile`
* Remove the binaries
* Increase the Basenine up deadline to 20 seconds
* Revert the changes in `shared/kubernetes/provider.go`
* Fix the OAS generator tests
* Protect from race condition
* Fix mutexes
* Fix unlock
* Fix logging data types
* Try to stabilize the tests
* Remove the `replace` statement
* revert the change the done in 2899414f2b to not change the leftOff
* Change `leftOffBottom` empty string default value to `latest`
* Upgrade Basenine to `0.7.1`
* Handle the Basenine client library errors better
* Use `DEFAULT_QUERY` constant
* Remove `min=-1`
* Replace some `Errorf`s with `Panicf`s
* Remove the closure in `runGenerator` method
* Remove an unnecessary check
Co-authored-by: M. Mert Yildiran <mehmet@up9.com>
Co-authored-by: Andrey Pokhilko <apc4@ya.ru>
Co-authored-by: undera <undera@undera-old-desktop.home>
Co-authored-by: AmitUp9 <96980485+AmitUp9@users.noreply.github.com>
80 lines
2.1 KiB
Go
80 lines
2.1 KiB
Go
package controllers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/up9inc/mizu/agent/pkg/dependency"
|
|
"github.com/up9inc/mizu/agent/pkg/entries"
|
|
"github.com/up9inc/mizu/agent/pkg/models"
|
|
"github.com/up9inc/mizu/agent/pkg/validation"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/up9inc/mizu/shared/logger"
|
|
)
|
|
|
|
func HandleEntriesError(c *gin.Context, err error) bool {
|
|
if err != nil {
|
|
logger.Log.Errorf("Error getting entry: %v", err)
|
|
_ = c.Error(err)
|
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
|
|
"error": true,
|
|
"type": "error",
|
|
"autoClose": "5000",
|
|
"msg": err.Error(),
|
|
})
|
|
return true // signal that there was an error and the caller should return
|
|
}
|
|
return false // no error, can continue
|
|
}
|
|
|
|
func GetEntries(c *gin.Context) {
|
|
entriesRequest := &models.EntriesRequest{}
|
|
|
|
if err := c.BindQuery(entriesRequest); err != nil {
|
|
c.JSON(http.StatusBadRequest, err)
|
|
}
|
|
validationError := validation.Validate(entriesRequest)
|
|
if validationError != nil {
|
|
c.JSON(http.StatusBadRequest, validationError)
|
|
}
|
|
|
|
if entriesRequest.TimeoutMs == 0 {
|
|
entriesRequest.TimeoutMs = 3000
|
|
}
|
|
|
|
entriesProvider := dependency.GetInstance(dependency.EntriesProvider).(entries.EntriesProvider)
|
|
entries, metadata, err := entriesProvider.GetEntries(entriesRequest)
|
|
if !HandleEntriesError(c, err) {
|
|
baseEntries := make([]interface{}, 0)
|
|
for _, entry := range entries {
|
|
baseEntries = append(baseEntries, entry.Base)
|
|
}
|
|
c.JSON(http.StatusOK, models.EntriesResponse{
|
|
Data: baseEntries,
|
|
Meta: metadata,
|
|
})
|
|
}
|
|
}
|
|
|
|
func GetEntry(c *gin.Context) {
|
|
singleEntryRequest := &models.SingleEntryRequest{}
|
|
|
|
if err := c.BindQuery(singleEntryRequest); err != nil {
|
|
c.JSON(http.StatusBadRequest, err)
|
|
}
|
|
validationError := validation.Validate(singleEntryRequest)
|
|
if validationError != nil {
|
|
c.JSON(http.StatusBadRequest, validationError)
|
|
}
|
|
|
|
id := c.Param("id")
|
|
|
|
entriesProvider := dependency.GetInstance(dependency.EntriesProvider).(entries.EntriesProvider)
|
|
entry, err := entriesProvider.GetEntry(singleEntryRequest, id)
|
|
|
|
if !HandleEntriesError(c, err) {
|
|
c.JSON(http.StatusOK, entry)
|
|
}
|
|
}
|