Skip to content

Commit 45e2a1b

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
1 parent d58e496 commit 45e2a1b

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

pkg/api/handlers/compat/images.go

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -390,31 +390,35 @@ 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+
//nolint:staticcheck // Deprecated field
419+
dockerImageInspect.ContainerConfig = cc
420+
}
421+
418422
return &handlers.ImageInspect{InspectResponse: dockerImageInspect}, nil
419423
}
420424

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

0 commit comments

Comments
 (0)