99 "time"
1010
1111 "github.com/argoproj-labs/argocd-image-updater/pkg/common"
12+ "github.com/argoproj-labs/argocd-image-updater/pkg/env"
1213 "github.com/argoproj-labs/argocd-image-updater/pkg/image"
1314 "github.com/argoproj-labs/argocd-image-updater/pkg/kube"
1415 "github.com/argoproj-labs/argocd-image-updater/pkg/log"
@@ -31,7 +32,7 @@ func (client *k8sClient) GetApplication(ctx context.Context, appName string) (*v
3132 log .Debugf ("Getting application %s across all namespaces" , appName )
3233
3334 // List all applications across all namespaces (using empty labelSelector)
34- appList , err := client .ListApplications ("" )
35+ appList , err := client .ListApplications (v1 . NamespaceAll )
3536 if err != nil {
3637 return nil , fmt .Errorf ("error listing applications: %w" , err )
3738 }
@@ -44,7 +45,7 @@ func (client *k8sClient) GetApplication(ctx context.Context, appName string) (*v
4445 }
4546
4647 // 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
4849}
4950
5051// ListApplications lists all applications across all namespaces.
@@ -85,13 +86,7 @@ func (client *k8sClient) UpdateSpec(ctx context.Context, spec *application.Appli
8586 const baseDelay = 100 * time .Millisecond // Initial delay before retrying
8687
8788 // 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 )
9590
9691 for attempts := 0 ; attempts < maxRetries ; attempts ++ {
9792 app , err := client .GetApplication (ctx , spec .GetName ())
0 commit comments