From 2b342c1e76e7a8cd3f74c28fe6943bb258355764 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 8 Jun 2016 12:37:08 +0200 Subject: [PATCH] Add interface to abstract GCE volume operations. We want to write unit test with fake GCE. --- pkg/cloudprovider/providers/gce/gce.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/cloudprovider/providers/gce/gce.go b/pkg/cloudprovider/providers/gce/gce.go index 9acd412732f..223b56e1e83 100644 --- a/pkg/cloudprovider/providers/gce/gce.go +++ b/pkg/cloudprovider/providers/gce/gce.go @@ -100,6 +100,28 @@ type Config struct { } } +// Disks is interface for manipulation with GCE PDs. +type Disks interface { + // AttachDisk attaches given disk to given instance. Current instance + // is used when instanceID is empty string. + AttachDisk(diskName, instanceID string, readOnly bool) error + + // DetachDisk detaches given disk to given instance. Current instance + // is used when instanceID is empty string. + DetachDisk(devicePath, instanceID string) error + + // CreateDisk creates a new PD with given properties. Tags are serialized + // as JSON into Description field. + CreateDisk(name string, zone string, sizeGb int64, tags map[string]string) error + + // DeleteDisk deletes PD. + DeleteDisk(diskToDelete string) error + + // GetAutoLabelsForPD returns labels to apply to PeristentVolume + // representing this PD, namely failure domain and zone. + GetAutoLabelsForPD(name string) (map[string]string, error) +} + type instRefSlice []*compute.InstanceReference func (p instRefSlice) Len() int { return len(p) }