mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
api/types/container: merge InspectResponse and ContainerJSONBase
Merge the two types instead of embedding the ContainerJSONBase. This should have no impact on the API response, but users constructing a response through struct literals will need to update their code. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -119,16 +119,9 @@ type Summary struct {
|
||||
Mounts []MountPoint
|
||||
}
|
||||
|
||||
// ContainerJSONBase contains response of Engine API GET "/containers/{name:.*}/json"
|
||||
// for API version 1.18 and older.
|
||||
//
|
||||
// TODO(thaJeztah): combine ContainerJSONBase and InspectResponse into a single struct.
|
||||
// The split between ContainerJSONBase (ContainerJSONBase) and InspectResponse (InspectResponse)
|
||||
// was done in commit 6deaa58ba5f051039643cedceee97c8695e2af74 (https://github.com/moby/moby/pull/13675).
|
||||
// ContainerJSONBase contained all fields for API < 1.19, and InspectResponse
|
||||
// held fields that were added in API 1.19 and up. Given that the minimum
|
||||
// supported API version is now 1.24, we no longer use the separate type.
|
||||
type ContainerJSONBase struct {
|
||||
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
|
||||
// endpoint.
|
||||
type InspectResponse struct {
|
||||
ID string `json:"Id"`
|
||||
Created string
|
||||
Path string
|
||||
@@ -151,12 +144,6 @@ type ContainerJSONBase struct {
|
||||
GraphDriver storage.DriverData
|
||||
SizeRw *int64 `json:",omitempty"`
|
||||
SizeRootFs *int64 `json:",omitempty"`
|
||||
}
|
||||
|
||||
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
|
||||
// endpoint.
|
||||
type InspectResponse struct {
|
||||
*ContainerJSONBase
|
||||
Mounts []MountPoint
|
||||
Config *Config
|
||||
NetworkSettings *NetworkSettings
|
||||
|
||||
@@ -75,11 +75,9 @@ func TestContainerInspect(t *testing.T) {
|
||||
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
|
||||
}
|
||||
content, err := json.Marshal(container.InspectResponse{
|
||||
ContainerJSONBase: &container.ContainerJSONBase{
|
||||
ID: "container_id",
|
||||
Image: "image",
|
||||
Name: "name",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -86,16 +86,15 @@ func (daemon *Daemon) ContainerInspect(ctx context.Context, name string, options
|
||||
imageManifest.Platform = &ctr.ImagePlatform
|
||||
}
|
||||
|
||||
return &containertypes.InspectResponse{
|
||||
ContainerJSONBase: base,
|
||||
Mounts: mountPoints,
|
||||
Config: ctr.Config,
|
||||
NetworkSettings: networkSettings,
|
||||
ImageManifestDescriptor: imageManifest,
|
||||
}, nil
|
||||
base.Mounts = mountPoints
|
||||
base.Config = ctr.Config
|
||||
base.NetworkSettings = networkSettings
|
||||
base.ImageManifestDescriptor = imageManifest
|
||||
|
||||
return base, nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) getInspectData(daemonCfg *config.Config, ctr *container.Container) (*containertypes.ContainerJSONBase, error) {
|
||||
func (daemon *Daemon) getInspectData(daemonCfg *config.Config, ctr *container.Container) (*containertypes.InspectResponse, error) {
|
||||
// make a copy to play with
|
||||
hostConfig := *ctr.HostConfig
|
||||
|
||||
@@ -130,7 +129,7 @@ func (daemon *Daemon) getInspectData(daemonCfg *config.Config, ctr *container.Co
|
||||
}
|
||||
}
|
||||
|
||||
inspectResponse := &containertypes.ContainerJSONBase{
|
||||
inspectResponse := &containertypes.InspectResponse{
|
||||
ID: ctr.ID,
|
||||
Created: ctr.Created.Format(time.RFC3339Nano),
|
||||
Path: ctr.Path,
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// This sets platform-specific fields
|
||||
func setPlatformSpecificContainerFields(ctr *containerpkg.Container, resp *container.ContainerJSONBase) *container.ContainerJSONBase {
|
||||
func setPlatformSpecificContainerFields(ctr *containerpkg.Container, resp *container.InspectResponse) *container.InspectResponse {
|
||||
resp.AppArmorProfile = ctr.AppArmorProfile
|
||||
resp.ResolvConfPath = ctr.ResolvConfPath
|
||||
resp.HostnamePath = ctr.HostnamePath
|
||||
|
||||
@@ -6,6 +6,6 @@ import (
|
||||
)
|
||||
|
||||
// This sets platform-specific fields
|
||||
func setPlatformSpecificContainerFields(ctr *containerpkg.Container, resp *container.ContainerJSONBase) *container.ContainerJSONBase {
|
||||
func setPlatformSpecificContainerFields(ctr *containerpkg.Container, resp *container.InspectResponse) *container.InspectResponse {
|
||||
return resp
|
||||
}
|
||||
|
||||
19
vendor/github.com/moby/moby/api/types/container/container.go
generated
vendored
19
vendor/github.com/moby/moby/api/types/container/container.go
generated
vendored
@@ -119,16 +119,9 @@ type Summary struct {
|
||||
Mounts []MountPoint
|
||||
}
|
||||
|
||||
// ContainerJSONBase contains response of Engine API GET "/containers/{name:.*}/json"
|
||||
// for API version 1.18 and older.
|
||||
//
|
||||
// TODO(thaJeztah): combine ContainerJSONBase and InspectResponse into a single struct.
|
||||
// The split between ContainerJSONBase (ContainerJSONBase) and InspectResponse (InspectResponse)
|
||||
// was done in commit 6deaa58ba5f051039643cedceee97c8695e2af74 (https://github.com/moby/moby/pull/13675).
|
||||
// ContainerJSONBase contained all fields for API < 1.19, and InspectResponse
|
||||
// held fields that were added in API 1.19 and up. Given that the minimum
|
||||
// supported API version is now 1.24, we no longer use the separate type.
|
||||
type ContainerJSONBase struct {
|
||||
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
|
||||
// endpoint.
|
||||
type InspectResponse struct {
|
||||
ID string `json:"Id"`
|
||||
Created string
|
||||
Path string
|
||||
@@ -151,12 +144,6 @@ type ContainerJSONBase struct {
|
||||
GraphDriver storage.DriverData
|
||||
SizeRw *int64 `json:",omitempty"`
|
||||
SizeRootFs *int64 `json:",omitempty"`
|
||||
}
|
||||
|
||||
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
|
||||
// endpoint.
|
||||
type InspectResponse struct {
|
||||
*ContainerJSONBase
|
||||
Mounts []MountPoint
|
||||
Config *Config
|
||||
NetworkSettings *NetworkSettings
|
||||
|
||||
Reference in New Issue
Block a user