Skip to content

Commit a28b0a2

Browse files
committed
[compat api] Remove ContainerConfig field
ContainerConfig has been removed from v1.45 InspectResponse.Container has also been removed but it seems we never implemented it. Ref: https://docs.docker.com/reference/api/engine/version-history/#v145-api-changes Signed-off-by: Lewis Roy <lewis@redhat.com>
1 parent d58e496 commit a28b0a2

File tree

4 files changed

+36
-22
lines changed

4 files changed

+36
-22
lines changed

pkg/api/handlers/compat/images.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -390,31 +390,34 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image, r *http.Req
390390
cc.Volumes = info.Config.Volumes
391391

392392
dockerImageInspect := dockerImage.InspectResponse{
393-
Architecture: info.Architecture,
394-
Author: info.Author,
395-
Comment: info.Comment,
396-
Config: &config,
397-
ContainerConfig: cc,
398-
Created: l.Created().Format(time.RFC3339Nano),
399-
DockerVersion: info.Version,
400-
GraphDriver: graphDriver,
401-
ID: "sha256:" + l.ID(),
402-
Metadata: dockerImage.Metadata{},
403-
Os: info.Os,
404-
OsVersion: info.Version,
405-
Parent: info.Parent,
406-
RepoDigests: info.RepoDigests,
407-
RepoTags: info.RepoTags,
408-
RootFS: rootfs,
409-
Size: info.Size,
410-
Variant: "",
393+
Architecture: info.Architecture,
394+
Author: info.Author,
395+
Comment: info.Comment,
396+
Config: &config,
397+
Created: l.Created().Format(time.RFC3339Nano),
398+
DockerVersion: info.Version,
399+
GraphDriver: graphDriver,
400+
ID: "sha256:" + l.ID(),
401+
Metadata: dockerImage.Metadata{},
402+
Os: info.Os,
403+
OsVersion: info.Version,
404+
Parent: info.Parent,
405+
RepoDigests: info.RepoDigests,
406+
RepoTags: info.RepoTags,
407+
RootFS: rootfs,
408+
Size: info.Size,
409+
Variant: "",
411410
}
412411

413412
if _, err := apiutil.SupportedVersion(r, "<1.44.0"); err == nil {
414413
//nolint:staticcheck // Deprecated field
415414
dockerImageInspect.VirtualSize = info.VirtualSize
416415
}
417416

417+
if _, err := apiutil.SupportedVersion(r, "<1.45.0"); err == nil {
418+
dockerImageInspect.ContainerConfig = cc //nolint:staticcheck // Deprecated field
419+
}
420+
418421
return &handlers.ImageInspect{InspectResponse: dockerImageInspect}, nil
419422
}
420423

pkg/api/handlers/types.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ type AuthConfig struct {
2020

2121
type ImageInspect struct {
2222
dockerImage.InspectResponse
23-
// Container is for backwards compat but is basically unused
24-
Container string
23+
// When you embed a struct, the fields of the embedded struct are "promoted" to the outer struct.
24+
// If a field in the outer struct has the same name as a field in the embedded struct,
25+
// the outer struct's field will shadow or override the embedded one allowing for a clean way to
26+
// hide fields from the swagger spec that still exist in the libraries struct.
27+
Container string `json:"-"`
28+
ContainerConfig string `json:"-"`
29+
VirtualSize string `json:"-"`
2530
}
2631

2732
type ContainerConfig struct {

test/apiv2/10-images.at

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ t GET /v1.43/images/$iid/json 200 \
6666
t GET /v1.44/images/$iid/json 200 \
6767
.VirtualSize=null
6868

69+
# Test ContainerConfig fields are present in API v1.44 (backward compatibility)
70+
t GET /v1.44/images/$iid/json 200 \
71+
.ContainerConfig.Hostname~[0-9a-f]
72+
73+
# Test ContainerConfig fields are no longer present in API v1.45+ (deprecated since API v1.45)
74+
t GET /v1.45/images/$iid/json 200 \
75+
.ContainerConfig=null
76+
6977
t POST "images/create?fromImage=alpine" 200 .error~null .status~".*Download complete.*"
7078
t POST "libpod/images/pull?reference=alpine&compatMode=true" 200 .error~null .status~".*Download complete.*"
7179

test/apiv2/python/rest_api/test_v2_0_0_image.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def test_list(self):
2323
"SharedSize",
2424
"VirtualSize",
2525
"Labels",
26-
"Containers",
2726
)
2827
images = r.json()
2928
self.assertIsInstance(images, list)
@@ -45,7 +44,6 @@ def test_inspect(self):
4544
"Parent",
4645
"Comment",
4746
"Created",
48-
"Container",
4947
"DockerVersion",
5048
"Author",
5149
"Architecture",

0 commit comments

Comments
 (0)