mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-07-05 14:41:03 +00:00
* Rename `mizu` to `kubeshark` * Rename `up9inc` to `kubeshark` * Change the logo, title, motto and the main color * Replace the favicon * Update the docs link * Change the copyright text in C files * Remove a comment * Rewrite the `README.md` and update the logo and screenshots used in it * Add a `TODO` * Fix the grammar * Fix the bottom text in the filtering guide * Change the Docker Hub username of cross-compilation intermediate images * Add an install script * Fix `docker/login-action` in the CI * Delete `build-custom-branch.yml` GitHub workflow * Update `README.md` * Remove `install.sh` * Change the motto back to "Traffic viewer for Kubernetes"
40 lines
919 B
Go
40 lines
919 B
Go
package controllers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/kubeshark/kubeshark/agent/pkg/dependency"
|
|
"github.com/kubeshark/kubeshark/agent/pkg/servicemap"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type ServiceMapController struct {
|
|
service servicemap.ServiceMap
|
|
}
|
|
|
|
func NewServiceMapController() *ServiceMapController {
|
|
serviceMapGenerator := dependency.GetInstance(dependency.ServiceMapGeneratorDependency).(servicemap.ServiceMap)
|
|
return &ServiceMapController{
|
|
service: serviceMapGenerator,
|
|
}
|
|
}
|
|
|
|
func (s *ServiceMapController) Status(c *gin.Context) {
|
|
c.JSON(http.StatusOK, s.service.GetStatus())
|
|
}
|
|
|
|
func (s *ServiceMapController) Get(c *gin.Context) {
|
|
response := &servicemap.ServiceMapResponse{
|
|
Status: s.service.GetStatus(),
|
|
Nodes: s.service.GetNodes(),
|
|
Edges: s.service.GetEdges(),
|
|
}
|
|
c.JSON(http.StatusOK, response)
|
|
}
|
|
|
|
func (s *ServiceMapController) Reset(c *gin.Context) {
|
|
s.service.Reset()
|
|
s.Status(c)
|
|
}
|