mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 00:09:40 +02:00
feat(docker/volumes): change how volume resource id is calculated (#5067)
[EE-494]
This commit is contained in:
parent
72117693fb
commit
db16299aab
9 changed files with 187 additions and 31 deletions
|
@ -2,6 +2,7 @@ package snapshot
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
|
@ -187,3 +188,27 @@ func (service *Service) snapshotEndpoints() error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// FetchDockerID fetches info.Swarm.Cluster.ID if endpoint is swarm and info.ID otherwise
|
||||
func FetchDockerID(snapshot portainer.DockerSnapshot) (string, error) {
|
||||
info, done := snapshot.SnapshotRaw.Info.(map[string]interface{})
|
||||
if !done {
|
||||
return "", errors.New("failed getting snapshot info")
|
||||
}
|
||||
|
||||
if !snapshot.Swarm {
|
||||
return info["ID"].(string), nil
|
||||
}
|
||||
|
||||
if info["Swarm"] == nil {
|
||||
return "", errors.New("swarm endpoint is missing swarm info snapshot")
|
||||
}
|
||||
|
||||
swarmInfo := info["Swarm"].(map[string]interface{})
|
||||
if swarmInfo["Cluster"] == nil {
|
||||
return "", errors.New("swarm endpoint is missing cluster info snapshot")
|
||||
}
|
||||
|
||||
clusterInfo := swarmInfo["Cluster"].(map[string]interface{})
|
||||
return clusterInfo["ID"].(string), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue