1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 15:29:42 +02:00

Revert "refactor(docker): strongly type snapshot [EE-3256]"

This reverts commit 0b2217a916.
This commit is contained in:
Chaim Lev-Ari 2022-05-26 15:39:55 +03:00
parent 0b2217a916
commit 75d854e6ad
4 changed files with 44 additions and 127 deletions

View file

@ -188,17 +188,24 @@ func (service *Service) snapshotEndpoints() error {
// FetchDockerID fetches info.Swarm.Cluster.ID if environment(endpoint) is swarm and info.ID otherwise
func FetchDockerID(snapshot portainer.DockerSnapshot) (string, error) {
info := snapshot.SnapshotRaw.Info
if !snapshot.Swarm {
return info.ID, nil
info, done := snapshot.SnapshotRaw.Info.(map[string]interface{})
if !done {
return "", errors.New("failed getting snapshot info")
}
swarmInfo := info.Swarm
if swarmInfo.Cluster == nil {
if !snapshot.Swarm {
return info["ID"].(string), nil
}
if info["Swarm"] == nil {
return "", errors.New("swarm environment is missing swarm info snapshot")
}
swarmInfo := info["Swarm"].(map[string]interface{})
if swarmInfo["Cluster"] == nil {
return "", errors.New("swarm environment is missing cluster info snapshot")
}
clusterInfo := swarmInfo.Cluster
return clusterInfo.ID, nil
clusterInfo := swarmInfo["Cluster"].(map[string]interface{})
return clusterInfo["ID"].(string), nil
}