@@ -154,44 +154,39 @@ func getStorageContainer(
154154 return nil , fmt .Errorf ("failed to list storage containers: %w" , err )
155155 }
156156
157- switch resp .GetData ().(type ) {
157+ switch data := resp .GetData ().(type ) {
158158 case nil :
159159 return nil , fmt .Errorf ("failed to find a matching storage container" )
160160
161161 case clustermgmtv4errors.ErrorResponse :
162- errResp , ok := resp .GetData ().(clustermgmtv4errors.ErrorResponse )
163- if ! ok {
164- return nil , fmt .Errorf ("failed to parse error response from %v" , resp .GetData ())
165- }
166-
167- return nil , fmt .Errorf ("failed to list storage containers: %v" , errResp .GetError ())
162+ return nil , fmt .Errorf ("failed to list storage containers: %v" , data .GetError ())
168163
169164 case []clustermgmtv4.StorageContainer :
170- containers , ok := resp .GetData ().([]clustermgmtv4.StorageContainer )
171- if ! ok {
172- return nil , fmt .Errorf ("failed to parse storage containers from %v" , resp .GetData ())
173- }
174-
175- if len (containers ) == 0 {
165+ if len (data ) == 0 {
176166 return nil , fmt .Errorf (
177167 "no storage container named %q found on cluster named %q" ,
178168 storageContainerName ,
179169 * cluster .Name ,
180170 )
181171 }
182172
183- if len (containers ) > 1 {
173+ if len (data ) > 1 {
184174 return nil , fmt .Errorf (
185175 "multiple storage containers found with name %q on cluster %q" ,
186176 storageContainerName ,
187177 * cluster .Name ,
188178 )
189179 }
190180
191- return ptr .To (containers [0 ]), nil
181+ return ptr .To (data [0 ]), nil
182+ default :
183+ return nil ,
184+ fmt .Errorf (
185+ "unexpected response type from ListStorageContainers(filter=%q): %T" ,
186+ fltr ,
187+ resp .GetData (),
188+ )
192189 }
193-
194- return nil , fmt .Errorf ("unexpected response type from ListStorageContainers(filter=%q): %T" , fltr , resp .GetData ())
195190}
196191
197192func getCluster (
0 commit comments