Skip to content

Commit

Permalink
comments for gosec
Browse files Browse the repository at this point in the history
Signed-off-by: Feny Mehta <[email protected]>
  • Loading branch information
fbm3307 committed Jan 9, 2025
1 parent fd09480 commit a621851
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func (r *Reconciler) determineCapacityReadyState(spc *toolchainv1alpha1.SpacePro
// It always knows this fact so returning a bool is ok, in contrast to determinMemoryUtilizationReadyState.
func determineSpaceCountReadyState(spc *toolchainv1alpha1.SpaceProvisionerConfig) bool {
max := spc.Spec.CapacityThresholds.MaxNumberOfSpaces
//the value of this is not going beyond 100 and it won't overflow, hence its okay to ignore the overflow linter error
return max == 0 || max > uint(spc.Status.ConsumedCapacity.SpaceCount) // nolint:gosec
}

Expand All @@ -203,6 +204,7 @@ func determineMemoryUtilizationReadyState(spc *toolchainv1alpha1.SpaceProvisione

// the memory utilitzation is ok if it is below the threshold in all node types
for _, val := range spc.Status.ConsumedCapacity.MemoryUsagePercentPerNodeRole {
//the value of this is not going beyond 100 and it won't overflow, hence its okay to ignore the overflow linter error
if uint(val) >= spc.Spec.CapacityThresholds.MaxMemoryUtilizationPercent { // nolint:gosec
return corev1.ConditionFalse
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/capacity/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type (

func hasNotReachedMaxNumberOfSpacesThreshold(counts counter.Counts) spaceProvisionerConfigPredicate {
return func(spc *toolchainv1alpha1.SpaceProvisionerConfig) bool {
//the value of this is not going beyond 100 and it won't overflow, hence its okay to ignore the overflow linter error
numberOfSpaces := uint(counts.SpacesPerClusterCounts[spc.Spec.ToolchainCluster]) // nolint:gosec
threshold := spc.Spec.CapacityThresholds.MaxNumberOfSpaces
return threshold == 0 || numberOfSpaces < threshold
Expand All @@ -45,6 +46,7 @@ func hasEnoughMemoryCapacity(status *toolchainv1alpha1.ToolchainStatus) spacePro
func hasMemberEnoughMemoryCapacity(memberStatus toolchainv1alpha1.Member, threshold uint) bool {
if len(memberStatus.MemberStatus.ResourceUsage.MemoryUsagePerNodeRole) > 0 {
for _, usagePerNode := range memberStatus.MemberStatus.ResourceUsage.MemoryUsagePerNodeRole {
//the value of this is not going beyond 100 and it won't overflow, hence its okay to ignore the overflow linter error
if uint(usagePerNode) >= threshold { // nolint:gosec
return false
}
Expand Down
1 change: 1 addition & 0 deletions pkg/space/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func NewSpaceWithFeatureToggles(userSignup *toolchainv1alpha1.UserSignup, target
func addFeatureToggles(space *toolchainv1alpha1.Space, toggles []toolchainconfig.FeatureToggle) {
var winners []string
for _, t := range toggles {
//the value of this is not going beyond 100 and it won't overflow, hence its okay to ignore the overflow linter error
weight := int(t.Weight()) // nolint:gosec
// We generate a random number between 0 and 100. If the number is equal to or lower than the weight
// then the feature wins.
Expand Down

0 comments on commit a621851

Please sign in to comment.