Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
| ... | ... |
@@ -3,6 +3,7 @@ package dockerfile |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"io" |
| 6 |
+ "maps" |
|
| 6 | 7 |
"sort" |
| 7 | 8 |
) |
| 8 | 9 |
|
| ... | ... |
@@ -47,12 +48,8 @@ func NewBuildArgs(argsFromOptions map[string]*string) *BuildArgs {
|
| 47 | 47 |
// Clone returns a copy of the BuildArgs type |
| 48 | 48 |
func (b *BuildArgs) Clone() *BuildArgs {
|
| 49 | 49 |
result := NewBuildArgs(b.argsFromOptions) |
| 50 |
- for k, v := range b.allowedBuildArgs {
|
|
| 51 |
- result.allowedBuildArgs[k] = v |
|
| 52 |
- } |
|
| 53 |
- for k, v := range b.allowedMetaArgs {
|
|
| 54 |
- result.allowedMetaArgs[k] = v |
|
| 55 |
- } |
|
| 50 |
+ maps.Copy(result.allowedBuildArgs, b.allowedBuildArgs) |
|
| 51 |
+ maps.Copy(result.allowedMetaArgs, b.allowedMetaArgs) |
|
| 56 | 52 |
for k := range b.referencedArgs {
|
| 57 | 53 |
result.referencedArgs[k] = struct{}{}
|
| 58 | 54 |
} |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"encoding/json" |
| 6 | 6 |
"fmt" |
| 7 |
+ "maps" |
|
| 7 | 8 |
"math" |
| 8 | 9 |
"net" |
| 9 | 10 |
"net/netip" |
| ... | ... |
@@ -261,15 +262,11 @@ func (c *containerConfig) labels() map[string]string {
|
| 261 | 261 |
) |
| 262 | 262 |
|
| 263 | 263 |
// base labels are those defined in the spec. |
| 264 |
- for k, v := range c.spec().Labels {
|
|
| 265 |
- labels[k] = v |
|
| 266 |
- } |
|
| 264 |
+ maps.Copy(labels, c.spec().Labels) |
|
| 267 | 265 |
|
| 268 | 266 |
// we then apply the overrides from the task, which may be set via the |
| 269 | 267 |
// orchestrator. |
| 270 |
- for k, v := range c.task.Annotations.Labels {
|
|
| 271 |
- labels[k] = v |
|
| 272 |
- } |
|
| 268 |
+ maps.Copy(labels, c.task.Annotations.Labels) |
|
| 273 | 269 |
|
| 274 | 270 |
// finally, we apply the system labels, which override all labels. |
| 275 | 271 |
for k, v := range system {
|
| ... | ... |
@@ -367,9 +364,7 @@ func convertMount(m api.Mount) enginemount.Mount {
|
| 367 | 367 |
} |
| 368 | 368 |
if m.VolumeOptions.Labels != nil {
|
| 369 | 369 |
mount.VolumeOptions.Labels = make(map[string]string, len(m.VolumeOptions.Labels)) |
| 370 |
- for k, v := range m.VolumeOptions.Labels {
|
|
| 371 |
- mount.VolumeOptions.Labels[k] = v |
|
| 372 |
- } |
|
| 370 |
+ maps.Copy(mount.VolumeOptions.Labels, m.VolumeOptions.Labels) |
|
| 373 | 371 |
} |
| 374 | 372 |
if m.VolumeOptions.DriverConfig != nil {
|
| 375 | 373 |
mount.VolumeOptions.DriverConfig = &enginemount.Driver{
|
| ... | ... |
@@ -377,9 +372,7 @@ func convertMount(m api.Mount) enginemount.Mount {
|
| 377 | 377 |
} |
| 378 | 378 |
if m.VolumeOptions.DriverConfig.Options != nil {
|
| 379 | 379 |
mount.VolumeOptions.DriverConfig.Options = make(map[string]string, len(m.VolumeOptions.DriverConfig.Options)) |
| 380 |
- for k, v := range m.VolumeOptions.DriverConfig.Options {
|
|
| 381 |
- mount.VolumeOptions.DriverConfig.Options[k] = v |
|
| 382 |
- } |
|
| 380 |
+ maps.Copy(mount.VolumeOptions.DriverConfig.Options, m.VolumeOptions.DriverConfig.Options) |
|
| 383 | 381 |
} |
| 384 | 382 |
} |
| 385 | 383 |
} |
| ... | ... |
@@ -3,6 +3,7 @@ package daemon |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"fmt" |
| 6 |
+ "maps" |
|
| 6 | 7 |
"runtime" |
| 7 | 8 |
"strings" |
| 8 | 9 |
"time" |
| ... | ... |
@@ -109,9 +110,7 @@ func merge(userConf, imageConf *containertypes.Config) error {
|
| 109 | 109 |
if len(userConf.Volumes) == 0 {
|
| 110 | 110 |
userConf.Volumes = imageConf.Volumes |
| 111 | 111 |
} else {
|
| 112 |
- for k, v := range imageConf.Volumes {
|
|
| 113 |
- userConf.Volumes[k] = v |
|
| 114 |
- } |
|
| 112 |
+ maps.Copy(userConf.Volumes, imageConf.Volumes) |
|
| 115 | 113 |
} |
| 116 | 114 |
|
| 117 | 115 |
if userConf.StopSignal == "" {
|
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"encoding/json" |
| 6 | 6 |
stderrors "errors" |
| 7 | 7 |
"fmt" |
| 8 |
+ "maps" |
|
| 8 | 9 |
"net" |
| 9 | 10 |
"net/netip" |
| 10 | 11 |
"net/url" |
| ... | ... |
@@ -587,9 +588,7 @@ func configValuesSet(config map[string]any) map[string]any {
|
| 587 | 587 |
flatten := make(map[string]any) |
| 588 | 588 |
for k, v := range config {
|
| 589 | 589 |
if m, isMap := v.(map[string]any); isMap && !flatOptions[k] {
|
| 590 |
- for km, vm := range m {
|
|
| 591 |
- flatten[km] = vm |
|
| 592 |
- } |
|
| 590 |
+ maps.Copy(flatten, m) |
|
| 593 | 591 |
continue |
| 594 | 592 |
} |
| 595 | 593 |
|
| ... | ... |
@@ -2,6 +2,7 @@ package container |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 |
+ "maps" |
|
| 5 | 6 |
"runtime" |
| 6 | 7 |
"sync" |
| 7 | 8 |
|
| ... | ... |
@@ -91,9 +92,7 @@ func NewExecStore() *ExecStore {
|
| 91 | 91 |
func (e *ExecStore) Commands() map[string]*ExecConfig {
|
| 92 | 92 |
e.mu.RLock() |
| 93 | 93 |
byID := make(map[string]*ExecConfig, len(e.byID)) |
| 94 |
- for id, config := range e.byID {
|
|
| 95 |
- byID[id] = config |
|
| 96 |
- } |
|
| 94 |
+ maps.Copy(byID, e.byID) |
|
| 97 | 95 |
e.mu.RUnlock() |
| 98 | 96 |
return byID |
| 99 | 97 |
} |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"errors" |
| 6 | 6 |
"fmt" |
| 7 |
+ "maps" |
|
| 7 | 8 |
"net/netip" |
| 8 | 9 |
"os" |
| 9 | 10 |
"runtime" |
| ... | ... |
@@ -413,9 +414,7 @@ func (daemon *Daemon) allocateNetwork(ctx context.Context, cfg *config.Config, c |
| 413 | 413 |
|
| 414 | 414 |
// An intermediate map is necessary because "connectToNetwork" modifies "container.NetworkSettings.Networks" |
| 415 | 415 |
networks := make(map[string]*network.EndpointSettings) |
| 416 |
- for n, epConf := range ctr.NetworkSettings.Networks {
|
|
| 417 |
- networks[n] = epConf |
|
| 418 |
- } |
|
| 416 |
+ maps.Copy(networks, ctr.NetworkSettings.Networks) |
|
| 419 | 417 |
for netName, epConf := range networks {
|
| 420 | 418 |
cleanOperationalData(epConf) |
| 421 | 419 |
if err := daemon.connectToNetwork(ctx, cfg, ctr, netName, epConf); err != nil {
|
| ... | ... |
@@ -2,6 +2,7 @@ package containerd |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 |
+ "maps" |
|
| 5 | 6 |
|
| 6 | 7 |
c8dimages "github.com/containerd/containerd/v2/core/images" |
| 7 | 8 |
"github.com/moby/moby/api/types/events" |
| ... | ... |
@@ -45,7 +46,5 @@ func copyAttributes(attributes, labels map[string]string) {
|
| 45 | 45 |
if labels == nil {
|
| 46 | 46 |
return |
| 47 | 47 |
} |
| 48 |
- for k, v := range labels {
|
|
| 49 |
- attributes[k] = v |
|
| 50 |
- } |
|
| 48 |
+ maps.Copy(attributes, labels) |
|
| 51 | 49 |
} |
| ... | ... |
@@ -2,6 +2,7 @@ package daemon |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 |
+ "maps" |
|
| 5 | 6 |
"strconv" |
| 6 | 7 |
"strings" |
| 7 | 8 |
"time" |
| ... | ... |
@@ -94,9 +95,7 @@ func copyAttributes(attributes, labels map[string]string) {
|
| 94 | 94 |
if labels == nil {
|
| 95 | 95 |
return |
| 96 | 96 |
} |
| 97 |
- for k, v := range labels {
|
|
| 98 |
- attributes[k] = v |
|
| 99 |
- } |
|
| 97 |
+ maps.Copy(attributes, labels) |
|
| 100 | 98 |
} |
| 101 | 99 |
|
| 102 | 100 |
// ProcessClusterNotifications gets changes from store and add them to event list |
| ... | ... |
@@ -2,6 +2,7 @@ package images |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 |
+ "maps" |
|
| 5 | 6 |
|
| 6 | 7 |
"github.com/moby/moby/api/types/events" |
| 7 | 8 |
"github.com/moby/moby/v2/daemon/server/imagebackend" |
| ... | ... |
@@ -32,7 +33,5 @@ func copyAttributes(attributes, labels map[string]string) {
|
| 32 | 32 |
if labels == nil {
|
| 33 | 33 |
return |
| 34 | 34 |
} |
| 35 |
- for k, v := range labels {
|
|
| 36 |
- attributes[k] = v |
|
| 37 |
- } |
|
| 35 |
+ maps.Copy(attributes, labels) |
|
| 38 | 36 |
} |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"errors" |
| 6 | 6 |
"fmt" |
| 7 |
+ "maps" |
|
| 7 | 8 |
"runtime" |
| 8 | 9 |
"time" |
| 9 | 10 |
|
| ... | ... |
@@ -35,9 +36,7 @@ func (daemon *Daemon) ContainerInspect(ctx context.Context, name string, options |
| 35 | 35 |
|
| 36 | 36 |
// TODO(thaJeztah): do we need a deep copy here? Otherwise we could use maps.Clone (see https://github.com/moby/moby/commit/7917a36cc787ada58987320e67cc6d96858f3b55) |
| 37 | 37 |
ports := make(networktypes.PortMap, len(ctr.NetworkSettings.Ports)) |
| 38 |
- for k, pm := range ctr.NetworkSettings.Ports {
|
|
| 39 |
- ports[k] = pm |
|
| 40 |
- } |
|
| 38 |
+ maps.Copy(ports, ctr.NetworkSettings.Ports) |
|
| 41 | 39 |
|
| 42 | 40 |
apiNetworks := make(map[string]*networktypes.EndpointSettings) |
| 43 | 41 |
for nwName, epConf := range ctr.NetworkSettings.Networks {
|
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"io" |
| 7 |
+ "maps" |
|
| 7 | 8 |
"net/netip" |
| 8 | 9 |
"strconv" |
| 9 | 10 |
"strings" |
| ... | ... |
@@ -213,9 +214,7 @@ func (b *Builder) Prune(ctx context.Context, opts buildbackend.CachePruneOptions |
| 213 | 213 |
validFilters["until"] = true |
| 214 | 214 |
validFilters["label"] = true // TODO(tiborvass): handle label |
| 215 | 215 |
validFilters["label!"] = true // TODO(tiborvass): handle label! |
| 216 |
- for k, v := range cacheFields {
|
|
| 217 |
- validFilters[k] = v |
|
| 218 |
- } |
|
| 216 |
+ maps.Copy(validFilters, cacheFields) |
|
| 219 | 217 |
if err := opts.Filters.Validate(validFilters); err != nil {
|
| 220 | 218 |
return 0, nil, err |
| 221 | 219 |
} |
| ... | ... |
@@ -6,6 +6,7 @@ package filters |
| 6 | 6 |
|
| 7 | 7 |
import ( |
| 8 | 8 |
"encoding/json" |
| 9 |
+ "maps" |
|
| 9 | 10 |
"regexp" |
| 10 | 11 |
"strings" |
| 11 | 12 |
) |
| ... | ... |
@@ -280,9 +281,7 @@ func (args Args) Clone() (newArgs Args) {
|
| 280 | 280 |
var mm map[string]bool |
| 281 | 281 |
if m != nil {
|
| 282 | 282 |
mm = make(map[string]bool, len(m)) |
| 283 |
- for kk, v := range m {
|
|
| 284 |
- mm[kk] = v |
|
| 285 |
- } |
|
| 283 |
+ maps.Copy(mm, m) |
|
| 286 | 284 |
} |
| 287 | 285 |
newArgs.fields[k] = mm |
| 288 | 286 |
} |
| ... | ... |
@@ -3,6 +3,7 @@ package cnmallocator |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"fmt" |
| 6 |
+ "maps" |
|
| 6 | 7 |
"net" |
| 7 | 8 |
"net/netip" |
| 8 | 9 |
"slices" |
| ... | ... |
@@ -725,14 +726,10 @@ func (na *cnmNetworkAllocator) allocateDriverState(d *networkDriver, n *api.Netw |
| 725 | 725 |
// reconcile the driver specific options from the network spec |
| 726 | 726 |
// and from the operational state retrieved from the store |
| 727 | 727 |
if n.Spec.DriverConfig != nil {
|
| 728 |
- for k, v := range n.Spec.DriverConfig.Options {
|
|
| 729 |
- options[k] = v |
|
| 730 |
- } |
|
| 728 |
+ maps.Copy(options, n.Spec.DriverConfig.Options) |
|
| 731 | 729 |
} |
| 732 | 730 |
if n.DriverState != nil {
|
| 733 |
- for k, v := range n.DriverState.Options {
|
|
| 734 |
- options[k] = v |
|
| 735 |
- } |
|
| 731 |
+ maps.Copy(options, n.DriverState.Options) |
|
| 736 | 732 |
} |
| 737 | 733 |
|
| 738 | 734 |
// Construct IPAM data for driver consumption. |
| ... | ... |
@@ -1036,9 +1036,7 @@ func (ep *Endpoint) getEtcHostsAddrs() []netip.Addr {
|
| 1036 | 1036 |
// in a Dictionary of Key-Value pair |
| 1037 | 1037 |
func EndpointOptionGeneric(generic map[string]any) EndpointOption {
|
| 1038 | 1038 |
return func(ep *Endpoint) {
|
| 1039 |
- for k, v := range generic {
|
|
| 1040 |
- ep.generic[k] = v |
|
| 1041 |
- } |
|
| 1039 |
+ maps.Copy(ep.generic, generic) |
|
| 1042 | 1040 |
} |
| 1043 | 1041 |
} |
| 1044 | 1042 |
|
| ... | ... |
@@ -476,9 +476,7 @@ func (n *Network) applyConfigurationTo(to *Network) error {
|
| 476 | 476 |
} |
| 477 | 477 |
if len(n.generic) > 0 {
|
| 478 | 478 |
to.generic = options.Generic{}
|
| 479 |
- for k, v := range n.generic {
|
|
| 480 |
- to.generic[k] = v |
|
| 481 |
- } |
|
| 479 |
+ maps.Copy(to.generic, n.generic) |
|
| 482 | 480 |
} |
| 483 | 481 |
|
| 484 | 482 |
// Network drivers only see generic flags. So, make sure they match. |
| ... | ... |
@@ -525,15 +523,11 @@ func (n *Network) CopyTo(o datastore.KVObject) error {
|
| 525 | 525 |
if dstN.labels == nil {
|
| 526 | 526 |
dstN.labels = make(map[string]string, len(n.labels)) |
| 527 | 527 |
} |
| 528 |
- for k, v := range n.labels {
|
|
| 529 |
- dstN.labels[k] = v |
|
| 530 |
- } |
|
| 528 |
+ maps.Copy(dstN.labels, n.labels) |
|
| 531 | 529 |
|
| 532 | 530 |
if n.ipamOptions != nil {
|
| 533 | 531 |
dstN.ipamOptions = make(map[string]string, len(n.ipamOptions)) |
| 534 |
- for k, v := range n.ipamOptions {
|
|
| 535 |
- dstN.ipamOptions[k] = v |
|
| 536 |
- } |
|
| 532 |
+ maps.Copy(dstN.ipamOptions, n.ipamOptions) |
|
| 537 | 533 |
} |
| 538 | 534 |
|
| 539 | 535 |
for _, c := range n.ipamV4Config {
|
| ... | ... |
@@ -553,9 +547,7 @@ func (n *Network) CopyTo(o datastore.KVObject) error {
|
| 553 | 553 |
} |
| 554 | 554 |
|
| 555 | 555 |
dstN.generic = options.Generic{}
|
| 556 |
- for k, v := range n.generic {
|
|
| 557 |
- dstN.generic[k] = v |
|
| 558 |
- } |
|
| 556 |
+ maps.Copy(dstN.generic, n.generic) |
|
| 559 | 557 |
|
| 560 | 558 |
return nil |
| 561 | 559 |
} |
| ... | ... |
@@ -793,9 +785,7 @@ func NetworkOptionGeneric(generic map[string]any) NetworkOption {
|
| 793 | 793 |
if val, ok := generic[netlabel.Internal]; ok {
|
| 794 | 794 |
n.internal = val.(bool) |
| 795 | 795 |
} |
| 796 |
- for k, v := range generic {
|
|
| 797 |
- n.generic[k] = v |
|
| 798 |
- } |
|
| 796 |
+ maps.Copy(n.generic, generic) |
|
| 799 | 797 |
} |
| 800 | 798 |
} |
| 801 | 799 |
|
| ... | ... |
@@ -1875,9 +1865,7 @@ func (n *Network) Labels() map[string]string {
|
| 1875 | 1875 |
defer n.mu.Unlock() |
| 1876 | 1876 |
|
| 1877 | 1877 |
lbls := make(map[string]string, len(n.labels)) |
| 1878 |
- for k, v := range n.labels {
|
|
| 1879 |
- lbls[k] = v |
|
| 1880 |
- } |
|
| 1878 |
+ maps.Copy(lbls, n.labels) |
|
| 1881 | 1879 |
|
| 1882 | 1880 |
return lbls |
| 1883 | 1881 |
} |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"encoding/json" |
| 6 | 6 |
"fmt" |
| 7 |
+ "maps" |
|
| 7 | 8 |
"net" |
| 8 | 9 |
"net/netip" |
| 9 | 10 |
"slices" |
| ... | ... |
@@ -126,9 +127,7 @@ func (sb *Sandbox) Labels() map[string]any {
|
| 126 | 126 |
sb.mu.Lock() |
| 127 | 127 |
defer sb.mu.Unlock() |
| 128 | 128 |
opts := make(map[string]any, len(sb.config.generic)) |
| 129 |
- for k, v := range sb.config.generic {
|
|
| 130 |
- opts[k] = v |
|
| 131 |
- } |
|
| 129 |
+ maps.Copy(opts, sb.config.generic) |
|
| 132 | 130 |
return opts |
| 133 | 131 |
} |
| 134 | 132 |
|
| ... | ... |
@@ -280,9 +279,7 @@ func (sb *Sandbox) UpdateLabels(labels map[string]any) {
|
| 280 | 280 |
if sb.config.generic == nil {
|
| 281 | 281 |
sb.config.generic = make(map[string]any, len(labels)) |
| 282 | 282 |
} |
| 283 |
- for k, v := range labels {
|
|
| 284 |
- sb.config.generic[k] = v |
|
| 285 |
- } |
|
| 283 |
+ maps.Copy(sb.config.generic, labels) |
|
| 286 | 284 |
} |
| 287 | 285 |
|
| 288 | 286 |
func (sb *Sandbox) MarshalJSON() ([]byte, error) {
|
| ... | ... |
@@ -4,6 +4,7 @@ package fluentd |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 | 6 |
"context" |
| 7 |
+ "maps" |
|
| 7 | 8 |
"math" |
| 8 | 9 |
"net/url" |
| 9 | 10 |
"strconv" |
| ... | ... |
@@ -120,9 +121,7 @@ func (f *fluentd) Log(msg *logger.Message) error {
|
| 120 | 120 |
"source": msg.Source, |
| 121 | 121 |
"log": string(msg.Line), |
| 122 | 122 |
} |
| 123 |
- for k, v := range f.extra {
|
|
| 124 |
- data[k] = v |
|
| 125 |
- } |
|
| 123 |
+ maps.Copy(data, f.extra) |
|
| 126 | 124 |
if msg.PLogMetaData != nil {
|
| 127 | 125 |
data["partial_message"] = "true" |
| 128 | 126 |
data["partial_id"] = msg.PLogMetaData.ID |
| ... | ... |
@@ -3,6 +3,7 @@ package fluentd |
| 3 | 3 |
import ( |
| 4 | 4 |
"bufio" |
| 5 | 5 |
"context" |
| 6 |
+ "maps" |
|
| 6 | 7 |
"net" |
| 7 | 8 |
"path/filepath" |
| 8 | 9 |
"runtime" |
| ... | ... |
@@ -350,9 +351,7 @@ func TestReadWriteTimeoutsAreEffective(t *testing.T) {
|
| 350 | 350 |
"fluentd-buffer-limit": "1", |
| 351 | 351 |
} |
| 352 | 352 |
// Update the config with test specific configs. |
| 353 |
- for k, v := range tc.cfg {
|
|
| 354 |
- cfg[k] = v |
|
| 355 |
- } |
|
| 353 |
+ maps.Copy(cfg, tc.cfg) |
|
| 356 | 354 |
|
| 357 | 355 |
f, err := New(logger.Info{
|
| 358 | 356 |
ContainerName: "/test-container", |
| ... | ... |
@@ -5,6 +5,7 @@ package journald |
| 5 | 5 |
import ( |
| 6 | 6 |
"errors" |
| 7 | 7 |
"fmt" |
| 8 |
+ "maps" |
|
| 8 | 9 |
"strconv" |
| 9 | 10 |
"sync/atomic" |
| 10 | 11 |
"time" |
| ... | ... |
@@ -129,9 +130,7 @@ func newJournald(info logger.Info) (*journald, error) {
|
| 129 | 129 |
if err != nil {
|
| 130 | 130 |
return nil, err |
| 131 | 131 |
} |
| 132 |
- for k, v := range extraAttrs {
|
|
| 133 |
- vars[k] = v |
|
| 134 |
- } |
|
| 132 |
+ maps.Copy(vars, extraAttrs) |
|
| 135 | 133 |
return &journald{
|
| 136 | 134 |
epoch: epoch, |
| 137 | 135 |
vars: vars, |
| ... | ... |
@@ -159,9 +158,7 @@ func validateLogOpt(cfg map[string]string) error {
|
| 159 | 159 |
|
| 160 | 160 |
func (s *journald) Log(msg *logger.Message) error {
|
| 161 | 161 |
vars := map[string]string{}
|
| 162 |
- for k, v := range s.vars {
|
|
| 163 |
- vars[k] = v |
|
| 164 |
- } |
|
| 162 |
+ maps.Copy(vars, s.vars) |
|
| 165 | 163 |
if !msg.Timestamp.IsZero() {
|
| 166 | 164 |
vars[fieldSyslogTimestamp] = msg.Timestamp.Format(time.RFC3339Nano) |
| 167 | 165 |
} |
| ... | ... |
@@ -1,5 +1,7 @@ |
| 1 | 1 |
package logger |
| 2 | 2 |
|
| 3 |
+import "maps" |
|
| 4 |
+ |
|
| 3 | 5 |
var externalValidators []LogOptValidator |
| 4 | 6 |
|
| 5 | 7 |
// RegisterExternalValidator adds the validator to the list of external validators. |
| ... | ... |
@@ -14,9 +16,7 @@ func RegisterExternalValidator(v LogOptValidator) {
|
| 14 | 14 |
// not be exposed as a usable log driver to the API. |
| 15 | 15 |
// This should only be called on package initialization. |
| 16 | 16 |
func AddBuiltinLogOpts(opts map[string]bool) {
|
| 17 |
- for k, v := range opts {
|
|
| 18 |
- builtInLogOpts[k] = v |
|
| 19 |
- } |
|
| 17 |
+ maps.Copy(builtInLogOpts, opts) |
|
| 20 | 18 |
} |
| 21 | 19 |
|
| 22 | 20 |
func validateExternal(cfg map[string]string) error {
|
| ... | ... |
@@ -304,9 +304,7 @@ func (daemon *Daemon) createNetwork(ctx context.Context, cfg *config.Config, cre |
| 304 | 304 |
} |
| 305 | 305 |
|
| 306 | 306 |
networkOptions := make(map[string]string) |
| 307 |
- for k, v := range create.Options {
|
|
| 308 |
- networkOptions[k] = v |
|
| 309 |
- } |
|
| 307 |
+ maps.Copy(networkOptions, create.Options) |
|
| 310 | 308 |
if defaultOpts, ok := cfg.DefaultNetworkOpts[driver]; create.ConfigFrom == nil && ok {
|
| 311 | 309 |
for k, v := range defaultOpts {
|
| 312 | 310 |
if _, ok := networkOptions[k]; !ok {
|
| ... | ... |
@@ -3,6 +3,7 @@ package daemon |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"fmt" |
| 6 |
+ "maps" |
|
| 6 | 7 |
"os" |
| 7 | 8 |
"path/filepath" |
| 8 | 9 |
"strconv" |
| ... | ... |
@@ -985,9 +986,7 @@ func WithSysctls(c *container.Container) coci.SpecOpts {
|
| 985 | 985 |
} |
| 986 | 986 |
// We merge the sysctls injected above with the HostConfig (latter takes |
| 987 | 987 |
// precedence for backwards-compatibility reasons). |
| 988 |
- for k, v := range c.HostConfig.Sysctls {
|
|
| 989 |
- s.Linux.Sysctl[k] = v |
|
| 990 |
- } |
|
| 988 |
+ maps.Copy(s.Linux.Sysctl, c.HostConfig.Sysctls) |
|
| 991 | 989 |
return nil |
| 992 | 990 |
} |
| 993 | 991 |
} |
| ... | ... |
@@ -102,9 +102,7 @@ func newServiceConfig(options ServiceOptions) (*serviceConfig, error) {
|
| 102 | 102 |
// copy constructs a new ServiceConfig with a copy of the configuration in config. |
| 103 | 103 |
func (config *serviceConfig) copy() *registry.ServiceConfig {
|
| 104 | 104 |
ic := make(map[string]*registry.IndexInfo) |
| 105 |
- for key, value := range config.IndexConfigs {
|
|
| 106 |
- ic[key] = value |
|
| 107 |
- } |
|
| 105 |
+ maps.Copy(ic, config.IndexConfigs) |
|
| 108 | 106 |
return ®istry.ServiceConfig{
|
| 109 | 107 |
InsecureRegistryCIDRs: slices.Clone(config.InsecureRegistryCIDRs), |
| 110 | 108 |
IndexConfigs: ic, |
| ... | ... |
@@ -1,6 +1,7 @@ |
| 1 | 1 |
package container |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "maps" |
|
| 4 | 5 |
"strings" |
| 5 | 6 |
"testing" |
| 6 | 7 |
|
| ... | ... |
@@ -315,9 +316,7 @@ func TestHandleSysctlBC(t *testing.T) {
|
| 315 | 315 |
NetworkMode: container.NetworkMode(tc.networkMode), |
| 316 | 316 |
Sysctls: map[string]string{},
|
| 317 | 317 |
} |
| 318 |
- for k, v := range tc.sysctls {
|
|
| 319 |
- hostCfg.Sysctls[k] = v |
|
| 320 |
- } |
|
| 318 |
+ maps.Copy(hostCfg.Sysctls, tc.sysctls) |
|
| 321 | 319 |
netCfg := &network.NetworkingConfig{
|
| 322 | 320 |
EndpointsConfig: tc.epConfig, |
| 323 | 321 |
} |
| ... | ... |
@@ -3,6 +3,7 @@ package drivers |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"errors" |
| 6 |
+ "maps" |
|
| 6 | 7 |
"strings" |
| 7 | 8 |
"time" |
| 8 | 9 |
|
| ... | ... |
@@ -169,8 +170,6 @@ func (a *volumeAdapter) CreatedAt() (time.Time, error) {
|
| 169 | 169 |
|
| 170 | 170 |
func (a *volumeAdapter) Status() map[string]any {
|
| 171 | 171 |
out := make(map[string]any, len(a.status)) |
| 172 |
- for k, v := range a.status {
|
|
| 173 |
- out[k] = v |
|
| 174 |
- } |
|
| 172 |
+ maps.Copy(out, a.status) |
|
| 175 | 173 |
return out |
| 176 | 174 |
} |
| ... | ... |
@@ -3,6 +3,7 @@ package service |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"fmt" |
| 6 |
+ "maps" |
|
| 6 | 7 |
"net" |
| 7 | 8 |
"os" |
| 8 | 9 |
"path/filepath" |
| ... | ... |
@@ -39,9 +40,7 @@ func (v volumeWrapper) Options() map[string]string {
|
| 39 | 39 |
return nil |
| 40 | 40 |
} |
| 41 | 41 |
options := make(map[string]string, len(v.options)) |
| 42 |
- for key, value := range v.options {
|
|
| 43 |
- options[key] = value |
|
| 44 |
- } |
|
| 42 |
+ maps.Copy(options, v.options) |
|
| 45 | 43 |
return options |
| 46 | 44 |
} |
| 47 | 45 |
|
| ... | ... |
@@ -51,9 +50,7 @@ func (v volumeWrapper) Labels() map[string]string {
|
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 | 53 |
labels := make(map[string]string, len(v.labels)) |
| 54 |
- for key, value := range v.labels {
|
|
| 55 |
- labels[key] = value |
|
| 56 |
- } |
|
| 54 |
+ maps.Copy(labels, v.labels) |
|
| 57 | 55 |
return labels |
| 58 | 56 |
} |
| 59 | 57 |
|
| ... | ... |
@@ -3,6 +3,7 @@ package daemon |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"encoding/hex" |
| 6 |
+ "maps" |
|
| 6 | 7 |
"os" |
| 7 | 8 |
"path/filepath" |
| 8 | 9 |
"sort" |
| ... | ... |
@@ -97,9 +98,7 @@ func (daemon *Daemon) registerMountPoints(ctr *container.Container, defaultReadO |
| 97 | 97 |
} |
| 98 | 98 |
|
| 99 | 99 |
// 1. Read already configured mount points. |
| 100 |
- for destination, point := range ctr.MountPoints {
|
|
| 101 |
- mountPoints[destination] = point |
|
| 102 |
- } |
|
| 100 |
+ maps.Copy(mountPoints, ctr.MountPoints) |
|
| 103 | 101 |
|
| 104 | 102 |
// 2. Read volumes from other containers. |
| 105 | 103 |
for _, v := range ctr.HostConfig.VolumesFrom {
|
| ... | ... |
@@ -1,6 +1,7 @@ |
| 1 | 1 |
package labelstore |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "maps" |
|
| 4 | 5 |
"sync" |
| 5 | 6 |
|
| 6 | 7 |
"github.com/opencontainers/go-digest" |
| ... | ... |
@@ -40,9 +41,7 @@ func (s *InMemory) Update(dgst digest.Digest, update map[string]string) (map[str |
| 40 | 40 |
if !ok {
|
| 41 | 41 |
labels = map[string]string{}
|
| 42 | 42 |
} |
| 43 |
- for k, v := range update {
|
|
| 44 |
- labels[k] = v |
|
| 45 |
- } |
|
| 43 |
+ maps.Copy(labels, update) |
|
| 46 | 44 |
if s.labels == nil {
|
| 47 | 45 |
s.labels = map[digest.Digest]map[string]string{}
|
| 48 | 46 |
} |