Merge pull request #8778 from hashicorp/b-non-effective-copy

Fix accidental broken Copy
This commit is contained in:
Mahmood Ali
2020-08-29 17:57:18 -04:00
committed by GitHub
3 changed files with 10 additions and 7 deletions

View File

@@ -139,11 +139,11 @@ func TestJobExposeCheckHook_tgValidateUseOfCheckExpose(t *testing.T) {
})
t.Run("group-service uses custom proxy but no expose", func(t *testing.T) {
withCustomProxyTaskNoExpose := &(*withCustomProxyTask)
withCustomProxyTaskNoExpose := *withCustomProxyTask
withCustomProxyTask.Checks[0].Expose = false
require.Nil(t, tgValidateUseOfCheckExpose(&structs.TaskGroup{
Name: "g1",
Services: []*structs.Service{withCustomProxyTaskNoExpose},
Services: []*structs.Service{&withCustomProxyTaskNoExpose},
}))
})

View File

@@ -4,6 +4,8 @@ import (
"fmt"
"strings"
"time"
"github.com/hashicorp/nomad/helper"
)
// CSISocketName is the filename that Nomad expects plugins to create inside the
@@ -152,7 +154,10 @@ func (o *CSIMountOptions) Copy() *CSIMountOptions {
if o == nil {
return nil
}
return &(*o)
no := *o
no.MountFlags = helper.CopySliceString(o.MountFlags)
return &no
}
func (o *CSIMountOptions) Merge(p *CSIMountOptions) {

View File

@@ -100,12 +100,10 @@ func (v *VolumeRequest) Copy() *VolumeRequest {
nv := new(VolumeRequest)
*nv = *v
if v.MountOptions == nil {
return nv
if v.MountOptions != nil {
nv.MountOptions = v.MountOptions.Copy()
}
nv.MountOptions = &(*v.MountOptions)
return nv
}