Skip to content

Commit

Permalink
Merge pull request #3345 from telepresenceio/thallgren/itest-with-config
Browse files Browse the repository at this point in the history
Use by-value copy in itest.WithConfig
  • Loading branch information
thallgren authored Sep 14, 2023
2 parents 5198b18 + 28af250 commit cda6a96
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions integration_test/itest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"
"os"
"path/filepath"
"reflect"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -1077,13 +1078,15 @@ func WithConfig(c context.Context, modifierFunc func(config client.Config)) cont
TelepresenceQuitOk(c)

t := getT(c)
configCopy := client.GetConfig(c)
modifierFunc(configCopy)
cfgVal := reflect.ValueOf(client.GetConfig(c)).Elem()
cfgCopyVal := reflect.New(cfgVal.Type())
cfgCopyVal.Elem().Set(cfgVal) // By value copy
configCopy := cfgCopyVal.Interface()
modifierFunc(configCopy.(client.Config))
configYaml, err := yaml.Marshal(&configCopy)
require.NoError(t, err)
configYamlStr := string(configYaml)
configDir := t.TempDir()
c = filelocation.WithAppUserConfigDir(c, configDir)
c, err = SetConfig(c, configDir, configYamlStr)
require.NoError(t, err)
return c
Expand Down

0 comments on commit cda6a96

Please sign in to comment.