@@ -70,6 +70,13 @@ func CompareGeneratedAssets(repoFs billy.Filesystem, u options.UpstreamOptions,
7070 ModifiedPostRelease : options.ReleaseOptions {},
7171 RemovedPostRelease : options.ReleaseOptions {},
7272 }
73+
74+ // Initialize lifecycle package for validating with assets lifecycle rules
75+ lifeCycleDep , err := lifecycle .InitDependencies (repoFs , lifecycle .ExtractBranchVersion (branch ), "" , false )
76+ if err != nil {
77+ logrus .Fatalf ("encountered error while initializing dependencies for lifecycle-assets-clean: %s" , err )
78+ }
79+
7380 // Pull repository
7481 logrus .Infof ("Pulling upstream repository %s at branch %s" , u .URL , branch )
7582 releasedChartsRepoBranch , err := puller .GetGithubRepository (u , & branch )
@@ -89,7 +96,7 @@ func CompareGeneratedAssets(repoFs billy.Filesystem, u options.UpstreamOptions,
8996 if err := standardize .RestructureChartsAndAssets (releaseFs ); err != nil {
9097 return response , fmt .Errorf ("failed to standardize upstream: %s" , err )
9198 }
92- // TODO: Add a check bypass here, all assets that do not belong on this lifecycle should be skipped
99+
93100 // Walk through directories and execute release logic
94101 localOnly := func (fs billy.Filesystem , localPath string , isDir bool ) error {
95102 if isDir {
@@ -113,7 +120,12 @@ func CompareGeneratedAssets(repoFs billy.Filesystem, u options.UpstreamOptions,
113120 }
114121 // Chart exists in local and is not tracked by release.yaml
115122 logrus .Infof ("%s/%s is untracked" , chart .Metadata .Name , chart .Metadata .Version )
116- response .UntrackedInRelease = response .UntrackedInRelease .Append (chart .Metadata .Name , chart .Metadata .Version )
123+ // If the chart exists in local and not on the upstream it may have been removed by the lifecycle rules
124+ isVersionInLifecycle := lifeCycleDep .VR .CheckChartVersionForLifecycle (chart .Metadata .Version )
125+ if isVersionInLifecycle {
126+ // this chart should not be removed
127+ response .UntrackedInRelease = response .UntrackedInRelease .Append (chart .Metadata .Name , chart .Metadata .Version )
128+ }
117129 return nil
118130 }
119131
0 commit comments