mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Inspect: API v1.51 compatibility
For API < v1.52: - In container inspect: - Restore GraphDriver when a snapshotter is used. - Remove field Storage - Related to commitefa077848f- In image inspect: - Restore GraphDriver when a snapshotter is used. - Related to commitc441b2ef19Co-authored-by: Sebastiaan van Stijn <github@gone.nl> Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/moby/moby/api/types/container"
|
||||
imagetypes "github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/api/types/registry"
|
||||
"github.com/moby/moby/api/types/storage"
|
||||
"github.com/moby/moby/v2/daemon/internal/filters"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
@@ -92,4 +93,8 @@ type InspectData struct {
|
||||
//
|
||||
// This field is removed in API v1.45, but used for API <= v1.44 responses.
|
||||
ContainerConfig *container.Config
|
||||
|
||||
// GraphDriverLegacy is used for API versions < v1.52, which included the
|
||||
// name of the snapshotter the GraphDriver field.
|
||||
GraphDriverLegacy *storage.DriverData
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/storage"
|
||||
"github.com/moby/moby/api/types/versions"
|
||||
"github.com/moby/moby/v2/daemon/internal/compat"
|
||||
"github.com/moby/moby/v2/daemon/internal/stringid"
|
||||
@@ -69,6 +70,15 @@ func (c *containerRouter) getContainersByName(ctx context.Context, w http.Respon
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
// Restore the GraphDriver field, now omitted when a snapshotter is used.
|
||||
// Remove the Storage field that replaced it.
|
||||
if ctr.GraphDriver == nil && ctr.Storage != nil && ctr.Storage.RootFS != nil && ctr.Storage.RootFS.Snapshot != nil {
|
||||
ctr.GraphDriver = &storage.DriverData{
|
||||
Name: ctr.Storage.RootFS.Snapshot.Name,
|
||||
}
|
||||
ctr.Storage = nil
|
||||
}
|
||||
}
|
||||
|
||||
return httputils.WriteJSON(w, http.StatusOK, compat.Wrap(ctr, wrapOpts...))
|
||||
|
||||
@@ -440,6 +440,11 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
|
||||
"Config": legacyConfigFields["v1.50-v1.51"],
|
||||
}))
|
||||
}
|
||||
|
||||
// Restore the GraphDriver field, now omitted when a snapshotter is used.
|
||||
if imageInspect.GraphDriver == nil && inspectData.GraphDriverLegacy != nil {
|
||||
imageInspect.GraphDriver = inspectData.GraphDriverLegacy
|
||||
}
|
||||
} else {
|
||||
if inspectData.Parent != "" {
|
||||
// field is deprecated, but still included in response when present (built with legacy builder).
|
||||
|
||||
Reference in New Issue
Block a user