Skip to content

Commit

Permalink
fix: cloning a channel copied the edge slice instead of cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
ecordell committed Jul 10, 2024
1 parent 93df637 commit c087c85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/fatih/camelcase v1.0.0
github.com/go-logr/logr v1.4.2
github.com/jzelinskie/stringz v0.0.3
github.com/samber/lo v1.44.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
go.uber.org/atomic v1.11.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/samber/lo v1.44.0 h1:5il56KxRE+GHsm1IR+sZ/6J42NODigFiqCWpSc2dybA=
github.com/samber/lo v1.44.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
Expand Down
7 changes: 5 additions & 2 deletions pkg/updates/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/jzelinskie/stringz"
"github.com/samber/lo"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -45,8 +46,10 @@ func (c Channel) Clone() Channel {
return Channel{
Name: c.Name,
Metadata: maps.Clone(c.Metadata),
Edges: maps.Clone(c.Edges),
Nodes: slices.Clone(c.Nodes),
Edges: lo.MapEntries(c.Edges, func(k string, v []string) (string, []string) {
return k, slices.Clone(v)
}),
Nodes: slices.Clone(c.Nodes),
}
}

Expand Down

0 comments on commit c087c85

Please sign in to comment.