mirror of
https://github.com/containers/podman.git
synced 2025-10-17 03:04:21 +08:00
fix deprecated docker v28 types
A lot of types are moved and now deprecated which causes lint issues. IDResponse is copied into podman because that has no new 1 to 1 replacement. For some fields that we set as part of the docker API I added the nolint directive as these fields might be used by API consumers. For the other types it is mostly a 1 to 1 move. ParseUintList is deprecated but we can use the same function from github.com/containers/storage/pkg/parsers instead. Note that it containers breaking changes to pkg/bindings which we should not do generally but given the prevoius commit already has a unavoidable breaking change we might as well fix the IDResponse issue once now. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -21,7 +21,7 @@ import (
|
|||||||
"github.com/containers/podman/v5/pkg/specgen"
|
"github.com/containers/podman/v5/pkg/specgen"
|
||||||
"github.com/containers/podman/v5/pkg/specgenutil"
|
"github.com/containers/podman/v5/pkg/specgenutil"
|
||||||
"github.com/containers/podman/v5/pkg/util"
|
"github.com/containers/podman/v5/pkg/util"
|
||||||
"github.com/docker/docker/pkg/parsers"
|
"github.com/containers/storage/pkg/parsers"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -24,10 +24,10 @@ import (
|
|||||||
"github.com/containers/podman/v5/pkg/ps"
|
"github.com/containers/podman/v5/pkg/ps"
|
||||||
"github.com/containers/podman/v5/pkg/signal"
|
"github.com/containers/podman/v5/pkg/signal"
|
||||||
"github.com/containers/podman/v5/pkg/util"
|
"github.com/containers/podman/v5/pkg/util"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
dockerBackend "github.com/docker/docker/api/types/backend"
|
dockerBackend "github.com/docker/docker/api/types/backend"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
|
"github.com/docker/docker/api/types/storage"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
@ -347,9 +347,9 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ports := make([]types.Port, len(portMappings))
|
ports := make([]container.Port, len(portMappings))
|
||||||
for idx, portMapping := range portMappings {
|
for idx, portMapping := range portMappings {
|
||||||
ports[idx] = types.Port{
|
ports[idx] = container.Port{
|
||||||
IP: portMapping.HostIP,
|
IP: portMapping.HostIP,
|
||||||
PrivatePort: portMapping.ContainerPort,
|
PrivatePort: portMapping.ContainerPort,
|
||||||
PublicPort: portMapping.HostPort,
|
PublicPort: portMapping.HostPort,
|
||||||
@ -365,7 +365,7 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
networkSettings := types.SummaryNetworkSettings{}
|
networkSettings := container.NetworkSettingsSummary{}
|
||||||
if err := json.Unmarshal(n, &networkSettings); err != nil {
|
if err := json.Unmarshal(n, &networkSettings); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -374,13 +374,13 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mounts := []types.MountPoint{}
|
mounts := []container.MountPoint{}
|
||||||
if err := json.Unmarshal(m, &mounts); err != nil {
|
if err := json.Unmarshal(m, &mounts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &handlers.Container{
|
return &handlers.Container{
|
||||||
Container: types.Container{
|
Container: container.Summary{
|
||||||
ID: l.ID(),
|
ID: l.ID(),
|
||||||
Names: []string{fmt.Sprintf("/%s", l.Name())},
|
Names: []string{fmt.Sprintf("/%s", l.Name())},
|
||||||
Image: imageName,
|
Image: imageName,
|
||||||
@ -408,7 +408,7 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertSecondaryIPPrefixLen(input *define.InspectNetworkSettings, output *types.NetworkSettings) {
|
func convertSecondaryIPPrefixLen(input *define.InspectNetworkSettings, output *container.NetworkSettings) {
|
||||||
for index, ip := range input.SecondaryIPAddresses {
|
for index, ip := range input.SecondaryIPAddresses {
|
||||||
output.SecondaryIPAddresses[index].PrefixLen = ip.PrefixLength
|
output.SecondaryIPAddresses[index].PrefixLen = ip.PrefixLength
|
||||||
}
|
}
|
||||||
@ -417,7 +417,7 @@ func convertSecondaryIPPrefixLen(input *define.InspectNetworkSettings, output *t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, error) {
|
func LibpodToContainerJSON(l *libpod.Container, sz bool) (*container.InspectResponse, error) {
|
||||||
imageID, imageName := l.Image()
|
imageID, imageName := l.Image()
|
||||||
inspect, err := l.Inspect(sz)
|
inspect, err := l.Inspect(sz)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -432,7 +432,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
state := types.ContainerState{}
|
state := container.State{}
|
||||||
if err := json.Unmarshal(i, &state); err != nil {
|
if err := json.Unmarshal(i, &state); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -448,14 +448,14 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if l.HasHealthCheck() && state.Status != "created" {
|
if l.HasHealthCheck() && state.Status != "created" {
|
||||||
state.Health = &types.Health{}
|
state.Health = &container.Health{}
|
||||||
if inspect.State.Health != nil {
|
if inspect.State.Health != nil {
|
||||||
state.Health.Status = inspect.State.Health.Status
|
state.Health.Status = inspect.State.Health.Status
|
||||||
state.Health.FailingStreak = inspect.State.Health.FailingStreak
|
state.Health.FailingStreak = inspect.State.Health.FailingStreak
|
||||||
log := inspect.State.Health.Log
|
log := inspect.State.Health.Log
|
||||||
|
|
||||||
for _, item := range log {
|
for _, item := range log {
|
||||||
res := &types.HealthcheckResult{}
|
res := &container.HealthcheckResult{}
|
||||||
s, err := time.Parse(time.RFC3339Nano, item.Start)
|
s, err := time.Parse(time.RFC3339Nano, item.Start)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -490,16 +490,13 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
|||||||
if hc.LogConfig.Type == define.KubernetesLogging {
|
if hc.LogConfig.Type == define.KubernetesLogging {
|
||||||
hc.LogConfig.Type = define.JSONLogging
|
hc.LogConfig.Type = define.JSONLogging
|
||||||
}
|
}
|
||||||
g, err := json.Marshal(inspect.GraphDriver)
|
|
||||||
if err != nil {
|
graphDriver := storage.DriverData{
|
||||||
return nil, err
|
Name: inspect.GraphDriver.Name,
|
||||||
}
|
Data: inspect.GraphDriver.Data,
|
||||||
graphDriver := types.GraphDriverData{}
|
|
||||||
if err := json.Unmarshal(g, &graphDriver); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cb := types.ContainerJSONBase{
|
cb := container.ContainerJSONBase{
|
||||||
ID: l.ID(),
|
ID: l.ID(),
|
||||||
Created: l.CreatedTime().UTC().Format(time.RFC3339Nano), // Docker uses UTC
|
Created: l.CreatedTime().UTC().Format(time.RFC3339Nano), // Docker uses UTC
|
||||||
Path: inspect.Path,
|
Path: inspect.Path,
|
||||||
@ -587,7 +584,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mounts := []types.MountPoint{}
|
mounts := []container.MountPoint{}
|
||||||
if err := json.Unmarshal(m, &mounts); err != nil {
|
if err := json.Unmarshal(m, &mounts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -606,7 +603,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
networkSettings := types.NetworkSettings{}
|
networkSettings := container.NetworkSettings{}
|
||||||
if err := json.Unmarshal(n, &networkSettings); err != nil {
|
if err := json.Unmarshal(n, &networkSettings); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -618,7 +615,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
|||||||
networkSettings.Networks = map[string]*network.EndpointSettings{}
|
networkSettings.Networks = map[string]*network.EndpointSettings{}
|
||||||
}
|
}
|
||||||
|
|
||||||
c := types.ContainerJSON{
|
c := container.InspectResponse{
|
||||||
ContainerJSONBase: &cb,
|
ContainerJSONBase: &cb,
|
||||||
Mounts: mounts,
|
Mounts: mounts,
|
||||||
Config: &config,
|
Config: &config,
|
||||||
@ -790,6 +787,6 @@ func UpdateContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
responseStruct := container.ContainerUpdateOKBody{}
|
responseStruct := container.UpdateResponse{}
|
||||||
utils.WriteResponse(w, http.StatusOK, responseStruct)
|
utils.WriteResponse(w, http.StatusOK, responseStruct)
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ import (
|
|||||||
"github.com/containers/podman/v5/pkg/domain/infra/abi"
|
"github.com/containers/podman/v5/pkg/domain/infra/abi"
|
||||||
"github.com/containers/podman/v5/pkg/util"
|
"github.com/containers/podman/v5/pkg/util"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
docker "github.com/docker/docker/api/types"
|
|
||||||
dockerContainer "github.com/docker/docker/api/types/container"
|
dockerContainer "github.com/docker/docker/api/types/container"
|
||||||
dockerImage "github.com/docker/docker/api/types/image"
|
dockerImage "github.com/docker/docker/api/types/image"
|
||||||
|
dockerStorage "github.com/docker/docker/api/types/storage"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -371,7 +371,7 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image) (*handlers.
|
|||||||
StopSignal: info.Config.StopSignal,
|
StopSignal: info.Config.StopSignal,
|
||||||
}
|
}
|
||||||
|
|
||||||
rootfs := docker.RootFS{}
|
rootfs := dockerImage.RootFS{}
|
||||||
if info.RootFS != nil {
|
if info.RootFS != nil {
|
||||||
rootfs.Type = info.RootFS.Type
|
rootfs.Type = info.RootFS.Type
|
||||||
rootfs.Layers = make([]string, 0, len(info.RootFS.Layers))
|
rootfs.Layers = make([]string, 0, len(info.RootFS.Layers))
|
||||||
@ -380,7 +380,7 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image) (*handlers.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
graphDriver := docker.GraphDriverData{
|
graphDriver := dockerStorage.DriverData{
|
||||||
Name: info.GraphDriver.Name,
|
Name: info.GraphDriver.Name,
|
||||||
Data: info.GraphDriver.Data,
|
Data: info.GraphDriver.Data,
|
||||||
}
|
}
|
||||||
@ -389,7 +389,7 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image) (*handlers.
|
|||||||
cc.Hostname = info.ID[0:11] // short ID is the hostname
|
cc.Hostname = info.ID[0:11] // short ID is the hostname
|
||||||
cc.Volumes = info.Config.Volumes
|
cc.Volumes = info.Config.Volumes
|
||||||
|
|
||||||
dockerImageInspect := docker.ImageInspect{
|
dockerImageInspect := dockerImage.InspectResponse{
|
||||||
Architecture: info.Architecture,
|
Architecture: info.Architecture,
|
||||||
Author: info.Author,
|
Author: info.Author,
|
||||||
Comment: info.Comment,
|
Comment: info.Comment,
|
||||||
@ -410,7 +410,7 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image) (*handlers.
|
|||||||
Variant: "",
|
Variant: "",
|
||||||
VirtualSize: info.VirtualSize,
|
VirtualSize: info.VirtualSize,
|
||||||
}
|
}
|
||||||
return &handlers.ImageInspect{ImageInspect: dockerImageInspect}, nil
|
return &handlers.ImageInspect{InspectResponse: dockerImageInspect}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// portsToPortSet converts libpod's exposed ports to docker's structs
|
// portsToPortSet converts libpod's exposed ports to docker's structs
|
||||||
|
@ -165,6 +165,7 @@ loop: // break out of for/select infinite loop
|
|||||||
Current: int64(e.Offset),
|
Current: int64(e.Offset),
|
||||||
Total: e.Artifact.Size,
|
Total: e.Artifact.Size,
|
||||||
}
|
}
|
||||||
|
//nolint:staticcheck // Deprecated field, but because consumers might still read it keep it.
|
||||||
report.ProgressMessage = report.Progress.String()
|
report.ProgressMessage = report.Progress.String()
|
||||||
case types.ProgressEventSkipped:
|
case types.ProgressEventSkipped:
|
||||||
report.Status = "Layer already exists"
|
report.Status = "Layer already exists"
|
||||||
@ -190,6 +191,7 @@ loop: // break out of for/select infinite loop
|
|||||||
report.Error = &jsonmessage.JSONError{
|
report.Error = &jsonmessage.JSONError{
|
||||||
Message: msg,
|
Message: msg,
|
||||||
}
|
}
|
||||||
|
//nolint:staticcheck // Deprecated field, but because consumers might still read it keep it.
|
||||||
report.ErrorMessage = msg
|
report.ErrorMessage = msg
|
||||||
if err := enc.Encode(report); err != nil {
|
if err := enc.Encode(report); err != nil {
|
||||||
logrus.Warnf("Failed to json encode error %q", err.Error())
|
logrus.Warnf("Failed to json encode error %q", err.Error())
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/containers/podman/v5/pkg/domain/entities"
|
"github.com/containers/podman/v5/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v5/pkg/domain/infra/abi"
|
"github.com/containers/podman/v5/pkg/domain/infra/abi"
|
||||||
docker "github.com/docker/docker/api/types"
|
docker "github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/container"
|
||||||
dockerImage "github.com/docker/docker/api/types/image"
|
dockerImage "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"github.com/docker/docker/api/types/volume"
|
||||||
)
|
)
|
||||||
@ -44,9 +45,9 @@ func GetDiskUsage(w http.ResponseWriter, r *http.Request) {
|
|||||||
imgs[i] = &t
|
imgs[i] = &t
|
||||||
}
|
}
|
||||||
|
|
||||||
ctnrs := make([]*docker.Container, len(df.Containers))
|
ctnrs := make([]*container.Summary, len(df.Containers))
|
||||||
for i, o := range df.Containers {
|
for i, o := range df.Containers {
|
||||||
t := docker.Container{
|
t := container.Summary{
|
||||||
ID: o.ContainerID,
|
ID: o.ContainerID,
|
||||||
Names: []string{o.Names},
|
Names: []string{o.Names},
|
||||||
Image: o.Image,
|
Image: o.Image,
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/containers/podman/v5/pkg/domain/entities"
|
"github.com/containers/podman/v5/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v5/pkg/domain/entities/reports"
|
"github.com/containers/podman/v5/pkg/domain/entities/reports"
|
||||||
"github.com/containers/podman/v5/pkg/inspect"
|
"github.com/containers/podman/v5/pkg/inspect"
|
||||||
dockerAPI "github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/container"
|
||||||
dockerImage "github.com/docker/docker/api/types/image"
|
dockerImage "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"github.com/docker/docker/api/types/volume"
|
||||||
@ -125,7 +125,7 @@ type inspectImageResponseLibpod struct {
|
|||||||
// swagger:response
|
// swagger:response
|
||||||
type containerInspectResponse struct {
|
type containerInspectResponse struct {
|
||||||
// in:body
|
// in:body
|
||||||
Body dockerAPI.ContainerJSON
|
Body container.InspectResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// List processes in container
|
// List processes in container
|
||||||
|
@ -19,7 +19,7 @@ type AuthConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ImageInspect struct {
|
type ImageInspect struct {
|
||||||
docker.ImageInspect
|
dockerImage.InspectResponse
|
||||||
// Container is for backwards compat but is basically unused
|
// Container is for backwards compat but is basically unused
|
||||||
Container string
|
Container string
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,7 @@ loop: // break out of for/select infinite loop
|
|||||||
report.Status = "Downloading"
|
report.Status = "Downloading"
|
||||||
report.Progress.Current = int64(e.Offset)
|
report.Progress.Current = int64(e.Offset)
|
||||||
report.Progress.Total = e.Artifact.Size
|
report.Progress.Total = e.Artifact.Size
|
||||||
|
//nolint:staticcheck // Deprecated field, but because consumers might still read it keep it.
|
||||||
report.ProgressMessage = report.Progress.String()
|
report.ProgressMessage = report.Progress.String()
|
||||||
case types.ProgressEventSkipped:
|
case types.ProgressEventSkipped:
|
||||||
report.Status = "Already exists"
|
report.Status = "Already exists"
|
||||||
@ -193,6 +194,7 @@ loop: // break out of for/select infinite loop
|
|||||||
report.Error = &jsonmessage.JSONError{
|
report.Error = &jsonmessage.JSONError{
|
||||||
Message: msg,
|
Message: msg,
|
||||||
}
|
}
|
||||||
|
//nolint:staticcheck // Deprecated field, but because consumers might still read it keep it.
|
||||||
report.ErrorMessage = msg
|
report.ErrorMessage = msg
|
||||||
} else {
|
} else {
|
||||||
pulledImages := pullRes.images
|
pulledImages := pullRes.images
|
||||||
@ -205,6 +207,7 @@ loop: // break out of for/select infinite loop
|
|||||||
report.Error = &jsonmessage.JSONError{
|
report.Error = &jsonmessage.JSONError{
|
||||||
Message: msg,
|
Message: msg,
|
||||||
}
|
}
|
||||||
|
//nolint:staticcheck // Deprecated field, but because consumers might still read it keep it.
|
||||||
report.ErrorMessage = msg
|
report.ErrorMessage = msg
|
||||||
writeStatusCode(http.StatusInternalServerError)
|
writeStatusCode(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
@ -11,26 +11,26 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/podman/v5/pkg/bindings"
|
"github.com/containers/podman/v5/pkg/bindings"
|
||||||
"github.com/containers/podman/v5/pkg/bindings/images"
|
"github.com/containers/podman/v5/pkg/bindings/images"
|
||||||
|
"github.com/containers/podman/v5/pkg/domain/entities/types"
|
||||||
"github.com/containers/storage/pkg/regexp"
|
"github.com/containers/storage/pkg/regexp"
|
||||||
dockerAPI "github.com/docker/docker/api/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var iidRegex = regexp.Delayed(`^[0-9a-f]{12}`)
|
var iidRegex = regexp.Delayed(`^[0-9a-f]{12}`)
|
||||||
|
|
||||||
// Commit creates a container image from a container. The container is defined by nameOrID. Use
|
// Commit creates a container image from a container. The container is defined by nameOrID. Use
|
||||||
// the CommitOptions for finer grain control on characteristics of the resulting image.
|
// the CommitOptions for finer grain control on characteristics of the resulting image.
|
||||||
func Commit(ctx context.Context, nameOrID string, options *CommitOptions) (dockerAPI.IDResponse, error) {
|
func Commit(ctx context.Context, nameOrID string, options *CommitOptions) (types.IDResponse, error) {
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = new(CommitOptions)
|
options = new(CommitOptions)
|
||||||
}
|
}
|
||||||
id := dockerAPI.IDResponse{}
|
id := types.IDResponse{}
|
||||||
conn, err := bindings.GetClient(ctx)
|
conn, err := bindings.GetClient(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return id, err
|
return id, err
|
||||||
}
|
}
|
||||||
params, err := options.ToParams()
|
params, err := options.ToParams()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dockerAPI.IDResponse{}, err
|
return types.IDResponse{}, err
|
||||||
}
|
}
|
||||||
params.Set("container", nameOrID)
|
params.Set("container", nameOrID)
|
||||||
var requestBody io.Reader
|
var requestBody io.Reader
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/containers/podman/v5/libpod/define"
|
"github.com/containers/podman/v5/libpod/define"
|
||||||
"github.com/containers/podman/v5/pkg/api/handlers"
|
"github.com/containers/podman/v5/pkg/api/handlers"
|
||||||
"github.com/containers/podman/v5/pkg/bindings"
|
"github.com/containers/podman/v5/pkg/bindings"
|
||||||
dockerAPI "github.com/docker/docker/api/types"
|
"github.com/containers/podman/v5/pkg/domain/entities/types"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -43,7 +43,7 @@ func ExecCreate(ctx context.Context, nameOrID string, config *handlers.ExecCreat
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
respStruct := new(dockerAPI.IDResponse)
|
respStruct := new(types.IDResponse)
|
||||||
if err := resp.Process(respStruct); err != nil {
|
if err := resp.Process(respStruct); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/containers/podman/v5/pkg/bindings/images"
|
"github.com/containers/podman/v5/pkg/bindings/images"
|
||||||
entitiesTypes "github.com/containers/podman/v5/pkg/domain/entities/types"
|
entitiesTypes "github.com/containers/podman/v5/pkg/domain/entities/types"
|
||||||
"github.com/containers/podman/v5/pkg/errorhandling"
|
"github.com/containers/podman/v5/pkg/errorhandling"
|
||||||
dockerAPI "github.com/docker/docker/api/types"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ import (
|
|||||||
// of a list if the name provided is a manifest list. The ID of the new manifest list
|
// of a list if the name provided is a manifest list. The ID of the new manifest list
|
||||||
// is returned as a string.
|
// is returned as a string.
|
||||||
func Create(ctx context.Context, name string, images []string, options *CreateOptions) (string, error) {
|
func Create(ctx context.Context, name string, images []string, options *CreateOptions) (string, error) {
|
||||||
var idr dockerAPI.IDResponse
|
var idr entitiesTypes.IDResponse
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = new(CreateOptions)
|
options = new(CreateOptions)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
entitiesTypes "github.com/containers/podman/v5/pkg/domain/entities/types"
|
entitiesTypes "github.com/containers/podman/v5/pkg/domain/entities/types"
|
||||||
"github.com/containers/podman/v5/pkg/specgen"
|
"github.com/containers/podman/v5/pkg/specgen"
|
||||||
"github.com/containers/storage/pkg/archive"
|
"github.com/containers/storage/pkg/archive"
|
||||||
dockerAPI "github.com/docker/docker/api/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Container struct {
|
type Container struct {
|
||||||
@ -117,5 +116,4 @@ type IDOrNameResponse struct {
|
|||||||
IDOrName string
|
IDOrName string
|
||||||
}
|
}
|
||||||
|
|
||||||
// swagger:model
|
type IDResponse = entitiesTypes.IDResponse
|
||||||
type IDResponse dockerAPI.IDResponse
|
|
||||||
|
@ -77,3 +77,11 @@ type BuildReport struct {
|
|||||||
// Format to save the image in
|
// Format to save the image in
|
||||||
SaveFormat string
|
SaveFormat string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// swagger:model
|
||||||
|
type IDResponse struct {
|
||||||
|
|
||||||
|
// The id of the newly created object.
|
||||||
|
// Required: true
|
||||||
|
ID string `json:"Id"`
|
||||||
|
}
|
||||||
|
106
vendor/github.com/docker/docker/pkg/parsers/parsers.go
generated
vendored
106
vendor/github.com/docker/docker/pkg/parsers/parsers.go
generated
vendored
@ -1,106 +0,0 @@
|
|||||||
// Package parsers provides helper functions to parse and validate different type
|
|
||||||
// of string. It can be hosts, unix addresses, tcp addresses, filters, kernel
|
|
||||||
// operating system versions.
|
|
||||||
package parsers // import "github.com/docker/docker/pkg/parsers"
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ParseKeyValueOpt parses and validates the specified string as a key/value
|
|
||||||
// pair (key=value).
|
|
||||||
//
|
|
||||||
// Deprecated: use [strings.Cut] instead. This utility was only used internally, and will be removed in the next release.
|
|
||||||
func ParseKeyValueOpt(opt string) (key string, value string, err error) {
|
|
||||||
k, v, ok := strings.Cut(opt, "=")
|
|
||||||
if !ok {
|
|
||||||
return "", "", fmt.Errorf("unable to parse key/value option: %s", opt)
|
|
||||||
}
|
|
||||||
return strings.TrimSpace(k), strings.TrimSpace(v), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseUintListMaximum parses and validates the specified string as the value
|
|
||||||
// found in some cgroup file (e.g. `cpuset.cpus`, `cpuset.mems`), which could be
|
|
||||||
// one of the formats below. Note that duplicates are actually allowed in the
|
|
||||||
// input string. It returns a `map[int]bool` with available elements from `val`
|
|
||||||
// set to `true`. Values larger than `maximum` cause an error if max is non zero,
|
|
||||||
// in order to stop the map becoming excessively large.
|
|
||||||
// Supported formats:
|
|
||||||
//
|
|
||||||
// 7
|
|
||||||
// 1-6
|
|
||||||
// 0,3-4,7,8-10
|
|
||||||
// 0-0,0,1-7
|
|
||||||
// 03,1-3 <- this is gonna get parsed as [1,2,3]
|
|
||||||
// 3,2,1
|
|
||||||
// 0-2,3,1
|
|
||||||
//
|
|
||||||
// Deprecated: ParseUintListMaximum was only used internally and will be removed in the next release.
|
|
||||||
func ParseUintListMaximum(val string, maximum int) (map[int]bool, error) {
|
|
||||||
return parseUintList(val, maximum)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseUintList parses and validates the specified string as the value
|
|
||||||
// found in some cgroup file (e.g. `cpuset.cpus`, `cpuset.mems`), which could be
|
|
||||||
// one of the formats below. Note that duplicates are actually allowed in the
|
|
||||||
// input string. It returns a `map[int]bool` with available elements from `val`
|
|
||||||
// set to `true`.
|
|
||||||
// Supported formats:
|
|
||||||
//
|
|
||||||
// 7
|
|
||||||
// 1-6
|
|
||||||
// 0,3-4,7,8-10
|
|
||||||
// 0-0,0,1-7
|
|
||||||
// 03,1-3 <- this is gonna get parsed as [1,2,3]
|
|
||||||
// 3,2,1
|
|
||||||
// 0-2,3,1
|
|
||||||
//
|
|
||||||
// Deprecated: ParseUintList was only used internally and will be removed in the next release.
|
|
||||||
func ParseUintList(val string) (map[int]bool, error) {
|
|
||||||
return parseUintList(val, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseUintList(val string, maximum int) (map[int]bool, error) {
|
|
||||||
if val == "" {
|
|
||||||
return map[int]bool{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
availableInts := make(map[int]bool)
|
|
||||||
split := strings.Split(val, ",")
|
|
||||||
errInvalidFormat := fmt.Errorf("invalid format: %s", val)
|
|
||||||
|
|
||||||
for _, r := range split {
|
|
||||||
if !strings.Contains(r, "-") {
|
|
||||||
v, err := strconv.Atoi(r)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errInvalidFormat
|
|
||||||
}
|
|
||||||
if maximum != 0 && v > maximum {
|
|
||||||
return nil, fmt.Errorf("value of out range, maximum is %d", maximum)
|
|
||||||
}
|
|
||||||
availableInts[v] = true
|
|
||||||
} else {
|
|
||||||
minS, maxS, _ := strings.Cut(r, "-")
|
|
||||||
minAvailable, err := strconv.Atoi(minS)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errInvalidFormat
|
|
||||||
}
|
|
||||||
maxAvailable, err := strconv.Atoi(maxS)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errInvalidFormat
|
|
||||||
}
|
|
||||||
if maxAvailable < minAvailable {
|
|
||||||
return nil, errInvalidFormat
|
|
||||||
}
|
|
||||||
if maximum != 0 && maxAvailable > maximum {
|
|
||||||
return nil, fmt.Errorf("value of out range, maximum is %d", maximum)
|
|
||||||
}
|
|
||||||
for i := minAvailable; i <= maxAvailable; i++ {
|
|
||||||
availableInts[i] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return availableInts, nil
|
|
||||||
}
|
|
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
@ -506,7 +506,6 @@ github.com/docker/docker/pkg/ioutils
|
|||||||
github.com/docker/docker/pkg/jsonmessage
|
github.com/docker/docker/pkg/jsonmessage
|
||||||
github.com/docker/docker/pkg/meminfo
|
github.com/docker/docker/pkg/meminfo
|
||||||
github.com/docker/docker/pkg/namesgenerator
|
github.com/docker/docker/pkg/namesgenerator
|
||||||
github.com/docker/docker/pkg/parsers
|
|
||||||
github.com/docker/docker/pkg/progress
|
github.com/docker/docker/pkg/progress
|
||||||
github.com/docker/docker/pkg/stdcopy
|
github.com/docker/docker/pkg/stdcopy
|
||||||
github.com/docker/docker/pkg/streamformatter
|
github.com/docker/docker/pkg/streamformatter
|
||||||
|
Reference in New Issue
Block a user