@@ -62,39 +62,36 @@ func NewHighLevelClient(options ...lapi.Option) (*HighLevelClient, error) {
62
62
// GenericAccessibleTopologies returns topologies based on linstor storage pools
63
63
// and whether a resource is allowed to be accessed over the network.
64
64
func (c * HighLevelClient ) GenericAccessibleTopologies (ctx context.Context , volId string , remoteAccessPolicy volume.RemoteAccessPolicy , params * volume.AccessibleTopologiesParams ) ([]* csi.Topology , error ) {
65
- var zones , nodeNames []string
66
- var volumeAccess , topology string
67
-
68
- if params != nil {
69
- zones = params .SCZones
70
- volumeAccess = params .SCVolumeAccess
71
- topology = params .SCTopology
65
+ if params == nil {
66
+ return nil , fmt .Errorf ("params must not be nil" )
72
67
}
73
68
74
69
r , err := c .Resources .GetAll (ctx , volId )
75
70
if err != nil {
76
71
return nil , fmt .Errorf ("unable to determine AccessibleTopologies: %v" , err )
77
72
}
78
-
79
- switch volumeAccess {
73
+
74
+ var nodeNames []string
75
+ switch params .SCVolumeAccess {
80
76
case "PreferablyLocal" , "EventuallyLocal" , "Any" :
81
- if topology == "TransZonal" {
82
- res := make ([]* csi.Topology , len (zones ))
83
- for i , zone := range zones {
77
+ switch params .SCTopology {
78
+ case "TransZonal" :
79
+ res := make ([]* csi.Topology , len (params .SCZones ))
80
+ for i , zone := range params .SCZones {
84
81
res [i ] = & csi.Topology {Segments : map [string ]string {"topology.kubernetes.io/zone" : zone }}
85
82
}
86
83
return res , nil
87
- }
88
- if topology == "Zonal" {
84
+ case "Zonal" :
89
85
nodeNames = util .DeployedDiskfullyNodes (r )
90
- }
91
- if topology == "Ignored" {
86
+ case "Ignored" :
92
87
return []* csi.Topology {}, nil
88
+ default :
89
+ return nil , fmt .Errorf ("invalid topology: %s" , params .SCTopology )
93
90
}
94
91
case "Local" :
95
92
nodeNames = util .DeployedDiskfullyNodes (r )
96
93
default :
97
- return nil , fmt .Errorf ("invalid volume access policy: %s" , volumeAccess )
94
+ return nil , fmt .Errorf ("invalid volume access policy: %s" , params . SCVolumeAccess )
98
95
}
99
96
100
97
nodes , err := c .Nodes .GetAll (ctx , & lapi.ListOpts {Node : nodeNames })
0 commit comments