From 83812bb8fe4ba69ce520780273c26eae5c7ba8b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 03:34:16 +0000 Subject: [PATCH] Bump github.com/kubeservice-stack/common from 1.9.1 to 1.10.0 Bumps [github.com/kubeservice-stack/common](https://github.com/kubeservice-stack/common) from 1.9.1 to 1.10.0. - [Release notes](https://github.com/kubeservice-stack/common/releases) - [Changelog](https://github.com/kubeservice-stack/common/blob/main/CHANGELOG.md) - [Commits](https://github.com/kubeservice-stack/common/compare/v1.9.1...v1.10.0) --- updated-dependencies: - dependency-name: github.com/kubeservice-stack/common dependency-version: 1.10.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +-- .../common/pkg/schedule/scheduler.go | 10 +++--- .../kubeservice-stack/common/pkg/utils/map.go | 10 ++++-- .../common/pkg/utils/slice.go | 31 ++++++++++++------- .../common/pkg/utils/strings.go | 12 +++++-- vendor/modules.txt | 4 +-- 7 files changed, 48 insertions(+), 25 deletions(-) diff --git a/go.mod b/go.mod index 51e30c4..80e922e 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.26 require ( github.com/alecthomas/kingpin/v2 v2.4.0 github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 - github.com/kubeservice-stack/common v1.9.1 + github.com/kubeservice-stack/common v1.10.0 github.com/montanaflynn/stats v0.9.0 github.com/prometheus/client_golang v1.23.2 github.com/prometheus/common v0.68.1 diff --git a/go.sum b/go.sum index 73ba01b..6bad3f8 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kubeservice-stack/common v1.9.1 h1:uWRvApeau58hTyOyfGUrzrzzvz+p5OCu5dEX2EDl93I= -github.com/kubeservice-stack/common v1.9.1/go.mod h1:tC4FPCQGUiCYfFAOASvpVvA1N1+UTuITK2cX6w4CWMM= +github.com/kubeservice-stack/common v1.10.0 h1:1WibIluxYwhxb+reGlju5p1RvDlhQ5LOfc3sRXxqJzU= +github.com/kubeservice-stack/common v1.10.0/go.mod h1:GEEMqFiOIHjP9dVjZzQsdU9jGVtMnnBnKbPWbS5MMK8= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= diff --git a/vendor/github.com/kubeservice-stack/common/pkg/schedule/scheduler.go b/vendor/github.com/kubeservice-stack/common/pkg/schedule/scheduler.go index 9a2204c..08ffa4f 100644 --- a/vendor/github.com/kubeservice-stack/common/pkg/schedule/scheduler.go +++ b/vendor/github.com/kubeservice-stack/common/pkg/schedule/scheduler.go @@ -193,11 +193,13 @@ func (s *Scheduler) Clear() { // Start all the pending jobs // Add seconds ticker -func (s *Scheduler) Start() chan bool { - stopped := make(chan bool, 1) +func (s *Scheduler) Start() (stopped chan bool, done <-chan struct{}) { + stopped = make(chan bool, 1) + doneCh := make(chan struct{}) ticker := time.NewTicker(1 * time.Second) go func() { + defer close(doneCh) for { select { case <-ticker.C: @@ -209,7 +211,7 @@ func (s *Scheduler) Start() chan bool { } }() - return stopped + return stopped, doneCh } // The following methods are shortcuts for not having to @@ -246,7 +248,7 @@ func RunAllwithDelay(d int) { } // Start run all jobs that are scheduled to run -func Start() chan bool { +func Start() (chan bool, <-chan struct{}) { return defaultScheduler.Start() } diff --git a/vendor/github.com/kubeservice-stack/common/pkg/utils/map.go b/vendor/github.com/kubeservice-stack/common/pkg/utils/map.go index b0d57de..f5a3988 100644 --- a/vendor/github.com/kubeservice-stack/common/pkg/utils/map.go +++ b/vendor/github.com/kubeservice-stack/common/pkg/utils/map.go @@ -22,6 +22,7 @@ import ( "strconv" ) +// Keys returns all keys from the map as a slice. func Keys(maps map[string]interface{}) []string { var keys []string for k := range maps { @@ -30,6 +31,7 @@ func Keys(maps map[string]interface{}) []string { return keys } +// Values returns all values from the map as a slice. func Values(maps map[string]interface{}) []interface{} { var values []interface{} for _, v := range maps { @@ -121,7 +123,9 @@ func ToMapStrings(param map[string]interface{}) map[string]string { } for key, value := range param { - ret[key] = value.(string) + if v, ok := value.(string); ok { + ret[key] = v + } } return ret } @@ -133,8 +137,8 @@ func Strings(param []interface{}) map[string]bool { } for _, value := range param { - if value.(string) != "" { - ret[value.(string)] = true + if v, ok := value.(string); ok && v != "" { + ret[v] = true } } diff --git a/vendor/github.com/kubeservice-stack/common/pkg/utils/slice.go b/vendor/github.com/kubeservice-stack/common/pkg/utils/slice.go index 28f3c4a..de9eac7 100644 --- a/vendor/github.com/kubeservice-stack/common/pkg/utils/slice.go +++ b/vendor/github.com/kubeservice-stack/common/pkg/utils/slice.go @@ -18,11 +18,11 @@ package utils import ( "errors" + "fmt" "math/rand" "reflect" "strconv" "strings" - "time" ) type ( @@ -73,9 +73,7 @@ func SliceRandList(min, max int) []int { min, max = max, min } length := max - min + 1 - t0 := time.Now() - r := rand.New(rand.NewSource(int64(t0.Nanosecond()))) - list := r.Perm(length) + list := rand.Perm(length) for index := range list { list[index] += min } @@ -138,18 +136,23 @@ func SliceRange(start, end, step int64) (intslice []int64) { return } +// SliceShuffle shuffles a slice using Fisher-Yates algorithm. +// NOTE: This uses math/rand which is not cryptographically secure. +// Do not use for security-sensitive shuffling (e.g., token generation). func SliceShuffle(slice []interface{}) []interface{} { - for i := 0; i < len(slice); i++ { - a := rand.Intn(len(slice)) - b := rand.Intn(len(slice)) - slice[a], slice[b] = slice[b], slice[a] + n := len(slice) + for i := n - 1; i > 0; i-- { + j := rand.Intn(i + 1) + slice[i], slice[j] = slice[j], slice[i] } return slice } func InterfacesToStrings(items []interface{}) (s []string) { for _, item := range items { - s = append(s, item.(string)) + if v, ok := item.(string); ok { + s = append(s, v) + } } return s } @@ -161,7 +164,11 @@ func ToStringDict(items []interface{}, key string) ([]string, error) { if !ok { return nil, errors.New("interface{} to map[string]string err") } - ret = append(ret, it[key].(string)) + v, ok := it[key].(string) + if !ok { + return nil, fmt.Errorf("key %q value is not a string", key) + } + ret = append(ret, v) } return ret, nil } @@ -183,7 +190,9 @@ func ToStrings(arr []interface{}) []string { var ret []string for _, value := range arr { if value != nil { - ret = append(ret, value.(string)) + if v, ok := value.(string); ok { + ret = append(ret, v) + } } } return ret diff --git a/vendor/github.com/kubeservice-stack/common/pkg/utils/strings.go b/vendor/github.com/kubeservice-stack/common/pkg/utils/strings.go index 65c430a..45ff559 100644 --- a/vendor/github.com/kubeservice-stack/common/pkg/utils/strings.go +++ b/vendor/github.com/kubeservice-stack/common/pkg/utils/strings.go @@ -26,12 +26,12 @@ func GetBetweenStr(str, start, end string) string { if n == -1 { n = 0 } - str = string([]byte(str)[n:]) + str = str[n:] m := strings.Index(str, end) if m == -1 { m = len(str) } - str = string([]byte(str)[:m]) + str = str[:m] return str } @@ -65,6 +65,10 @@ func Substr(str string, start, length int) string { return string(rs[start:end]) } +// String2Bytes converts a string to a byte slice without memory allocation. +// WARNING: the returned slice shares the underlying memory with the string. +// Do NOT modify the returned slice, as it may corrupt the original string. +// For safe conversion, use []byte(s) instead. func String2Bytes(s string) []byte { var ret []byte if len(s) == 0 { @@ -73,6 +77,10 @@ func String2Bytes(s string) []byte { return unsafe.Slice(unsafe.StringData(s), len(s)) } +// Bytes2String converts a byte slice to a string without memory allocation. +// WARNING: the returned string shares the underlying memory with the byte slice. +// Do NOT modify the input slice while the returned string is in use. +// For safe conversion, use string(b) instead. func Bytes2String(b []byte) string { if len(b) == 0 { return "" diff --git a/vendor/modules.txt b/vendor/modules.txt index ad8de48..b1e0725 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -35,8 +35,8 @@ github.com/illumos/go-kstat # github.com/jpillora/backoff v1.0.0 ## explicit; go 1.13 github.com/jpillora/backoff -# github.com/kubeservice-stack/common v1.9.1 -## explicit; go 1.24.0 +# github.com/kubeservice-stack/common v1.10.0 +## explicit; go 1.26 github.com/kubeservice-stack/common/pkg/config github.com/kubeservice-stack/common/pkg/config/ltoml github.com/kubeservice-stack/common/pkg/logger