@@ -143,7 +143,7 @@ func (impl *FullModeDeploymentServiceImpl) UpdateAppGitOpsOperations(manifest *b
143143 gitHash , _ , valuesCommitErr = impl .gitOperationService .CommitValues (ctx , manifest .ValuesConfig )
144144 } else {
145145 cloneChartToGitRequest := adapter .ParseChartGitPushRequest (installAppVersionRequest , "" )
146- migrateDependencies , err := impl .shouldMigrateProxyChartDependencies (cloneChartToGitRequest )
146+ migrateDependencies , err := impl .shouldMigrateProxyChartDependencies (cloneChartToGitRequest , manifest . ChartMetaDataConfig . FileContent )
147147 if err != nil {
148148 impl .Logger .Errorw ("error in checking if proxy chart dependencies should be migrated" , "err" , err )
149149 return nil , err
@@ -427,7 +427,7 @@ func (impl *FullModeDeploymentServiceImpl) CreateArgoRepoSecretIfNeeded(appStore
427427 return nil
428428}
429429
430- func (impl * FullModeDeploymentServiceImpl ) shouldMigrateProxyChartDependencies (pushChartToGitRequest * gitBean.PushChartToGitRequestDTO ) (bool , error ) {
430+ func (impl * FullModeDeploymentServiceImpl ) shouldMigrateProxyChartDependencies (pushChartToGitRequest * gitBean.PushChartToGitRequestDTO , expectedChartYamlContent string ) (bool , error ) {
431431 clonedDir , err := impl .gitOperationService .CloneChartForHelmApp (pushChartToGitRequest .AppName , pushChartToGitRequest .RepoURL , pushChartToGitRequest .TargetRevision )
432432 if err != nil {
433433 impl .Logger .Errorw ("error in cloning chart for helm app" , "appName" , pushChartToGitRequest .AppName , "repoUrl" , pushChartToGitRequest .RepoURL , "err" , err )
@@ -436,14 +436,6 @@ func (impl *FullModeDeploymentServiceImpl) shouldMigrateProxyChartDependencies(p
436436 defer impl .chartTemplateService .CleanDir (clonedDir )
437437 gitOpsChartLocation := fmt .Sprintf ("%s-%s" , pushChartToGitRequest .AppName , pushChartToGitRequest .EnvName )
438438 dir := filepath .Join (clonedDir , gitOpsChartLocation )
439- requirementsYamlPath := filepath .Join (dir , appStoreBean .REQUIREMENTS_YAML_FILE )
440- if _ , err := os .Stat (requirementsYamlPath ); os .IsNotExist (err ) {
441- impl .Logger .Debugw ("requirements.yaml not found in cloned repo from git-ops, no migrations required" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName )
442- return false , nil
443- } else if err != nil {
444- impl .Logger .Errorw ("error in checking requirements.yaml file" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName , "err" , err )
445- return false , err
446- }
447439 chartYamlPath := filepath .Join (dir , chartRefBean .CHART_YAML_FILE )
448440 if _ , err := os .Stat (chartYamlPath ); os .IsNotExist (err ) {
449441 impl .Logger .Debugw ("chart.yaml not found in cloned repo from git-ops, no migrations required" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName )
@@ -452,28 +444,22 @@ func (impl *FullModeDeploymentServiceImpl) shouldMigrateProxyChartDependencies(p
452444 impl .Logger .Errorw ("error in checking chart.yaml file" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName , "err" , err )
453445 return false , err
454446 }
455- // load requirements.yaml file to check if it has dependencies
456- requirementsYamlContent , err := os .ReadFile (requirementsYamlPath )
457- if err != nil {
458- impl .Logger .Errorw ("error in reading requirements.yaml file" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName , "err" , err )
459- return false , err
460- }
461- dependencies := appStoreBean.Dependencies {}
462- requirementsJsonContent , err := yaml .YAMLToJSON (requirementsYamlContent )
447+ expectedChartMetaData := & chart.Metadata {}
448+ expectedChartJsonContent , err := yaml .YAMLToJSON ([]byte (expectedChartYamlContent ))
463449 if err != nil {
464450 impl .Logger .Errorw ("error in converting requirements.yaml to json" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName , "err" , err )
465451 return false , err
466452 }
467- err = json .Unmarshal (requirementsJsonContent , & dependencies )
453+ err = json .Unmarshal (expectedChartJsonContent , & expectedChartMetaData )
468454 if err != nil {
469455 impl .Logger .Errorw ("error in unmarshalling requirements.yaml file" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName , "err" , err )
470456 return false , err
471457 }
472- if len (dependencies .Dependencies ) == 0 {
458+ if len (expectedChartMetaData .Dependencies ) == 0 {
473459 impl .Logger .Debugw ("no dependencies found in requirements.yaml file" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName )
474460 return false , nil
475461 }
476- impl .Logger .Debugw ("dependencies found in requirements.yaml file" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName , "dependencies" , dependencies .Dependencies )
462+ impl .Logger .Debugw ("dependencies found in requirements.yaml file" , "appName" , pushChartToGitRequest .AppName , "envName" , pushChartToGitRequest .EnvName , "dependencies" , expectedChartMetaData .Dependencies )
477463 // check if chart.yaml file has dependencies
478464 chartYamlContent , err := os .ReadFile (chartYamlPath )
479465 if err != nil {
@@ -500,7 +486,7 @@ func (impl *FullModeDeploymentServiceImpl) shouldMigrateProxyChartDependencies(p
500486 latestDependencies := sliceUtil .NewMapFromFuncExec (chartMetadata .Dependencies , func (dependency * chart.Dependency ) string {
501487 return getUniqueKeyFromDependency (dependency )
502488 })
503- previousDependencies := sliceUtil .NewMapFromFuncExec (dependencies .Dependencies , func (dependency * chart.Dependency ) string {
489+ previousDependencies := sliceUtil .NewMapFromFuncExec (expectedChartMetaData .Dependencies , func (dependency * chart.Dependency ) string {
504490 return getUniqueKeyFromDependency (dependency )
505491 })
506492 for key := range latestDependencies {
0 commit comments