Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,35 @@

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Tidy
run: go mod tidy && git diff --exit-code

- name: Install dependencies
run: go install github.com/vektra/mockery/v2@v2.43.2

- name: Generate
run: go generate ./... && git diff --exit-code

- name: Build
run: go build -o=/dev/null ./cmd/...

- name: Lint
uses: golangci/golangci-lint-action@v5.0.0
with:
args: --timeout 3m

- name: Run tests
run: go test -race -shuffle=on -v ./...
run: go test -race -shuffle=on -v ./...

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 4 months ago

The best way to fix this problem is by explicitly specifying a permissions block restricting the GITHUB_TOKEN to the least privilege required. In this workflow, the steps only need to check repository contents; write access is unnecessary. Thus, the minimal required permissions are contents: read. This can be set at the workflow root (applies to all jobs) or inside the specific job config if more granularity is required. As there is only one job, adding the following at the workflow root after the name: line is optimal (as per convention and examples):

permissions:
  contents: read

Make this addition immediately after the name: Run tests line (line 15), before the on: block.

No imports, methods, or further changes are required.


Suggested changeset 1
.github/workflows/test.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -13,6 +13,8 @@
 # limitations under the License.
 
 name: Run tests
+permissions:
+  contents: read
 
 on:
   pull_request: {}
EOF
@@ -13,6 +13,8 @@
# limitations under the License.

name: Run tests
permissions:
contents: read

on:
pull_request: {}
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread
seukyaso marked this conversation as resolved.
1 change: 1 addition & 0 deletions pkg/diskapi/diskapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type CreateDiskRequest struct {
ZoneID string
TypeID string
Size int64
BlockSize int64
SnapshotID string
DiskPlacementPolicy *DiskPlacementPolicy
KMSKeyID string
Expand Down
1 change: 1 addition & 0 deletions pkg/diskapi/public/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (d *publicDiskAPI) CreateDisk(ctx context.Context, req *diskapi.CreateDiskR
Name: req.Name,
Labels: labels,
Size: req.Size,
BlockSize: req.BlockSize,
DiskPlacementPolicy: convertDiskPlacementPolicyToComputeAPI(req.DiskPlacementPolicy),
KmsKeyId: req.KMSKeyID,
},
Expand Down
11 changes: 11 additions & 0 deletions pkg/services/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,17 @@ func (c *controller) createNewVolume(

diskAPIRequest.TypeID = volumeTypeID

blockSizeStr := parameters["blockSize"]
Comment thread
seukyaso marked this conversation as resolved.
Outdated
if blockSizeStr != "" {
Comment thread
seukyaso marked this conversation as resolved.
blockSize, err := strconv.ParseInt(blockSizeStr, 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse blockSize: %w", err)
}
diskAPIRequest.BlockSize = blockSize
}

klog.Infof("blockSize: %d", diskAPIRequest.BlockSize)

size, err := getVolumeSize(req.GetCapacityRange())
if err != nil {
return nil, err
Expand Down
Loading