1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 04:15:28 +02:00

feat(system/upgrade): add upgrade banner [EE-4564] (#8046)

This commit is contained in:
Chaim Lev-Ari 2022-11-16 18:38:39 +02:00 committed by GitHub
parent c21921a08d
commit eccc8131dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 366 additions and 33 deletions

View file

@ -0,0 +1,60 @@
package status
import (
"net/http"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/response"
"github.com/portainer/portainer/api/internal/endpointutils"
"github.com/portainer/portainer/api/platform"
)
type systemInfoResponse struct {
Platform platform.ContainerPlatform `json:"platform"`
EdgeAgents int `json:"edgeAgents"`
EdgeDevices int `json:"edgeDevices"`
Agents int `json:"agents"`
}
// @id statusSystem
// @summary Retrieve system info
// @description **Access policy**: authenticated
// @security ApiKeyAuth
// @security jwt
// @tags status
// @produce json
// @success 200 {object} systemInfoResponse "Success"
// @failure 500 "Server error"
// @router /status/system [get]
func (handler *Handler) statusSystem(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
environments, err := handler.dataStore.Endpoint().Endpoints()
if err != nil {
return httperror.InternalServerError("Failed to get environment list", err)
}
agents := 0
edgeAgents := 0
edgeDevices := 0
for _, environment := range environments {
if endpointutils.IsAgentEndpoint(&environment) {
agents++
}
if endpointutils.IsEdgeEndpoint(&environment) {
edgeAgents++
}
if environment.IsEdgeDevice {
edgeDevices++
}
}
return response.JSON(w, &systemInfoResponse{
EdgeAgents: edgeAgents,
EdgeDevices: edgeDevices,
Agents: agents,
Platform: platform.DetermineContainerPlatform(),
})
}