@@ -96,20 +96,13 @@ ProcessApplicationResult ProcessApplication(ArgoCDApplicationDto application,
9696 UpdateArgoCDAppDeploymentConfig deploymentConfig )
9797 {
9898 log . InfoFormat ( "Processing application {0}" , application . Name ) ;
99-
100- var result = new ProcessApplicationResult ( application . Name . ToApplicationName ( ) ) ;
101-
10299 var applicationFromYaml = argoCdApplicationManifestParser . ParseManifest ( application . Manifest ) ;
103-
100+ var containsMultipleSources = applicationFromYaml . Spec . Sources . Count > 1 ;
101+ var applicationName = applicationFromYaml . Metadata . Name ;
102+
104103 var validationResult = ApplicationValidator . Validate ( applicationFromYaml ) ;
105104 validationResult . Action ( log ) ;
106105
107- var containsMultipleSources = applicationFromYaml . Spec . Sources . Count > 1 ;
108-
109- result . TotalSourceCount = applicationFromYaml . Spec . Sources . Count ;
110-
111- result . MatchingSourceCount = applicationFromYaml . Spec . Sources . Count ( s => deploymentScope . Matches ( ScopingAnnotationReader . GetScopeForApplicationSource ( s . Name . ToApplicationSourceName ( ) , applicationFromYaml . Metadata . Annotations , containsMultipleSources ) ) ) ;
112-
113106 var updatedSourcesResults = applicationFromYaml . GetSourcesWithMetadata ( )
114107 . Select ( applicationSource => new
115108 {
@@ -122,25 +115,30 @@ ProcessApplicationResult ProcessApplication(ArgoCDApplicationDto application,
122115 deploymentConfig ,
123116 application . DefaultRegistry ) ,
124117 applicationSource ,
125- } ) . Where ( r => r . Updated . Any ( ) ) . ToList ( ) ;
118+ } )
119+ . Where ( r => r . Updated . Any ( ) )
120+ . ToList ( ) ;
126121
127- result . UpdatedSourceCount = updatedSourcesResults . Count ;
128- result . GitReposUpdated . AddRange ( updatedSourcesResults . Select ( r => r . applicationSource . Source . RepoUrl . AbsoluteUri ) ) ;
129- result . UpdatedImages . AddRange ( updatedSourcesResults . SelectMany ( r => r . Updated ) ) ;
130122
131123 //if we have links, use that to generate a link, otherwise just put the name there
132124 var instanceLinks = application . InstanceWebUiUrl != null ? new ArgoCDInstanceLinks ( application . InstanceWebUiUrl ) : null ;
133125 var linkifiedAppName = instanceLinks != null
134- ? log . FormatLink ( instanceLinks . ApplicationDetails ( application . Name , application . KubernetesNamespace ) , application . Name )
135- : application . Name ;
126+ ? log . FormatLink ( instanceLinks . ApplicationDetails ( applicationName , application . KubernetesNamespace ) , applicationName )
127+ : applicationName ;
136128
137129 var message = updatedSourcesResults . Any ( )
138130 ? "Updated Application {0}"
139131 : "Nothing to update for Application {0}" ;
140132
141133 log . InfoFormat ( message , linkifiedAppName ) ;
142134
143- return result ;
135+ return new ProcessApplicationResult ( applicationName . ToApplicationName ( ) )
136+ {
137+ TotalSourceCount = applicationFromYaml . Spec . Sources . Count ,
138+ MatchingSourceCount = applicationFromYaml . Spec . Sources . Count ( s => deploymentScope . Matches ( ScopingAnnotationReader . GetScopeForApplicationSource ( s . Name . ToApplicationSourceName ( ) , applicationFromYaml . Metadata . Annotations , containsMultipleSources ) ) ) ,
139+ GitReposUpdated = updatedSourcesResults . Select ( r => r . applicationSource . Source . RepoUrl . AbsoluteUri ) . ToHashSet ( ) ,
140+ UpdatedImages = updatedSourcesResults . SelectMany ( r => r . Updated ) . ToHashSet ( )
141+ } ;
144142 }
145143
146144 /// <returns>Images that were updated</returns>
@@ -468,6 +466,7 @@ RepositoryWrapper CreateRepository(Dictionary<string, GitCredentialDto> gitCrede
468466 return Update ( rootPath , imagesToUpdate , filesToUpdate , imageReplacerFactory ) ;
469467 }
470468
469+
471470 ( HashSet < string > , HashSet < string > ) UpdateKustomizeYaml ( string rootPath ,
472471 string subFolder ,
473472 string defaultRegistry ,
@@ -594,11 +593,11 @@ public ProcessApplicationResult(ApplicationName applicationName)
594593
595594 public int TotalSourceCount { get ; set ; }
596595 public int MatchingSourceCount { get ; set ; }
597- public int UpdatedSourceCount { get ; set ; }
598- public HashSet < string > GitReposUpdated { get ; } = new HashSet < string > ( ) ;
596+ public HashSet < string > GitReposUpdated { get ; set ; } = new HashSet < string > ( ) ;
599597 public ApplicationName ApplicationName { get ; }
600- public HashSet < string > UpdatedImages { get ; } = new HashSet < string > ( ) ;
598+ public HashSet < string > UpdatedImages { get ; set ; } = new HashSet < string > ( ) ;
601599
600+ public int UpdatedSourceCount => GitReposUpdated . Count ;
602601 public bool Updated => UpdatedSourceCount > 0 ;
603602 }
604603 }
0 commit comments