Deprecate Legacy structs and use port.String()

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza
2026-03-05 07:53:50 +01:00
parent c10f685b43
commit 01688e7621
6 changed files with 13 additions and 6 deletions

View File

@@ -283,6 +283,7 @@ func WaitContainer(w http.ResponseWriter, r *http.Request) {
utils.WaitContainerDocker(w, r)
}
//nolint:staticcheck
func convertSecondaryIPPrefixLen(input *define.InspectNetworkSettings, output *handlers.LegacyNetworkSettings) {
for index, ip := range input.SecondaryIPAddresses {
output.SecondaryIPAddresses[index].PrefixLen = ip.PrefixLength
@@ -446,6 +447,7 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
}, nil
}
//nolint:staticcheck
func LibpodToContainerJSON(l *libpod.Container, sz bool) (*handlers.LegacyImageInspect, error) {
imageID, imageName := l.Image()
inspect, err := l.Inspect(sz)
@@ -544,7 +546,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*handlers.LegacyImageI
Data: inspect.GraphDriver.Data,
}
cb := handlers.LegacyImageInspect{
cb := handlers.LegacyImageInspect{ //nolint:staticcheck
InspectResponse: container.InspectResponse{
ID: l.ID(),
Created: l.CreatedTime().UTC().Format(time.RFC3339Nano), // Docker uses UTC
@@ -658,7 +660,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*handlers.LegacyImageI
return nil, err
}
networkSettings := handlers.LegacyNetworkSettings{}
networkSettings := handlers.LegacyNetworkSettings{} //nolint:staticcheck
if err := json.Unmarshal(n, &networkSettings); err != nil {
return nil, err
}

View File

@@ -219,7 +219,7 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C
// expose ports
expose := make([]string, 0, len(cc.Config.ExposedPorts))
for p := range cc.Config.ExposedPorts {
expose = append(expose, fmt.Sprintf("%d/%s", p.Num(), p.Proto()))
expose = append(expose, p.String())
}
// mounts type=tmpfs/bind,source=...,target=...=,opt=val

View File

@@ -152,7 +152,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
loop: // break out of for/select infinite loop
for {
var report handlers.LegacyJSONMessage
var report handlers.LegacyJSONMessage //nolint:staticcheck
select {
case e := <-options.Progress:

View File

@@ -105,7 +105,7 @@ func GetDiskUsage(w http.ResponseWriter, r *http.Request) {
}
}
utils.WriteResponse(w, http.StatusOK, handlers.LegacyDiskUsage{
utils.WriteResponse(w, http.StatusOK, handlers.LegacyDiskUsage{ //nolint:staticcheck
LayersSize: df.ImagesSize,
Images: legacy,
Containers: ctnrs,

View File

@@ -127,6 +127,7 @@ type LegacyImageSummary struct {
VirtualSize int64 `json:"VirtualSize,omitempty"`
}
// Deprecated: kept to maintain backwards compatibility with API < v1.52
type LegacyDiskUsage struct {
// Deprecated: kept to maintain backwards compatibility with API < v1.52, use [ImagesDiskUsage.TotalSize] instead.
LayersSize int64 `json:"LayersSize"`
@@ -144,6 +145,7 @@ type LegacyDiskUsage struct {
BuildCache []build.CacheRecord `json:"BuildCache,omitzero"`
}
// Deprecated: kept to maintain backwards compatibility with API < v1.52
type LegacyJSONMessage struct {
jsonstream.Message
// ErrorMessage contains errors encountered during the operation.
@@ -153,17 +155,20 @@ type LegacyJSONMessage struct {
ProgressMessage string `json:"progress,omitempty"`
}
// Deprecated: kept to maintain backwards compatibility with API < v1.52
type LegacyAddress struct {
Addr string
PrefixLen int
}
// Deprecated: kept to maintain backwards compatibility with API < v1.52
type LegacyNetworkSettings struct {
dockerContainer.NetworkSettings
SecondaryIPAddresses []LegacyAddress `json:"SecondaryIPAddresses,omitempty"`
SecondaryIPv6Addresses []LegacyAddress `json:"SecondaryIPv6Addresses,omitempty"`
}
// Deprecated: kept to maintain backwards compatibility with API < v1.52
type LegacyImageInspect struct {
dockerContainer.InspectResponse
NetworkSettings *LegacyNetworkSettings

View File

@@ -222,7 +222,7 @@ func CompatPull(r *http.Request, w http.ResponseWriter, runtime *libpod.Runtime,
loop: // break out of for/select infinite loop
for {
report := handlers.LegacyJSONMessage{}
report := handlers.LegacyJSONMessage{} //nolint:staticcheck
report.Progress = &jsonstream.Progress{}
select {
case e := <-progress: