Skip to content

Commit 01688e7

Browse files
committed
Deprecate Legacy structs and use port.String()
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
1 parent c10f685 commit 01688e7

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

pkg/api/handlers/compat/containers.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ func WaitContainer(w http.ResponseWriter, r *http.Request) {
283283
utils.WaitContainerDocker(w, r)
284284
}
285285

286+
//nolint:staticcheck
286287
func convertSecondaryIPPrefixLen(input *define.InspectNetworkSettings, output *handlers.LegacyNetworkSettings) {
287288
for index, ip := range input.SecondaryIPAddresses {
288289
output.SecondaryIPAddresses[index].PrefixLen = ip.PrefixLength
@@ -446,6 +447,7 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
446447
}, nil
447448
}
448449

450+
//nolint:staticcheck
449451
func LibpodToContainerJSON(l *libpod.Container, sz bool) (*handlers.LegacyImageInspect, error) {
450452
imageID, imageName := l.Image()
451453
inspect, err := l.Inspect(sz)
@@ -544,7 +546,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*handlers.LegacyImageI
544546
Data: inspect.GraphDriver.Data,
545547
}
546548

547-
cb := handlers.LegacyImageInspect{
549+
cb := handlers.LegacyImageInspect{ //nolint:staticcheck
548550
InspectResponse: container.InspectResponse{
549551
ID: l.ID(),
550552
Created: l.CreatedTime().UTC().Format(time.RFC3339Nano), // Docker uses UTC
@@ -658,7 +660,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*handlers.LegacyImageI
658660
return nil, err
659661
}
660662

661-
networkSettings := handlers.LegacyNetworkSettings{}
663+
networkSettings := handlers.LegacyNetworkSettings{} //nolint:staticcheck
662664
if err := json.Unmarshal(n, &networkSettings); err != nil {
663665
return nil, err
664666
}

pkg/api/handlers/compat/containers_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C
219219
// expose ports
220220
expose := make([]string, 0, len(cc.Config.ExposedPorts))
221221
for p := range cc.Config.ExposedPorts {
222-
expose = append(expose, fmt.Sprintf("%d/%s", p.Num(), p.Proto()))
222+
expose = append(expose, p.String())
223223
}
224224

225225
// mounts type=tmpfs/bind,source=...,target=...=,opt=val

pkg/api/handlers/compat/images_push.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
152152

153153
loop: // break out of for/select infinite loop
154154
for {
155-
var report handlers.LegacyJSONMessage
155+
var report handlers.LegacyJSONMessage //nolint:staticcheck
156156

157157
select {
158158
case e := <-options.Progress:

pkg/api/handlers/compat/system.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func GetDiskUsage(w http.ResponseWriter, r *http.Request) {
105105
}
106106
}
107107

108-
utils.WriteResponse(w, http.StatusOK, handlers.LegacyDiskUsage{
108+
utils.WriteResponse(w, http.StatusOK, handlers.LegacyDiskUsage{ //nolint:staticcheck
109109
LayersSize: df.ImagesSize,
110110
Images: legacy,
111111
Containers: ctnrs,

pkg/api/handlers/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ type LegacyImageSummary struct {
127127
VirtualSize int64 `json:"VirtualSize,omitempty"`
128128
}
129129

130+
// Deprecated: kept to maintain backwards compatibility with API < v1.52
130131
type LegacyDiskUsage struct {
131132
// Deprecated: kept to maintain backwards compatibility with API < v1.52, use [ImagesDiskUsage.TotalSize] instead.
132133
LayersSize int64 `json:"LayersSize"`
@@ -144,6 +145,7 @@ type LegacyDiskUsage struct {
144145
BuildCache []build.CacheRecord `json:"BuildCache,omitzero"`
145146
}
146147

148+
// Deprecated: kept to maintain backwards compatibility with API < v1.52
147149
type LegacyJSONMessage struct {
148150
jsonstream.Message
149151
// ErrorMessage contains errors encountered during the operation.
@@ -153,17 +155,20 @@ type LegacyJSONMessage struct {
153155
ProgressMessage string `json:"progress,omitempty"`
154156
}
155157

158+
// Deprecated: kept to maintain backwards compatibility with API < v1.52
156159
type LegacyAddress struct {
157160
Addr string
158161
PrefixLen int
159162
}
160163

164+
// Deprecated: kept to maintain backwards compatibility with API < v1.52
161165
type LegacyNetworkSettings struct {
162166
dockerContainer.NetworkSettings
163167
SecondaryIPAddresses []LegacyAddress `json:"SecondaryIPAddresses,omitempty"`
164168
SecondaryIPv6Addresses []LegacyAddress `json:"SecondaryIPv6Addresses,omitempty"`
165169
}
166170

171+
// Deprecated: kept to maintain backwards compatibility with API < v1.52
167172
type LegacyImageInspect struct {
168173
dockerContainer.InspectResponse
169174
NetworkSettings *LegacyNetworkSettings

pkg/api/handlers/utils/images.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func CompatPull(r *http.Request, w http.ResponseWriter, runtime *libpod.Runtime,
222222

223223
loop: // break out of for/select infinite loop
224224
for {
225-
report := handlers.LegacyJSONMessage{}
225+
report := handlers.LegacyJSONMessage{} //nolint:staticcheck
226226
report.Progress = &jsonstream.Progress{}
227227
select {
228228
case e := <-progress:

0 commit comments

Comments
 (0)