From 7373088e31b71c29696810d41a8b837f9008adef Mon Sep 17 00:00:00 2001 From: Marcus Karlsson Date: Wed, 20 Nov 2019 08:43:44 +1300 Subject: [PATCH] ActiveCluster now returns a pointer to a copy of the selected cluster. Issue: https://github.com/birdayz/kaf/issues/86 Suggested Fix: https://github.com/birdayz/kaf/pull/87#issuecomment-555669868 --- config.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 1a5a81c6..613fc1fd 100644 --- a/config.go +++ b/config.go @@ -76,7 +76,11 @@ func (c *Config) ActiveCluster() *Cluster { for _, cluster := range c.Clusters { if cluster.Name == toSearch { - return cluster + // Make copy of cluster struct, using a pointer leads to unintended + // behavior where modifications on currentCluster are written back + // into the config + c := *cluster + return &c } } return nil