Skip to content

Commit

Permalink
Merge branch 'master' into tom/fix-kanx-error-test
Browse files Browse the repository at this point in the history
  • Loading branch information
pavannd1 authored Oct 30, 2024
2 parents 45dfe54 + 1708d6c commit 8c73aa6
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 28 deletions.
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ require (
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637

//pinned k8s.io to v0.29.x tag
k8s.io/api v0.29.9
k8s.io/apiextensions-apiserver v0.29.9
k8s.io/apimachinery v0.29.9
k8s.io/cli-runtime v0.29.9
k8s.io/client-go v0.29.9
k8s.io/code-generator v0.29.9
k8s.io/kubectl v0.29.9
k8s.io/api v0.29.10
k8s.io/apiextensions-apiserver v0.29.10
k8s.io/apimachinery v0.29.10
k8s.io/cli-runtime v0.29.10
k8s.io/client-go v0.29.10
k8s.io/code-generator v0.29.10
k8s.io/kubectl v0.29.10
sigs.k8s.io/controller-runtime v0.16.6
sigs.k8s.io/yaml v1.3.0

Expand Down Expand Up @@ -224,7 +224,7 @@ require (
gopkg.in/kothar/go-backblaze.v0 v0.0.0-20210124194846-35409b867216 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/component-base v0.29.9 // indirect
k8s.io/component-base v0.29.10 // indirect
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00
Expand Down
32 changes: 16 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -834,23 +834,23 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
k8s.io/api v0.19.0/go.mod h1:I1K45XlvTrDjmj5LoM5LuP/KYrhWbjUKT/SoPG0qTjw=
k8s.io/api v0.29.9 h1:FwdflpNsfMUYUOblMZNWJ4K/q0OSL5A4jGa0iOgcJco=
k8s.io/api v0.29.9/go.mod h1:fNhmzRfKaSEHCmczA/jRx6CiDKhYOnFLJBERMJAXEk8=
k8s.io/apiextensions-apiserver v0.29.9 h1:EB6RK06kFJjbzBwU1YiVznxrcgBE0hhDWt6EQQIcOy4=
k8s.io/apiextensions-apiserver v0.29.9/go.mod h1:jcaHG6R/bB1iU6XzC1DMhB1x2ktTJLt2KKpg6B65Z2c=
k8s.io/api v0.29.10 h1:Fao3HOxccbGRC1HZtXD+Y41xJhP0tEToVo5W7EEUBm0=
k8s.io/api v0.29.10/go.mod h1:rF0sRh64w1hMNAVGh4YYniSxODyHye3GLmymAbWBDvY=
k8s.io/apiextensions-apiserver v0.29.10 h1:2k2AHrWgs4S+07HrOjEdcyrQ/UqYlvBi6uon1fox1KE=
k8s.io/apiextensions-apiserver v0.29.10/go.mod h1:3rrJC52bW5frHf10N3JvaDpl++hgrzD9Gs6IZpKWMoc=
k8s.io/apimachinery v0.19.0/go.mod h1:DnPGDnARWFvYa3pMHgSxtbZb7gpzzAZ1pTfaUNDVlmA=
k8s.io/apimachinery v0.29.9 h1:YZ8HUid1TzQVz94cnNlsQjLdH0VoAhWSqz7t0q6B12A=
k8s.io/apimachinery v0.29.9/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y=
k8s.io/cli-runtime v0.29.9 h1:rryHH2SZtZePv0gj9RM5ftXYcK8v2jbMLOzbORnzzw4=
k8s.io/cli-runtime v0.29.9/go.mod h1:IHgU0jdyAOcrfkpvaDXZRqPe+RJYlUgbufl88Z6EUyo=
k8s.io/apimachinery v0.29.10 h1:57OLNqOJUgp5KlRRY3JOBFOTTa5Rt/LVkmKiiN2cvaQ=
k8s.io/apimachinery v0.29.10/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y=
k8s.io/cli-runtime v0.29.10 h1:iX8bo6jmxvmoq046YX/Ry+s3Vc21sfxmYzjKLfEaP6M=
k8s.io/cli-runtime v0.29.10/go.mod h1:sGE4CX6FM600SEX8h/tPS0WGFYkTH+W5oU9eyp5Xtpc=
k8s.io/client-go v0.19.0/go.mod h1:H9E/VT95blcFQnlyShFgnFT9ZnJOAceiUHM3MlRC+mU=
k8s.io/client-go v0.29.9 h1:4f/Wz6li3rEyIPFj32XAQMtOGMM1tg7KQi1oeS6ibPg=
k8s.io/client-go v0.29.9/go.mod h1:2N1drQEZ5yiYrWVaE2Un8JiISUhl47D8pyZlYLszke4=
k8s.io/client-go v0.29.10 h1:hPmG1pmKslRhmCIzVd90sA58B0sJwNwduNgXFWsFqhI=
k8s.io/client-go v0.29.10/go.mod h1:gnMCQiRXGL9K0VtlW8gTkhzptGrHm2BJ4qBbujNemc4=
k8s.io/code-generator v0.19.0/go.mod h1:moqLn7w0t9cMs4+5CQyxnfA/HV8MF6aAVENF+WZZhgk=
k8s.io/code-generator v0.29.9 h1:57k53ZbD4W4NFlTV2iH7nKfmoLP4Q6yW2o2H2nyZpF0=
k8s.io/code-generator v0.29.9/go.mod h1:7TYnI0dYItL2cKuhhgPSuF3WED9uMdELgbVXFfn/joE=
k8s.io/component-base v0.29.9 h1:lPENvp3CCwdeMEWGjiTfn5b287qQYuK7gX32OBOovmA=
k8s.io/component-base v0.29.9/go.mod h1:NGDa6Ih0EdcLA2G4K2ZYySoiB+2Tn+rmSqPyudCPgDY=
k8s.io/code-generator v0.29.10 h1:Tj2comS0HYcs9yTt/g5PtiSxnprR7W/3oHLrarmWU5c=
k8s.io/code-generator v0.29.10/go.mod h1:7TYnI0dYItL2cKuhhgPSuF3WED9uMdELgbVXFfn/joE=
k8s.io/component-base v0.29.10 h1:YQrQ/bpzGPGqIPEPaBzxjH0/1DJOI+yZPZNbbz7ZCBY=
k8s.io/component-base v0.29.10/go.mod h1:IbwsBob2DnYiAONsSHIuYenchqcDycbHSLHrXshuLgM=
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=
Expand All @@ -862,8 +862,8 @@ k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo=
k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o=
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780=
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
k8s.io/kubectl v0.29.9 h1:8DJIPkRk5a6WonxRAbicJIn0DNwacOxaLxO4EDwf/hc=
k8s.io/kubectl v0.29.9/go.mod h1:ylJbHUuPTYiwxAKx97nAyU3TKh3vHlEW+Pp44Usolvw=
k8s.io/kubectl v0.29.10 h1:9LLAI52kRG98Kicn+JUPY3ZVg8MPcJVsHPoaMM//9cA=
k8s.io/kubectl v0.29.10/go.mod h1:HxsflBafbaRcMyQjiD6elLHr+erlGmnQgLzSDYjEth0=
k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
Expand Down
4 changes: 2 additions & 2 deletions pkg/function/scale_workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func (s *scaleWorkloadFunc) setArgs(tp param.TemplateParams, args map[string]int
case int64:
replicas = int32(val)
case string:
var v int
if v, err = strconv.Atoi(val); err != nil {
v, err := strconv.ParseInt(val, 10, 32)
if err != nil {
return errkit.Wrap(err, fmt.Sprintf("Cannot convert %s to int", val))
}
replicas = int32(v)
Expand Down
46 changes: 46 additions & 0 deletions pkg/function/scale_workload_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package function

import (
"gopkg.in/check.v1"

"github.com/kanisterio/kanister/pkg/param"
)

type ScaleWorkloadSuite struct{}

var _ = check.Suite(&ScaleWorkloadSuite{})

func (s *ScaleWorkloadSuite) TestSetArgs(c *check.C) {
stsParams := &param.StatefulSetParams{}
for _, tc := range []struct {
replicas interface{}
expectedReplicas int32
}{
{
replicas: 4,
expectedReplicas: 4,
},
{
replicas: 234324,
expectedReplicas: 234324,
},
{
replicas: 234324,
expectedReplicas: 234324,
},
{
replicas: 2147483647,
expectedReplicas: 2147483647, // 2147483647 is the maximum value int32 can hold
},
} {
s := scaleWorkloadFunc{}
err := s.setArgs(param.TemplateParams{
StatefulSet: stsParams,
}, map[string]interface{}{
"replicas": tc.replicas,
})

c.Assert(err, check.IsNil)
c.Assert(s.replicas, check.Equals, tc.expectedReplicas)
}
}
4 changes: 2 additions & 2 deletions pkg/kanx/kanx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"google.golang.org/grpc"
. "gopkg.in/check.v1"
"github.com/kanisterio/kanister/pkg/poll"

"github.com/kanisterio/kanister/pkg/poll"
)

// Hook up gocheck into the "go test" runner.
Expand Down

0 comments on commit 8c73aa6

Please sign in to comment.