Skip to content

Commit 6231805

Browse files
author
anmokretsov
committed
Add support for new field 'kmsKeyID'
1 parent 06adf17 commit 6231805

File tree

1,501 files changed

+250087
-85762
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,501 files changed

+250087
-85762
lines changed

go.mod

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ go 1.21
44

55
require (
66
github.com/container-storage-interface/spec v1.8.0
7-
github.com/google/uuid v1.4.0
7+
github.com/google/uuid v1.6.0
88
github.com/kubernetes-csi/csi-test/v4 v4.4.0
99
github.com/mitchellh/go-testing-interface v1.14.1
1010
github.com/onsi/ginkgo v1.16.5
1111
github.com/onsi/gomega v1.30.0
12-
github.com/stretchr/testify v1.8.4
13-
github.com/yandex-cloud/go-genproto v0.0.0-20231204110853-8db1d6a6f340
14-
github.com/yandex-cloud/go-sdk v0.0.0-20231204111359-25f2607c41ac
15-
golang.org/x/net v0.19.0
16-
google.golang.org/grpc v1.59.0
17-
google.golang.org/protobuf v1.31.0
12+
github.com/stretchr/testify v1.9.0
13+
github.com/yandex-cloud/go-genproto v0.0.0-20250304111827-f558b88ff434
14+
github.com/yandex-cloud/go-sdk v0.0.0-20250304120247-c2605c41f59f
15+
golang.org/x/net v0.28.0
16+
google.golang.org/grpc v1.66.2
17+
google.golang.org/protobuf v1.34.2
1818
k8s.io/apimachinery v0.28.4
1919
k8s.io/klog v1.0.0
2020
k8s.io/kubernetes v1.28.4
@@ -28,21 +28,21 @@ require (
2828
github.com/ghodss/yaml v1.0.0 // indirect
2929
github.com/go-logr/logr v1.2.4 // indirect
3030
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
31-
github.com/golang/protobuf v1.5.3 // indirect
31+
github.com/golang/protobuf v1.5.4 // indirect
3232
github.com/google/go-cmp v0.6.0 // indirect
3333
github.com/hashicorp/errwrap v1.0.0 // indirect
34-
github.com/hashicorp/go-multierror v1.0.0 // indirect
34+
github.com/hashicorp/go-multierror v1.1.1 // indirect
3535
github.com/kr/text v0.2.0 // indirect
3636
github.com/moby/sys/mountinfo v0.6.2 // indirect
3737
github.com/nxadm/tail v1.4.8 // indirect
3838
github.com/opencontainers/selinux v1.10.0 // indirect
3939
github.com/pmezard/go-difflib v1.0.0 // indirect
40-
github.com/stretchr/objx v0.5.0 // indirect
41-
golang.org/x/sys v0.15.0 // indirect
42-
golang.org/x/text v0.14.0 // indirect
43-
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
44-
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
45-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
40+
github.com/stretchr/objx v0.5.2 // indirect
41+
golang.org/x/sys v0.24.0 // indirect
42+
golang.org/x/text v0.17.0 // indirect
43+
google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 // indirect
44+
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
45+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
4646
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
4747
gopkg.in/yaml.v2 v2.4.0 // indirect
4848
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 32 additions & 50 deletions
Large diffs are not rendered by default.

pkg/diskapi/diskapi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type CreateDiskRequest struct {
7272
Size int64
7373
SnapshotID string
7474
DiskPlacementPolicy *DiskPlacementPolicy
75+
KMSKeyID string
7576
}
7677

7778
type DiskPlacementPolicy struct {

pkg/diskapi/public/public.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1"
2323
ycsdk "github.com/yandex-cloud/go-sdk"
24+
2425
"github.com/yandex-cloud/yc-csi-driver/pkg/diskapi"
2526

2627
"golang.org/x/net/context"
@@ -83,6 +84,7 @@ func (d *publicDiskAPI) CreateDisk(ctx context.Context, req *diskapi.CreateDiskR
8384
Labels: labels,
8485
Size: req.Size,
8586
DiskPlacementPolicy: convertDiskPlacementPolicyToComputeAPI(req.DiskPlacementPolicy),
87+
KmsKeyId: req.KMSKeyID,
8688
},
8789
),
8890
)

pkg/diskapi/public/public_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131

3232
"github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1"
3333
ycsdk "github.com/yandex-cloud/go-sdk"
34+
3435
"github.com/yandex-cloud/yc-csi-driver/pkg/diskapi"
3536
"github.com/yandex-cloud/yc-csi-driver/pkg/inflight"
3637
"github.com/yandex-cloud/yc-csi-driver/pkg/services"
@@ -43,6 +44,7 @@ const (
4344
diskName = "NewVolume"
4445
diskTypeID = "mytype"
4546
instanceID = "NewInstance"
47+
kmsKeyID = "kms-key-id"
4648
defaultDiskSizeBytes = 4 * 1024 * 1024 * 1024
4749
)
4850

@@ -57,6 +59,7 @@ type testResources struct {
5759
diskName string
5860
testData *testData
5961
defaultDiskSizeBytes int64
62+
kmsKeyID string
6063
}
6164

6265
type controllerTest struct {
@@ -73,10 +76,11 @@ func TestCreateDisk(t *testing.T) {
7376
disk, err := test.diskapi.CreateDisk(
7477
context.Background(),
7578
&diskapi.CreateDiskRequest{
76-
Name: test.cloudRes.diskName,
77-
ZoneID: test.cloudRes.zoneID,
78-
TypeID: test.cloudRes.diskTypeID,
79-
Size: test.cloudRes.defaultDiskSizeBytes,
79+
Name: test.cloudRes.diskName,
80+
ZoneID: test.cloudRes.zoneID,
81+
TypeID: test.cloudRes.diskTypeID,
82+
Size: test.cloudRes.defaultDiskSizeBytes,
83+
KMSKeyID: test.cloudRes.kmsKeyID,
8084
})
8185
require.NoError(t, err)
8286
assert.Equal(t, disk.Name, test.cloudRes.diskName)
@@ -337,6 +341,7 @@ func initializeTest(t *testing.T) *controllerTest {
337341
diskTypeID: diskTypeID,
338342
diskName: diskName,
339343
defaultDiskSizeBytes: defaultDiskSizeBytes,
344+
kmsKeyID: kmsKeyID,
340345
testData: &testData{disk: []*compute.Disk{}, instance: []*compute.Instance{}},
341346
},
342347
}

pkg/diskapi/public/testutil_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929

3030
"github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1"
3131
pubOperation "github.com/yandex-cloud/go-genproto/yandex/cloud/operation"
32+
3233
"github.com/yandex-cloud/yc-csi-driver/pkg/testutil/pubapimock"
3334
)
3435

@@ -48,6 +49,9 @@ func diskCreateMock(api *pubapimock.API, folderID string, testData *testData) {
4849
TypeId: req.GetTypeId(),
4950
ZoneId: req.GetZoneId(),
5051
Size: req.GetSize(),
52+
KmsKey: &compute.KMSKey{
53+
KeyId: req.GetKmsKeyId(),
54+
},
5155
}
5256
testData.disk = append(testData.disk, disk)
5357
return successOperation(disk)

pkg/services/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const (
3535

3636
DiskPlacementGroupIDKey = "diskPlacementGroupId"
3737
DiskPlacementGroupPartitionKey = "diskPlacementGroupPartition"
38+
39+
KMSKeyIDKey = "kmsKeyId"
3840
)
3941

4042
var (

pkg/services/controller/controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@ func (c *controller) createNewVolume(
612612

613613
diskAPIRequest.DiskPlacementPolicy = diskPlacementPolicy
614614

615+
if kmsKeyID, ok := parameters[services.KMSKeyIDKey]; ok {
616+
diskAPIRequest.KMSKeyID = kmsKeyID
617+
}
618+
615619
disk, err := c.diskAPI.CreateDisk(
616620
ctx,
617621
diskAPIRequest,

pkg/testutil/pubapimock/mock/computemocks/disk_service_server.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/testutil/pubapimock/mock/computemocks/instance_service_server.go

Lines changed: 178 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)