mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
feat(system/upgrade): add upgrade banner [EE-4564] (#8046)
This commit is contained in:
parent
c21921a08d
commit
eccc8131dd
16 changed files with 366 additions and 33 deletions
35
api/internal/nodes/nodes.go
Normal file
35
api/internal/nodes/nodes.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package status
|
||||
|
||||
import (
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
)
|
||||
|
||||
// NodesCount returns the total node number of all environments
|
||||
func NodesCount(endpoints []portainer.Endpoint) int {
|
||||
nodes := 0
|
||||
for _, env := range endpoints {
|
||||
nodes += countNodes(&env)
|
||||
}
|
||||
|
||||
return nodes
|
||||
}
|
||||
|
||||
func countNodes(endpoint *portainer.Endpoint) int {
|
||||
if len(endpoint.Snapshots) == 1 {
|
||||
return max(endpoint.Snapshots[0].NodeCount, 1)
|
||||
}
|
||||
|
||||
if len(endpoint.Kubernetes.Snapshots) == 1 {
|
||||
return max(endpoint.Kubernetes.Snapshots[0].NodeCount, 1)
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
|
@ -124,8 +124,12 @@ func (service *Service) Create(snapshot portainer.Snapshot) error {
|
|||
}
|
||||
|
||||
func (service *Service) FillSnapshotData(endpoint *portainer.Endpoint) error {
|
||||
snapshot, err := service.dataStore.Snapshot().Snapshot(endpoint.ID)
|
||||
if service.dataStore.IsErrObjectNotFound(err) {
|
||||
return FillSnapshotData(service.dataStore, endpoint)
|
||||
}
|
||||
|
||||
func FillSnapshotData(dataStore dataservices.DataStore, endpoint *portainer.Endpoint) error {
|
||||
snapshot, err := dataStore.Snapshot().Snapshot(endpoint.ID)
|
||||
if dataStore.IsErrObjectNotFound(err) {
|
||||
endpoint.Snapshots = []portainer.DockerSnapshot{}
|
||||
endpoint.Kubernetes.Snapshots = []portainer.KubernetesSnapshot{}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue