Skip to content

Commit c224982

Browse files
authored
Merge pull request #50 from civo/provision-volumes-as-cluster-type
provision volumes using the volume type of the cluster
2 parents 677a3ef + aa8a5c8 commit c224982

5 files changed

Lines changed: 19 additions & 8 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.1
44

55
require (
66
github.com/BurntSushi/toml v0.3.1
7-
github.com/civo/civogo v0.3.92
7+
github.com/civo/civogo v0.6.3
88
github.com/container-storage-interface/spec v1.6.0
99
github.com/golang/protobuf v1.5.4
1010
github.com/joho/godotenv v1.4.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
1414
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
1515
github.com/civo/civogo v0.3.92 h1:fiA9nsyvEU9vVwA8ssIDSGt6gsWs6meqgaKrimAEaI0=
1616
github.com/civo/civogo v0.3.92/go.mod h1:7UCYX+qeeJbrG55E1huv+0ySxcHTqq/26FcHLVelQJM=
17+
github.com/civo/civogo v0.6.3 h1:AgTJa2C8Q6q+vFfsaa41vVZBQXVOiUdb/JbWpNuDlc8=
18+
github.com/civo/civogo v0.6.3/go.mod h1:LaEbkszc+9nXSh4YNG0sYXFGYqdQFmXXzQg0gESs2hc=
1719
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
1820
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
1921
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ func main() {
3939

4040
log.Info().Interface("d", d).Msg("Created a new driver")
4141

42+
log.Debug().Msg("Determining volumeType of cluster")
43+
cluster, err := d.CivoClient.GetKubernetesCluster(d.ClusterID)
44+
if err != nil {
45+
log.Fatal().Err(err)
46+
}
47+
d.ClusterVolumeType = cluster.VolumeType
48+
4249
ctx, cancel := context.WithCancel(context.Background())
4350
defer cancel()
4451

pkg/driver/controller_server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
135135
Namespace: d.Namespace,
136136
ClusterID: d.ClusterID,
137137
SizeGigabytes: int(desiredSize),
138+
VolumeType: d.ClusterVolumeType,
138139
// SnapshotID: snapshotID, // TODO: Uncomment after client implementation is complete.
139140
}
140141
log.Debug().Msg("Creating volume in Civo API")

pkg/driver/driver.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ type Driver struct {
3535
DiskHotPlugger DiskHotPlugger
3636
controller bool
3737
SocketFilename string
38-
NodeInstanceID string
39-
Region string
40-
Namespace string
41-
ClusterID string
42-
TestMode bool
43-
grpcServer *grpc.Server
38+
// NodeInstanceID string
39+
Region string
40+
Namespace string
41+
ClusterID string
42+
TestMode bool
43+
grpcServer *grpc.Server
44+
ClusterVolumeType string
4445
}
4546

4647
// NewDriver returns a CSI driver that implements gRPC endpoints for CSI
@@ -94,7 +95,7 @@ func NewTestDriver(fc *civogo.FakeClient) (*Driver, error) {
9495

9596
d.DiskHotPlugger = &FakeDiskHotPlugger{}
9697
d.TestMode = true // Just stops so much logging out of failures, as they are often expected during the tests
97-
98+
d.ClusterVolumeType = "standard"
9899
zerolog.SetGlobalLevel(zerolog.PanicLevel)
99100

100101
return d, err

0 commit comments

Comments
 (0)