mirror of
https://github.com/containerd/containerd.git
synced 2026-11-06 05:17:02 +00:00
core: modernize: mapsloop
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
modernize -mapsloop -fix ./...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
7 files changed
+15
-24
No files matched your search
@@ -22,6 +22,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"maps"
|
||||
"path"
|
||||
"slices"
|
||||
"sort"
|
||||
@@ -195,9 +196,7 @@ func WithSkipMissing(store content.InfoReaderProvider) ExportOpt {
|
||||
|
||||
func addNameAnnotation(name string, base map[string]string) map[string]string {
|
||||
annotations := map[string]string{}
|
||||
for k, v := range base {
|
||||
annotations[k] = v
|
||||
}
|
||||
maps.Copy(annotations, base)
|
||||
|
||||
annotations[images.AnnotationImageName] = name
|
||||
annotations[ocispec.AnnotationRefName] = ociReferenceName(name)
|
||||
|
||||
@@ -18,6 +18,7 @@ package leases
|
||||
|
||||
import (
|
||||
"context"
|
||||
"maps"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -84,9 +85,7 @@ func WithLabels(labels map[string]string) Opt {
|
||||
if l.Labels == nil {
|
||||
l.Labels = map[string]string{}
|
||||
}
|
||||
for k, v := range labels {
|
||||
l.Labels[k] = v
|
||||
}
|
||||
maps.Copy(l.Labels, labels)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package leases
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -80,9 +81,7 @@ func newLease(labels map[string]string) *Lease {
|
||||
lease := &Lease{}
|
||||
if labels != nil {
|
||||
lease.Labels = map[string]string{}
|
||||
for k, v := range labels {
|
||||
lease.Labels[k] = v
|
||||
}
|
||||
maps.Copy(lease.Labels, labels)
|
||||
}
|
||||
return lease
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package metadata
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -250,9 +251,7 @@ func overlayInfo(info, overlay snapshots.Info) snapshots.Info {
|
||||
if info.Labels == nil {
|
||||
info.Labels = overlay.Labels
|
||||
} else {
|
||||
for k, v := range overlay.Labels {
|
||||
info.Labels[k] = v
|
||||
}
|
||||
maps.Copy(info.Labels, overlay.Labels)
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package metadata
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -291,9 +292,7 @@ func (s *tmpSnapshotter) Update(ctx context.Context, info snapshots.Info, fieldp
|
||||
return snapshots.Info{}, errdefs.ErrNotFound
|
||||
}
|
||||
|
||||
for k, v := range info.Labels {
|
||||
i.Labels[k] = v
|
||||
}
|
||||
maps.Copy(i.Labels, info.Labels)
|
||||
|
||||
s.snapshots[i.Name] = i
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package snapshots
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"maps"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -371,9 +372,7 @@ func WithLabels(labels map[string]string) Opt {
|
||||
info.Labels = make(map[string]string)
|
||||
}
|
||||
|
||||
for k, v := range labels {
|
||||
info.Labels[k] = v
|
||||
}
|
||||
maps.Copy(info.Labels, labels)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
|
||||
@@ -159,11 +160,7 @@ func (ts *localTransferService) importStream(ctx context.Context, i transfer.Ima
|
||||
|
||||
func mergeMap(m1, m2 map[string]string) map[string]string {
|
||||
merged := make(map[string]string, len(m1)+len(m2))
|
||||
for k, v := range m1 {
|
||||
merged[k] = v
|
||||
}
|
||||
for k, v := range m2 {
|
||||
merged[k] = v
|
||||
}
|
||||
maps.Copy(merged, m1)
|
||||
maps.Copy(merged, m2)
|
||||
return merged
|
||||
}
|
||||
Reference in new issue
Block a user