Skip to content

Commit d9aa8b6

Browse files
Fix migrate command (#725)
## What <!-- What is changing in this PR? --> ## Why <!-- Why are these changes being made? --> ## Notes <!-- Add any additional notes here -->
1 parent fcd73ea commit d9aa8b6

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.1.54
1+
VERSION=v0.1.55
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/migrate.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.51/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.55/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.51/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.55/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

0 commit comments

Comments
 (0)