@@ -22,8 +22,35 @@ export class ArgoCDClient {
22
22
}
23
23
24
24
public async listApplications ( params ?: { search ?: string } ) {
25
- const { body } = await this . client . get < V1alpha1ApplicationList > ( `/api/v1/applications` , params ) ;
26
- return body ;
25
+ const { body } = await this . client . get < V1alpha1ApplicationList > ( `/api/v1/applications` ) ;
26
+
27
+ // If no search parameter, return all applications with filtered fields
28
+ const filteredItems = body . items ?. map ( ( app ) => ( {
29
+ metadata : {
30
+ name : app . metadata ?. name ,
31
+ namespace : app . metadata ?. namespace ,
32
+ labels : app . metadata ?. labels
33
+ } ,
34
+ status : {
35
+ health : app . status ?. health ,
36
+ sync : app . status ?. sync
37
+ }
38
+ } ) ) || [ ] ;
39
+
40
+ if ( ! params ?. search ) {
41
+ return { items : filteredItems } ;
42
+ }
43
+
44
+ // Full-text search across filtered fields and subfields
45
+ const searchTerm = params . search . toLowerCase ( ) ;
46
+
47
+ const searchMatches = filteredItems . filter ( ( app ) => {
48
+ // Convert the filtered app object to a string for full-text search
49
+ const searchableContent = JSON . stringify ( app ) . toLowerCase ( ) ;
50
+ return searchableContent . includes ( searchTerm ) ;
51
+ } ) ;
52
+
53
+ return { items : searchMatches } ;
27
54
}
28
55
29
56
public async getApplication ( applicationName : string ) {
@@ -107,21 +134,29 @@ export class ArgoCDClient {
107
134
public async getWorkloadLogs (
108
135
applicationName : string ,
109
136
applicationNamespace : string ,
110
- resourceRef : V1alpha1ResourceResult
137
+ resourceRef : V1alpha1ResourceResult ,
138
+ container ?: string ,
139
+ tailLines ?: number
111
140
) {
112
141
const logs : ApplicationLogEntry [ ] = [ ] ;
142
+ const params : any = {
143
+ appNamespace : applicationNamespace ,
144
+ namespace : resourceRef . namespace ,
145
+ resourceName : resourceRef . name ,
146
+ group : resourceRef . group ,
147
+ kind : resourceRef . kind ,
148
+ version : resourceRef . version ,
149
+ follow : false ,
150
+ tailLines : tailLines ?? 100
151
+ } ;
152
+
153
+ if ( container ) {
154
+ params . container = container ;
155
+ }
156
+
113
157
await this . client . getStream < ApplicationLogEntry > (
114
158
`/api/v1/applications/${ applicationName } /logs` ,
115
- {
116
- appNamespace : applicationNamespace ,
117
- namespace : resourceRef . namespace ,
118
- resourceName : resourceRef . name ,
119
- group : resourceRef . group ,
120
- kind : resourceRef . kind ,
121
- version : resourceRef . version ,
122
- follow : false ,
123
- tailLines : 100
124
- } ,
159
+ params ,
125
160
( chunk ) => logs . push ( chunk )
126
161
) ;
127
162
return logs ;
0 commit comments