@@ -20,6 +20,7 @@ import (
20
20
"net/url"
21
21
"strings"
22
22
23
+ aputil "github.com/argoproj-labs/argocd-autopilot/pkg/util"
23
24
argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
24
25
"github.com/codefresh-io/cli-v2/pkg/log"
25
26
"github.com/codefresh-io/cli-v2/pkg/store"
@@ -134,14 +135,18 @@ func runHelmMigrate(ctx context.Context, opts *MigrateOptions) error {
134
135
}
135
136
136
137
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
+ }
137
142
destCloneOpts := & apgit.CloneOptions {
138
143
Provider : user .ActiveAccount .GitProvider .String (),
139
144
Repo : * user .ActiveAccount .SharedConfigRepo ,
140
145
Auth : opts .cloneOpts .Auth ,
141
- FS : apfs . Create ( memfs . New ()) ,
146
+ FS : destFs ,
142
147
}
143
148
destCloneOpts .Parse ()
144
- destRepo , destFs , err : = destCloneOpts .GetRepo (ctx )
149
+ _ , destFs , err = destCloneOpts .GetRepo (ctx )
145
150
if err != nil {
146
151
return fmt .Errorf ("failed getting shared config repo: %w" , err )
147
152
}
@@ -171,15 +176,20 @@ func runHelmMigrate(ctx context.Context, opts *MigrateOptions) error {
171
176
return fmt .Errorf ("failed pushing changes to installation repo: %w" , err )
172
177
}
173
178
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
+ }
175
185
sha , err = destRepo .Persist (ctx , & apgit.PushOptions {
176
186
CommitMsg : "moved resources from installation repo" ,
177
187
})
178
188
if err != nil {
179
189
return fmt .Errorf ("failed pushing changes to internal-shared-config repo: %w" , err )
180
190
}
181
191
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 )
183
193
log .G (ctx ).Infof ("Done migrating resources from %q to %q" , * runtime .Repo , * user .ActiveAccount .SharedConfigRepo )
184
194
185
195
err = removeFromCluster (ctx , opts .helmReleaseName , * runtime .Metadata .Namespace , opts .kubeContext , srcCloneOpts , opts .kubeFactory )
@@ -631,3 +641,10 @@ func filterStatus(manifest []byte) []byte {
631
641
632
642
return []byte (strings .Join (res , "\n " ))
633
643
}
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