mirror of
https://github.com/rancher/steve.git
synced 2025-10-21 15:28:52 +00:00
Implement custom DeepCopy for Count
This commit is contained in:
1
go.mod
1
go.mod
@@ -28,7 +28,6 @@ require (
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/urfave/cli v1.22.14
|
||||
github.com/urfave/cli/v2 v2.25.7
|
||||
golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b
|
||||
golang.org/x/sync v0.5.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
k8s.io/api v0.28.6
|
||||
|
2
go.sum
2
go.sum
@@ -396,8 +396,6 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw=
|
||||
go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
|
||||
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
|
||||
golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b h1:lkOPTy76R9NZ6FeDQWkDj3NsLtD8Csc9AAFYEl3kiME=
|
||||
golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b/go.mod h1:QXG482h3unP32W/YwIPOc+09bvY447B7T+iLjC/JPcA=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
|
@@ -4,7 +4,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/rancher/apiserver/pkg/types"
|
||||
"golang.design/x/reflect"
|
||||
)
|
||||
|
||||
// debounceDuration determines how long events will be held before they are sent to the consumer
|
||||
@@ -50,7 +49,7 @@ func debounceCounts(result chan types.APIEvent, input chan Count) {
|
||||
}
|
||||
case <-t.C:
|
||||
if currentCount != nil {
|
||||
result <- toAPIEvent(reflect.DeepCopy(*currentCount))
|
||||
result <- toAPIEvent(*currentCount.DeepCopy())
|
||||
currentCount = nil
|
||||
}
|
||||
}
|
||||
|
@@ -48,6 +48,17 @@ type Count struct {
|
||||
Counts map[string]ItemCount `json:"counts"`
|
||||
}
|
||||
|
||||
func (c *Count) DeepCopy() *Count {
|
||||
r := *c
|
||||
if r.Counts != nil {
|
||||
r.Counts = map[string]ItemCount{}
|
||||
for k, v := range c.Counts {
|
||||
r.Counts[k] = *v.DeepCopy()
|
||||
}
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
type Summary struct {
|
||||
Count int `json:"count,omitempty"`
|
||||
States map[string]int `json:"states,omitempty"`
|
||||
|
Reference in New Issue
Block a user