feat(api/snapshot): extend docker container snapshot type (#8537)

pull/8137/head
LP B 2023-03-01 17:33:40 +01:00 committed by GitHub
parent 7dcd6f9b9e
commit bc6a667a6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 9 deletions

View File

@ -220,7 +220,9 @@ func snapshotContainers(snapshot *portainer.DockerSnapshot, cli *client.Client)
snapshot.HealthyContainerCount = healthyContainers
snapshot.UnhealthyContainerCount = unhealthyContainers
snapshot.StackCount += len(stacks)
snapshot.SnapshotRaw.Containers = containers
for _, container := range containers {
snapshot.SnapshotRaw.Containers = append(snapshot.SnapshotRaw.Containers, portainer.DockerContainerSnapshot{Container: container})
}
return nil
}

View File

@ -207,15 +207,21 @@ type (
GpuUseList []string `json:"GpuUseList"`
}
// DockerSnapshotRaw represents all the information related to a snapshot as returned by the Docker API
// DockerContainerSnapshot is an extent of Docker's Container struct
// It contains some information of Docker's ContainerJSON struct
DockerContainerSnapshot struct {
types.Container
Env []string `json:"Env"`
}
// DockerSnapshotRaw represents all the information related to a snapshot as returned by the Docker API
DockerSnapshotRaw struct {
Containers []types.Container `json:"Containers" swaggerignore:"true"`
Volumes volume.VolumeListOKBody `json:"Volumes" swaggerignore:"true"`
Networks []types.NetworkResource `json:"Networks" swaggerignore:"true"`
Images []types.ImageSummary `json:"Images" swaggerignore:"true"`
Info types.Info `json:"Info" swaggerignore:"true"`
Version types.Version `json:"Version" swaggerignore:"true"`
Containers []DockerContainerSnapshot `json:"Containers" swaggerignore:"true"`
Volumes volume.VolumeListOKBody `json:"Volumes" swaggerignore:"true"`
Networks []types.NetworkResource `json:"Networks" swaggerignore:"true"`
Images []types.ImageSummary `json:"Images" swaggerignore:"true"`
Info types.Info `json:"Info" swaggerignore:"true"`
Version types.Version `json:"Version" swaggerignore:"true"`
}
// EdgeGroup represents an Edge group

View File

@ -1,7 +1,11 @@
import { DockerContainer } from '@/react/docker/containers/types';
export type DockerContainerSnapshot = DockerContainer & {
Env?: string[];
};
export type DockerSnapshotRaw = {
Containers: DockerContainer[];
Containers: DockerContainerSnapshot[];
SnapshotTime: string;
};