@@ -20,6 +20,7 @@ import (
2020 "net/url"
2121 "strings"
2222
23+ aputil "github.com/argoproj-labs/argocd-autopilot/pkg/util"
2324 argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
2425 "github.com/codefresh-io/cli-v2/pkg/log"
2526 "github.com/codefresh-io/cli-v2/pkg/store"
@@ -134,14 +135,18 @@ func runHelmMigrate(ctx context.Context, opts *MigrateOptions) error {
134135 }
135136
136137 log .G (ctx ).Infof ("Cloned installation repo %q" , * runtime .Repo )
138+ destFs := apfs .Create (memfs .New ())
139+ if isSharedConfigInInstallationRepo (user .ActiveAccount .SharedConfigRepo , runtime .Repo ) {
140+ destFs = opts .cloneOpts .FS
141+ }
137142 destCloneOpts := & apgit.CloneOptions {
138143 Provider : user .ActiveAccount .GitProvider .String (),
139144 Repo : * user .ActiveAccount .SharedConfigRepo ,
140145 Auth : opts .cloneOpts .Auth ,
141- FS : apfs . Create ( memfs . New ()) ,
146+ FS : destFs ,
142147 }
143148 destCloneOpts .Parse ()
144- destRepo , destFs , err : = destCloneOpts .GetRepo (ctx )
149+ _ , destFs , err = destCloneOpts .GetRepo (ctx )
145150 if err != nil {
146151 return fmt .Errorf ("failed getting shared config repo: %w" , err )
147152 }
@@ -171,15 +176,20 @@ func runHelmMigrate(ctx context.Context, opts *MigrateOptions) error {
171176 return fmt .Errorf ("failed pushing changes to installation repo: %w" , err )
172177 }
173178
174- log .G (ctx ).Infof ("Pushed changes to installation repo %q, sha: %s" , * user .ActiveAccount .SharedConfigRepo , sha )
179+ log .G (ctx ).Infof ("Pushed changes to installation repo %q, sha: %s" , * runtime .Repo , sha )
180+
181+ destRepo , _ , err := destCloneOpts .GetRepo (ctx )
182+ if err != nil {
183+ return fmt .Errorf ("failed getting shared config repo: %w" , err )
184+ }
175185 sha , err = destRepo .Persist (ctx , & apgit.PushOptions {
176186 CommitMsg : "moved resources from installation repo" ,
177187 })
178188 if err != nil {
179189 return fmt .Errorf ("failed pushing changes to internal-shared-config repo: %w" , err )
180190 }
181191
182- log .G (ctx ).Infof ("Pushed changes to shared-config-repo %q, sha: %s" , * runtime . Repo , sha )
192+ log .G (ctx ).Infof ("Pushed changes to shared-config-repo %q, sha: %s" , * user . ActiveAccount . SharedConfigRepo , sha )
183193 log .G (ctx ).Infof ("Done migrating resources from %q to %q" , * runtime .Repo , * user .ActiveAccount .SharedConfigRepo )
184194
185195 err = removeFromCluster (ctx , opts .helmReleaseName , * runtime .Metadata .Namespace , opts .kubeContext , srcCloneOpts , opts .kubeFactory )
@@ -631,3 +641,10 @@ func filterStatus(manifest []byte) []byte {
631641
632642 return []byte (strings .Join (res , "\n " ))
633643}
644+
645+ func isSharedConfigInInstallationRepo (iscRepo , installationRepo * string ) bool {
646+ iscRepoHost , _ , _ , _ , _ , _ , _ := aputil .ParseGitUrl (* iscRepo )
647+ installationRepoHost , _ , _ , _ , _ , _ , _ := aputil .ParseGitUrl (* installationRepo )
648+
649+ return iscRepoHost == installationRepoHost
650+ }
0 commit comments