diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go index 91c3328977..78809068e9 100644 --- a/cmd/podman/pods/create.go +++ b/cmd/podman/pods/create.go @@ -21,7 +21,7 @@ import ( "github.com/containers/podman/v5/pkg/specgen" "github.com/containers/podman/v5/pkg/specgenutil" "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/spf13/cobra" ) diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go index 96e4a23440..0a26735bd1 100644 --- a/pkg/api/handlers/compat/containers.go +++ b/pkg/api/handlers/compat/containers.go @@ -24,10 +24,10 @@ import ( "github.com/containers/podman/v5/pkg/ps" "github.com/containers/podman/v5/pkg/signal" "github.com/containers/podman/v5/pkg/util" - "github.com/docker/docker/api/types" dockerBackend "github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/storage" "github.com/docker/go-connections/nat" "github.com/docker/go-units" 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 } - ports := make([]types.Port, len(portMappings)) + ports := make([]container.Port, len(portMappings)) for idx, portMapping := range portMappings { - ports[idx] = types.Port{ + ports[idx] = container.Port{ IP: portMapping.HostIP, PrivatePort: portMapping.ContainerPort, PublicPort: portMapping.HostPort, @@ -365,7 +365,7 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error if err != nil { return nil, err } - networkSettings := types.SummaryNetworkSettings{} + networkSettings := container.NetworkSettingsSummary{} if err := json.Unmarshal(n, &networkSettings); err != nil { return nil, err } @@ -374,13 +374,13 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error if err != nil { return nil, err } - mounts := []types.MountPoint{} + mounts := []container.MountPoint{} if err := json.Unmarshal(m, &mounts); err != nil { return nil, err } return &handlers.Container{ - Container: types.Container{ + Container: container.Summary{ ID: l.ID(), Names: []string{fmt.Sprintf("/%s", l.Name())}, Image: imageName, @@ -408,7 +408,7 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error }, nil } -func convertSecondaryIPPrefixLen(input *define.InspectNetworkSettings, output *types.NetworkSettings) { +func convertSecondaryIPPrefixLen(input *define.InspectNetworkSettings, output *container.NetworkSettings) { for index, ip := range input.SecondaryIPAddresses { 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() inspect, err := l.Inspect(sz) if err != nil { @@ -432,7 +432,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, if err != nil { return nil, err } - state := types.ContainerState{} + state := container.State{} if err := json.Unmarshal(i, &state); err != nil { return nil, err } @@ -448,14 +448,14 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, } if l.HasHealthCheck() && state.Status != "created" { - state.Health = &types.Health{} + state.Health = &container.Health{} if inspect.State.Health != nil { state.Health.Status = inspect.State.Health.Status state.Health.FailingStreak = inspect.State.Health.FailingStreak log := inspect.State.Health.Log for _, item := range log { - res := &types.HealthcheckResult{} + res := &container.HealthcheckResult{} s, err := time.Parse(time.RFC3339Nano, item.Start) if err != nil { return nil, err @@ -490,16 +490,13 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, if hc.LogConfig.Type == define.KubernetesLogging { hc.LogConfig.Type = define.JSONLogging } - g, err := json.Marshal(inspect.GraphDriver) - if err != nil { - return nil, err - } - graphDriver := types.GraphDriverData{} - if err := json.Unmarshal(g, &graphDriver); err != nil { - return nil, err + + graphDriver := storage.DriverData{ + Name: inspect.GraphDriver.Name, + Data: inspect.GraphDriver.Data, } - cb := types.ContainerJSONBase{ + cb := container.ContainerJSONBase{ ID: l.ID(), Created: l.CreatedTime().UTC().Format(time.RFC3339Nano), // Docker uses UTC Path: inspect.Path, @@ -587,7 +584,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, if err != nil { return nil, err } - mounts := []types.MountPoint{} + mounts := []container.MountPoint{} if err := json.Unmarshal(m, &mounts); err != nil { return nil, err } @@ -606,7 +603,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, return nil, err } - networkSettings := types.NetworkSettings{} + networkSettings := container.NetworkSettings{} if err := json.Unmarshal(n, &networkSettings); err != nil { return nil, err } @@ -618,7 +615,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, networkSettings.Networks = map[string]*network.EndpointSettings{} } - c := types.ContainerJSON{ + c := container.InspectResponse{ ContainerJSONBase: &cb, Mounts: mounts, Config: &config, @@ -790,6 +787,6 @@ func UpdateContainer(w http.ResponseWriter, r *http.Request) { return } - responseStruct := container.ContainerUpdateOKBody{} + responseStruct := container.UpdateResponse{} utils.WriteResponse(w, http.StatusOK, responseStruct) } diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index a7e2701cb1..03be953ce7 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -25,9 +25,9 @@ import ( "github.com/containers/podman/v5/pkg/domain/infra/abi" "github.com/containers/podman/v5/pkg/util" "github.com/containers/storage" - docker "github.com/docker/docker/api/types" dockerContainer "github.com/docker/docker/api/types/container" dockerImage "github.com/docker/docker/api/types/image" + dockerStorage "github.com/docker/docker/api/types/storage" "github.com/docker/go-connections/nat" "github.com/opencontainers/go-digest" "github.com/sirupsen/logrus" @@ -371,7 +371,7 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image) (*handlers. StopSignal: info.Config.StopSignal, } - rootfs := docker.RootFS{} + rootfs := dockerImage.RootFS{} if info.RootFS != nil { rootfs.Type = info.RootFS.Type 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, 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.Volumes = info.Config.Volumes - dockerImageInspect := docker.ImageInspect{ + dockerImageInspect := dockerImage.InspectResponse{ Architecture: info.Architecture, Author: info.Author, Comment: info.Comment, @@ -410,7 +410,7 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image) (*handlers. Variant: "", 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 diff --git a/pkg/api/handlers/compat/images_push.go b/pkg/api/handlers/compat/images_push.go index 319dc98a27..bf0ab6389d 100644 --- a/pkg/api/handlers/compat/images_push.go +++ b/pkg/api/handlers/compat/images_push.go @@ -165,6 +165,7 @@ loop: // break out of for/select infinite loop Current: int64(e.Offset), Total: e.Artifact.Size, } + //nolint:staticcheck // Deprecated field, but because consumers might still read it keep it. report.ProgressMessage = report.Progress.String() case types.ProgressEventSkipped: report.Status = "Layer already exists" @@ -190,6 +191,7 @@ loop: // break out of for/select infinite loop report.Error = &jsonmessage.JSONError{ Message: msg, } + //nolint:staticcheck // Deprecated field, but because consumers might still read it keep it. report.ErrorMessage = msg if err := enc.Encode(report); err != nil { logrus.Warnf("Failed to json encode error %q", err.Error()) diff --git a/pkg/api/handlers/compat/system.go b/pkg/api/handlers/compat/system.go index eeaf70c7de..a8b42e5736 100644 --- a/pkg/api/handlers/compat/system.go +++ b/pkg/api/handlers/compat/system.go @@ -13,6 +13,7 @@ import ( "github.com/containers/podman/v5/pkg/domain/entities" "github.com/containers/podman/v5/pkg/domain/infra/abi" docker "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" dockerImage "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/volume" ) @@ -44,9 +45,9 @@ func GetDiskUsage(w http.ResponseWriter, r *http.Request) { imgs[i] = &t } - ctnrs := make([]*docker.Container, len(df.Containers)) + ctnrs := make([]*container.Summary, len(df.Containers)) for i, o := range df.Containers { - t := docker.Container{ + t := container.Summary{ ID: o.ContainerID, Names: []string{o.Names}, Image: o.Image, diff --git a/pkg/api/handlers/swagger/responses.go b/pkg/api/handlers/swagger/responses.go index 18b11efdf2..6c9b40e740 100644 --- a/pkg/api/handlers/swagger/responses.go +++ b/pkg/api/handlers/swagger/responses.go @@ -11,7 +11,7 @@ import ( "github.com/containers/podman/v5/pkg/domain/entities" "github.com/containers/podman/v5/pkg/domain/entities/reports" "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" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" @@ -125,7 +125,7 @@ type inspectImageResponseLibpod struct { // swagger:response type containerInspectResponse struct { // in:body - Body dockerAPI.ContainerJSON + Body container.InspectResponse } // List processes in container diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index 26ba0374d2..278fa2316a 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -19,7 +19,7 @@ type AuthConfig struct { } type ImageInspect struct { - docker.ImageInspect + dockerImage.InspectResponse // Container is for backwards compat but is basically unused Container string } diff --git a/pkg/api/handlers/utils/images.go b/pkg/api/handlers/utils/images.go index a53fa59805..00e7eac669 100644 --- a/pkg/api/handlers/utils/images.go +++ b/pkg/api/handlers/utils/images.go @@ -169,6 +169,7 @@ loop: // break out of for/select infinite loop report.Status = "Downloading" report.Progress.Current = int64(e.Offset) report.Progress.Total = e.Artifact.Size + //nolint:staticcheck // Deprecated field, but because consumers might still read it keep it. report.ProgressMessage = report.Progress.String() case types.ProgressEventSkipped: report.Status = "Already exists" @@ -193,6 +194,7 @@ loop: // break out of for/select infinite loop report.Error = &jsonmessage.JSONError{ Message: msg, } + //nolint:staticcheck // Deprecated field, but because consumers might still read it keep it. report.ErrorMessage = msg } else { pulledImages := pullRes.images @@ -205,6 +207,7 @@ loop: // break out of for/select infinite loop report.Error = &jsonmessage.JSONError{ Message: msg, } + //nolint:staticcheck // Deprecated field, but because consumers might still read it keep it. report.ErrorMessage = msg writeStatusCode(http.StatusInternalServerError) } diff --git a/pkg/bindings/containers/commit.go b/pkg/bindings/containers/commit.go index 76b22d1f06..2d4489d90b 100644 --- a/pkg/bindings/containers/commit.go +++ b/pkg/bindings/containers/commit.go @@ -11,26 +11,26 @@ import ( "github.com/containers/podman/v5/pkg/bindings" "github.com/containers/podman/v5/pkg/bindings/images" + "github.com/containers/podman/v5/pkg/domain/entities/types" "github.com/containers/storage/pkg/regexp" - dockerAPI "github.com/docker/docker/api/types" ) var iidRegex = regexp.Delayed(`^[0-9a-f]{12}`) // 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. -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 { options = new(CommitOptions) } - id := dockerAPI.IDResponse{} + id := types.IDResponse{} conn, err := bindings.GetClient(ctx) if err != nil { return id, err } params, err := options.ToParams() if err != nil { - return dockerAPI.IDResponse{}, err + return types.IDResponse{}, err } params.Set("container", nameOrID) var requestBody io.Reader diff --git a/pkg/bindings/containers/exec.go b/pkg/bindings/containers/exec.go index e471a58dd5..a8419e3e29 100644 --- a/pkg/bindings/containers/exec.go +++ b/pkg/bindings/containers/exec.go @@ -11,7 +11,7 @@ import ( "github.com/containers/podman/v5/libpod/define" "github.com/containers/podman/v5/pkg/api/handlers" "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" "github.com/sirupsen/logrus" ) @@ -43,7 +43,7 @@ func ExecCreate(ctx context.Context, nameOrID string, config *handlers.ExecCreat } defer resp.Body.Close() - respStruct := new(dockerAPI.IDResponse) + respStruct := new(types.IDResponse) if err := resp.Process(respStruct); err != nil { return "", err } diff --git a/pkg/bindings/manifests/manifests.go b/pkg/bindings/manifests/manifests.go index 9ac41a85eb..630a164df8 100644 --- a/pkg/bindings/manifests/manifests.go +++ b/pkg/bindings/manifests/manifests.go @@ -24,7 +24,6 @@ import ( "github.com/containers/podman/v5/pkg/bindings/images" entitiesTypes "github.com/containers/podman/v5/pkg/domain/entities/types" "github.com/containers/podman/v5/pkg/errorhandling" - dockerAPI "github.com/docker/docker/api/types" 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 // is returned as a string. func Create(ctx context.Context, name string, images []string, options *CreateOptions) (string, error) { - var idr dockerAPI.IDResponse + var idr entitiesTypes.IDResponse if options == nil { options = new(CreateOptions) } diff --git a/pkg/domain/entities/types.go b/pkg/domain/entities/types.go index 89c921ebfe..256ad15eb8 100644 --- a/pkg/domain/entities/types.go +++ b/pkg/domain/entities/types.go @@ -9,7 +9,6 @@ import ( entitiesTypes "github.com/containers/podman/v5/pkg/domain/entities/types" "github.com/containers/podman/v5/pkg/specgen" "github.com/containers/storage/pkg/archive" - dockerAPI "github.com/docker/docker/api/types" ) type Container struct { @@ -117,5 +116,4 @@ type IDOrNameResponse struct { IDOrName string } -// swagger:model -type IDResponse dockerAPI.IDResponse +type IDResponse = entitiesTypes.IDResponse diff --git a/pkg/domain/entities/types/types.go b/pkg/domain/entities/types/types.go index 6530402f30..ccb60e48e3 100644 --- a/pkg/domain/entities/types/types.go +++ b/pkg/domain/entities/types/types.go @@ -77,3 +77,11 @@ type BuildReport struct { // Format to save the image in SaveFormat string } + +// swagger:model +type IDResponse struct { + + // The id of the newly created object. + // Required: true + ID string `json:"Id"` +} diff --git a/vendor/github.com/docker/docker/pkg/parsers/parsers.go b/vendor/github.com/docker/docker/pkg/parsers/parsers.go deleted file mode 100644 index af2de8e95a..0000000000 --- a/vendor/github.com/docker/docker/pkg/parsers/parsers.go +++ /dev/null @@ -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 -} diff --git a/vendor/modules.txt b/vendor/modules.txt index c777a9d00c..e0a8116f39 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -506,7 +506,6 @@ github.com/docker/docker/pkg/ioutils github.com/docker/docker/pkg/jsonmessage github.com/docker/docker/pkg/meminfo github.com/docker/docker/pkg/namesgenerator -github.com/docker/docker/pkg/parsers github.com/docker/docker/pkg/progress github.com/docker/docker/pkg/stdcopy github.com/docker/docker/pkg/streamformatter