mirror of
https://github.com/containers/podman.git
synced 2025-10-16 10:43:52 +08:00
Merge pull request #27172 from ninja-quokka/docker_compate_145
[compat api] Remove ContainerConfig field
This commit is contained in:
@ -390,24 +390,23 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image, r *http.Req
|
|||||||
cc.Volumes = info.Config.Volumes
|
cc.Volumes = info.Config.Volumes
|
||||||
|
|
||||||
dockerImageInspect := dockerImage.InspectResponse{
|
dockerImageInspect := dockerImage.InspectResponse{
|
||||||
Architecture: info.Architecture,
|
Architecture: info.Architecture,
|
||||||
Author: info.Author,
|
Author: info.Author,
|
||||||
Comment: info.Comment,
|
Comment: info.Comment,
|
||||||
Config: &config,
|
Config: &config,
|
||||||
ContainerConfig: cc,
|
Created: l.Created().Format(time.RFC3339Nano),
|
||||||
Created: l.Created().Format(time.RFC3339Nano),
|
DockerVersion: info.Version,
|
||||||
DockerVersion: info.Version,
|
GraphDriver: graphDriver,
|
||||||
GraphDriver: graphDriver,
|
ID: "sha256:" + l.ID(),
|
||||||
ID: "sha256:" + l.ID(),
|
Metadata: dockerImage.Metadata{},
|
||||||
Metadata: dockerImage.Metadata{},
|
Os: info.Os,
|
||||||
Os: info.Os,
|
OsVersion: info.Version,
|
||||||
OsVersion: info.Version,
|
Parent: info.Parent,
|
||||||
Parent: info.Parent,
|
RepoDigests: info.RepoDigests,
|
||||||
RepoDigests: info.RepoDigests,
|
RepoTags: info.RepoTags,
|
||||||
RepoTags: info.RepoTags,
|
RootFS: rootfs,
|
||||||
RootFS: rootfs,
|
Size: info.Size,
|
||||||
Size: info.Size,
|
Variant: "",
|
||||||
Variant: "",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := apiutil.SupportedVersion(r, "<1.44.0"); err == nil {
|
if _, err := apiutil.SupportedVersion(r, "<1.44.0"); err == nil {
|
||||||
@ -415,6 +414,10 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image, r *http.Req
|
|||||||
dockerImageInspect.VirtualSize = info.VirtualSize
|
dockerImageInspect.VirtualSize = info.VirtualSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err := apiutil.SupportedVersion(r, "<1.45.0"); err == nil {
|
||||||
|
dockerImageInspect.ContainerConfig = cc //nolint:staticcheck // Deprecated field
|
||||||
|
}
|
||||||
|
|
||||||
return &handlers.ImageInspect{InspectResponse: dockerImageInspect}, nil
|
return &handlers.ImageInspect{InspectResponse: dockerImageInspect}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,13 @@ type AuthConfig struct {
|
|||||||
|
|
||||||
type ImageInspect struct {
|
type ImageInspect struct {
|
||||||
dockerImage.InspectResponse
|
dockerImage.InspectResponse
|
||||||
// Container is for backwards compat but is basically unused
|
// When you embed a struct, the fields of the embedded struct are "promoted" to the outer struct.
|
||||||
Container string
|
// If a field in the outer struct has the same name as a field in the embedded struct,
|
||||||
|
// the outer struct's field will shadow or override the embedded one allowing for a clean way to
|
||||||
|
// hide fields from the swagger spec that still exist in the libraries struct.
|
||||||
|
Container string `json:"-"`
|
||||||
|
ContainerConfig string `json:"-"`
|
||||||
|
VirtualSize string `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerConfig struct {
|
type ContainerConfig struct {
|
||||||
|
@ -66,6 +66,14 @@ t GET /v1.43/images/$iid/json 200 \
|
|||||||
t GET /v1.44/images/$iid/json 200 \
|
t GET /v1.44/images/$iid/json 200 \
|
||||||
.VirtualSize=null
|
.VirtualSize=null
|
||||||
|
|
||||||
|
# Test ContainerConfig fields are present in API v1.44 (backward compatibility)
|
||||||
|
t GET /v1.44/images/$iid/json 200 \
|
||||||
|
.ContainerConfig.Hostname~[0-9a-f]
|
||||||
|
|
||||||
|
# Test ContainerConfig fields are no longer present in API >= v1.45 (deprecated since API v1.44, omitted since API v1.45)
|
||||||
|
t GET /v1.45/images/$iid/json 200 \
|
||||||
|
.ContainerConfig=null
|
||||||
|
|
||||||
t POST "images/create?fromImage=alpine" 200 .error~null .status~".*Download complete.*"
|
t POST "images/create?fromImage=alpine" 200 .error~null .status~".*Download complete.*"
|
||||||
t POST "libpod/images/pull?reference=alpine&compatMode=true" 200 .error~null .status~".*Download complete.*"
|
t POST "libpod/images/pull?reference=alpine&compatMode=true" 200 .error~null .status~".*Download complete.*"
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ class ImageTestCase(APITestCase):
|
|||||||
"SharedSize",
|
"SharedSize",
|
||||||
"VirtualSize",
|
"VirtualSize",
|
||||||
"Labels",
|
"Labels",
|
||||||
"Containers",
|
|
||||||
)
|
)
|
||||||
images = r.json()
|
images = r.json()
|
||||||
self.assertIsInstance(images, list)
|
self.assertIsInstance(images, list)
|
||||||
@ -45,7 +44,6 @@ class ImageTestCase(APITestCase):
|
|||||||
"Parent",
|
"Parent",
|
||||||
"Comment",
|
"Comment",
|
||||||
"Created",
|
"Created",
|
||||||
"Container",
|
|
||||||
"DockerVersion",
|
"DockerVersion",
|
||||||
"Author",
|
"Author",
|
||||||
"Architecture",
|
"Architecture",
|
||||||
|
Reference in New Issue
Block a user