From 63ac16c06307a59adca4da27ea2408de30050b50 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 16 Jan 2023 22:19:42 +0100 Subject: Add util-check for dataLocality and use it --- pkg/driver/utils.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkg/driver/utils.go') diff --git a/pkg/driver/utils.go b/pkg/driver/utils.go index b629543..e103079 100644 --- a/pkg/driver/utils.go +++ b/pkg/driver/utils.go @@ -8,6 +8,7 @@ import ( "sync" "github.com/container-storage-interface/spec/lib/go/csi" + "github.com/seaweedfs/seaweedfs-csi-driver/pkg/datalocality" "github.com/seaweedfs/seaweedfs/weed/glog" "golang.org/x/net/context" "google.golang.org/grpc" @@ -121,3 +122,10 @@ func (km *KeyMutex) GetMutex(key string) *sync.Mutex { func (km *KeyMutex) RemoveMutex(key string) { km.mutexes.Delete(key) } + +func CheckDataLocality(dataLocality *datalocality.DataLocality, dataCenter *string) error { + if(*dataLocality != datalocality.None && *dataCenter == ""){ + return fmt.Errorf("dataLocality set, but not all locality-definitions were set") + } + return nil +} -- cgit v1.2.3