File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,16 @@ type k8sClient struct {
29
29
appNamespace * string
30
30
}
31
31
32
- // GetApplication retrieves an application by name across all namespaces.
32
+ // GetApplication retrieves an application by name, either in a specific namespace or all namespaces depending on client configuration .
33
33
func (client * k8sClient ) GetApplication (ctx context.Context , appName string ) (* v1alpha1.Application , error ) {
34
34
// List all applications across configured namespace or all namespaces (using empty labelSelector)
35
+ if * client .appNamespace != v1 .NamespaceAll {
36
+ return client .kubeClient .ApplicationsClientset .ArgoprojV1alpha1 ().Applications (* client .appNamespace ).Get (ctx , appName , v1.GetOptions {})
37
+ }
38
+ return client .getApplicationInAllNamespaces (ctx , appName )
39
+ }
40
+
41
+ func (client * k8sClient ) getApplicationInAllNamespaces (ctx context.Context , appName string ) (* v1alpha1.Application , error ) {
35
42
appList , err := client .ListApplications ("" )
36
43
if err != nil {
37
44
return nil , fmt .Errorf ("error listing applications: %w" , err )
You can’t perform that action at this time.
0 commit comments