Skip to content

Commit

Permalink
Merge pull request #26 from dell/add-go-version-workflow
Browse files Browse the repository at this point in the history
Add go version update worklow
  • Loading branch information
falfaroc authored Oct 8, 2024
2 parents 01d8728 + c2f21a1 commit 0bc0fc5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/go-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0

# Reusable workflow to perform go version update on Golang based projects
name: Go Version Update

on:
workflow_dispatch:
repository_dispatch:
types: [go-update-workflow]

jobs:
# go version update
go-version-update:
uses: dell/common-github-actions/.github/workflows/go-version-workflow.yaml@main
name: Go Version Update
secrets: inherit
26 changes: 14 additions & 12 deletions mock/service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,20 @@ func (s *service) ListVolumes(
}()

var (
ulenVols = int32(len(vols))
ulenVols = int64(len(vols))
maxEntries = req.MaxEntries
startingToken int32
startingToken int64
)

if v := req.StartingToken; v != "" {
i, err := strconv.ParseUint(v, 10, 32)
i, err := strconv.ParseInt(v, 10, 32)
if err != nil {
return nil, status.Errorf(
codes.InvalidArgument,
"startingToken=%d !< int32=%d",
startingToken, math.MaxUint32)
}
startingToken = int32(i)
startingToken = i
}

if startingToken > ulenVols {
Expand All @@ -204,7 +204,8 @@ func (s *service) ListVolumes(
}

// Discern the number of remaining entries.
rem := ulenVols - startingToken
// #nosec G115
rem := int32(ulenVols - startingToken)

// If maxEntries is 0 or greater than the number of remaining entries then
// set maxEntries to the number of remaining entries.
Expand All @@ -228,7 +229,7 @@ func (s *service) ListVolumes(
}

var nextToken string
if n := startingToken + int32(i); n < ulenVols {
if n := startingToken + int64(i); n < ulenVols {
nextToken = fmt.Sprintf("%d", n)
}

Expand Down Expand Up @@ -345,20 +346,20 @@ func (s *service) ListSnapshots(
}()

var (
ulensnaps = int32(len(snaps))
ulensnaps = int64(len(snaps))
maxEntries = req.MaxEntries
startingToken int32
startingToken int64
)

if s := req.StartingToken; s != "" {
i, err := strconv.ParseUint(s, 10, 32)
i, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return nil, status.Errorf(
codes.InvalidArgument,
"startingToken=%d !< int32=%d",
startingToken, math.MaxUint32)
}
startingToken = int32(i)
startingToken = i
}

if startingToken > ulensnaps {
Expand All @@ -369,7 +370,8 @@ func (s *service) ListSnapshots(
}

// Discern the number of remaining entries.
rem := ulensnaps - startingToken
// #nosec G115
rem := int32(ulensnaps - startingToken)

// If maxEntries is 0 or greater than the number of remaining entries then
// set maxEntries to the number of remaining entries.
Expand All @@ -395,7 +397,7 @@ func (s *service) ListSnapshots(
}

var nextToken string
if n := startingToken + int32(i); n < ulensnaps {
if n := startingToken + int64(i); n < ulensnaps {
nextToken = fmt.Sprintf("%d", n)
}

Expand Down
5 changes: 2 additions & 3 deletions testing/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,8 @@ var _ = Describe("Controller", func() {
Ω(vol).Should(BeNil())
Ω(err).Should(ΣCM(
codes.InvalidArgument,
fmt.Sprintf(
"exceeds size limit: Parameters[%s]: max=128, size=129",
string129)))
"exceeds size limit: Parameters[%s]: max=128, size=129",
string129))
})
})
Context("Invalid Params Field Val", func() {
Expand Down

0 comments on commit 0bc0fc5

Please sign in to comment.