kanisterio / kanister

An extensible framework for application-level data management on Kubernetes
https://kanister.io
Apache License 2.0
764 stars 155 forks source link

Fix incorrect conversion between int types #3205

Closed viveksinghggits closed 3 weeks ago

viveksinghggits commented 3 weeks ago

Change Overview

Fixes https://github.com/kanisterio/kanister/issues/3202

In the older version of the logic where we were reading replicas of workload in ScaleWorkload function; if val (string type) has an int value that is beyond the range of int32, even though call strconv.Atoi(val) would succeed, the next of replicas = int32(v) would result into unexpected result because the val is beyond what can be accommodated into int32 type. This change fixes that.

Pull request type

Please check the type of change your PR introduces:

Issues

Test Plan

/kanister/pkg/function (fix-codescanning-incorrect-intconv*) » go test -check.f "ScaleWorkloadSuite"
OK: 1 passed
PASS
ok      github.com/kanisterio/kanister/pkg/function     0.894s