9
9
"time"
10
10
11
11
"github.com/argoproj-labs/argocd-image-updater/pkg/common"
12
+ "github.com/argoproj-labs/argocd-image-updater/pkg/env"
12
13
"github.com/argoproj-labs/argocd-image-updater/pkg/image"
13
14
"github.com/argoproj-labs/argocd-image-updater/pkg/kube"
14
15
"github.com/argoproj-labs/argocd-image-updater/pkg/log"
@@ -31,7 +32,7 @@ func (client *k8sClient) GetApplication(ctx context.Context, appName string) (*v
31
32
log .Debugf ("Getting application %s across all namespaces" , appName )
32
33
33
34
// List all applications across all namespaces (using empty labelSelector)
34
- appList , err := client .ListApplications ("" )
35
+ appList , err := client .ListApplications (v1 . NamespaceAll )
35
36
if err != nil {
36
37
return nil , fmt .Errorf ("error listing applications: %w" , err )
37
38
}
@@ -44,7 +45,7 @@ func (client *k8sClient) GetApplication(ctx context.Context, appName string) (*v
44
45
}
45
46
46
47
// Retrieve the application in the specified namespace
47
- return client . kubeClient . ApplicationsClientset . ArgoprojV1alpha1 (). Applications ( app . Namespace ). Get ( ctx , app . Name , v1. GetOptions {})
48
+ return app , nil
48
49
}
49
50
50
51
// ListApplications lists all applications across all namespaces.
@@ -85,13 +86,7 @@ func (client *k8sClient) UpdateSpec(ctx context.Context, spec *application.Appli
85
86
const baseDelay = 100 * time .Millisecond // Initial delay before retrying
86
87
87
88
// Allow overriding max retries for testing purposes
88
- maxRetries := defaultMaxRetries
89
- if overrideRetries , ok := os .LookupEnv ("OVERRIDE_MAX_RETRIES" ); ok {
90
- var retries int
91
- if _ , err := fmt .Sscanf (overrideRetries , "%d" , & retries ); err == nil {
92
- maxRetries = retries
93
- }
94
- }
89
+ maxRetries := env .ParseNumFromEnv ("OVERRIDE_MAX_RETRIES" , defaultMaxRetries , 0 , 100 )
95
90
96
91
for attempts := 0 ; attempts < maxRetries ; attempts ++ {
97
92
app , err := client .GetApplication (ctx , spec .GetName ())
0 commit comments