use maps.Clone() over Copy() when possible

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-09-09 15:15:33 +02:00
parent 637de6022f
commit 4417e6269c
2 changed files with 3 additions and 6 deletions

View File

@@ -416,13 +416,11 @@ func (c *Container) generateInspectContainerConfig(spec *spec.Spec) *define.Insp
}
if len(c.config.Labels) != 0 {
ctrConfig.Labels = make(map[string]string)
maps.Copy(ctrConfig.Labels, c.config.Labels)
ctrConfig.Labels = maps.Clone(c.config.Labels)
}
if len(spec.Annotations) != 0 {
ctrConfig.Annotations = make(map[string]string)
maps.Copy(ctrConfig.Annotations, spec.Annotations)
ctrConfig.Annotations = maps.Clone(spec.Annotations)
}
ctrConfig.StopSignal = signal.ToDockerFormat(c.config.StopSignal)
// TODO: should JSON deep copy this to ensure internal pointers don't

View File

@@ -87,8 +87,7 @@ func WithStorageConfig(config storage.StoreOptions) RuntimeOption {
}
if config.PullOptions != nil {
rt.storageConfig.PullOptions = make(map[string]string)
maps.Copy(rt.storageConfig.PullOptions, config.PullOptions)
rt.storageConfig.PullOptions = maps.Clone(config.PullOptions)
}
// If any one of runroot, graphroot, graphdrivername,