@@ -81,11 +81,13 @@ impl KubeResourceSeeker<'_> {
81
81
resource_types : Vec < TargetType > ,
82
82
operator_active : bool ,
83
83
) -> Result < Vec < String > > {
84
- let mut targets = vec ! [ ] ;
85
- for resource_type in resource_types {
86
- targets. extend ( self . filtered_single ( resource_type, operator_active) . await ?) ;
87
- }
88
- Ok ( targets)
84
+ Ok ( futures:: future:: try_join_all (
85
+ resource_types
86
+ . into_iter ( )
87
+ . map ( |resource_type| self . filtered_single ( resource_type, operator_active) ) ,
88
+ )
89
+ . await ?
90
+ . concat ( ) )
89
91
}
90
92
91
93
async fn filtered_single (
@@ -114,27 +116,11 @@ impl KubeResourceSeeker<'_> {
114
116
TargetType :: ReplicaSet if operator_active => {
115
117
self . simple_list_resource :: < ReplicaSet > ( "replicaset" ) . await
116
118
}
117
- TargetType :: Targetless => {
118
- tracing:: error!( "Cannot list targets with resource type 'targetless'" ) ;
119
- Err ( KubeApiError :: InvalidListTargetType (
120
- resource_type,
121
- "cannot list targets with resource type 'targetless'." . to_string ( ) ,
122
- ) )
123
- }
119
+ TargetType :: Targetless => Err ( KubeApiError :: InvalidTargetType ( resource_type) ) ,
124
120
resource_type if !operator_active => {
125
- tracing:: warn!( "Cannot list targets with resource type '{resource_type}' unless the operator is enabled." ) ;
126
- Err ( KubeApiError :: InvalidListTargetType (
127
- resource_type,
128
- "this type requires the operator to be enabled." . to_string ( ) ,
129
- ) )
130
- }
131
- resource_type => {
132
- tracing:: error!( "Cannot list targets with resource type '{resource_type}' due to a missing implementation. This is a bug." ) ;
133
- Err ( KubeApiError :: InvalidListTargetType (
134
- resource_type,
135
- "this type cannot be listed. This is a bug." . to_string ( ) ,
136
- ) )
121
+ Err ( KubeApiError :: TargetTypeRequiresOperator ( resource_type) )
137
122
}
123
+ resource_type => Err ( KubeApiError :: InvalidTargetTypeBug ( resource_type) ) ,
138
124
}
139
125
}
140
126
0 commit comments