@@ -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,31 @@ 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+ UpdatedSourceCount = updatedSourcesResults . Count ,
138+ TotalSourceCount = applicationFromYaml . Spec . Sources . Count ,
139+ MatchingSourceCount = applicationFromYaml . Spec . Sources . Count ( s => deploymentScope . Matches ( ScopingAnnotationReader . GetScopeForApplicationSource ( s . Name . ToApplicationSourceName ( ) , applicationFromYaml . Metadata . Annotations , containsMultipleSources ) ) ) ,
140+ GitReposUpdated = updatedSourcesResults . Select ( r => r . applicationSource . Source . RepoUrl . AbsoluteUri ) . ToHashSet ( ) ,
141+ UpdatedImages = updatedSourcesResults . SelectMany ( r => r . Updated ) . ToHashSet ( )
142+ } ;
144143 }
145144
146145 /// <returns>Images that were updated</returns>
@@ -468,6 +467,7 @@ RepositoryWrapper CreateRepository(Dictionary<string, GitCredentialDto> gitCrede
468467 return Update ( rootPath , imagesToUpdate , filesToUpdate , imageReplacerFactory ) ;
469468 }
470469
470+
471471 ( HashSet < string > , HashSet < string > ) UpdateKustomizeYaml ( string rootPath ,
472472 string subFolder ,
473473 string defaultRegistry ,
@@ -594,11 +594,11 @@ public ProcessApplicationResult(ApplicationName applicationName)
594594
595595 public int TotalSourceCount { get ; set ; }
596596 public int MatchingSourceCount { get ; set ; }
597- public int UpdatedSourceCount { get ; set ; }
598- public HashSet < string > GitReposUpdated { get ; } = new HashSet < string > ( ) ;
597+ public HashSet < string > GitReposUpdated { get ; set ; } = new HashSet < string > ( ) ;
599598 public ApplicationName ApplicationName { get ; }
600- public HashSet < string > UpdatedImages { get ; } = new HashSet < string > ( ) ;
599+ public HashSet < string > UpdatedImages { get ; set ; } = new HashSet < string > ( ) ;
601600
601+ public int UpdatedSourceCount { get ; set ; }
602602 public bool Updated => UpdatedSourceCount > 0 ;
603603 }
604604 }
0 commit comments