diff --git a/client/config/config.go b/client/config/config.go index c4d17abc2e7..32163f85ab7 100644 --- a/client/config/config.go +++ b/client/config/config.go @@ -232,6 +232,7 @@ func (c *Config) Copy() *Config { nc.Node = nc.Node.Copy() nc.Servers = helper.CopySliceString(nc.Servers) nc.Options = helper.CopyMapStringString(nc.Options) + nc.HostVolumes = structs.CopyMapStringClientHostVolumeConfig(nc.HostVolumes) nc.ConsulConfig = c.ConsulConfig.Copy() nc.VaultConfig = c.VaultConfig.Copy() return nc diff --git a/nomad/structs/volumes.go b/nomad/structs/volumes.go index f317d48a657..3c935b3e2a1 100644 --- a/nomad/structs/volumes.go +++ b/nomad/structs/volumes.go @@ -27,6 +27,19 @@ func (p *ClientHostVolumeConfig) Copy() *ClientHostVolumeConfig { return c } +func CopyMapStringClientHostVolumeConfig(m map[string]*ClientHostVolumeConfig) map[string]*ClientHostVolumeConfig { + if m == nil { + return nil + } + + nm := make(map[string]*ClientHostVolumeConfig, len(m)) + for k, v := range m { + nm[k] = v.Copy() + } + + return nm +} + func HostVolumeSliceMerge(a, b []*ClientHostVolumeConfig) []*ClientHostVolumeConfig { n := make([]*ClientHostVolumeConfig, len(a)) seenKeys := make(map[string]struct{}, len(a))