diff --git a/Makefile b/Makefile index 8cff93ab..be34880c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=v0.1.54 +VERSION=v0.1.55 OUT_DIR=dist YEAR?=$(shell date +"%Y") diff --git a/cmd/commands/migrate.go b/cmd/commands/migrate.go index 4180a019..6c435b60 100644 --- a/cmd/commands/migrate.go +++ b/cmd/commands/migrate.go @@ -20,6 +20,7 @@ import ( "net/url" "strings" + aputil "github.com/argoproj-labs/argocd-autopilot/pkg/util" argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" "github.com/codefresh-io/cli-v2/pkg/log" "github.com/codefresh-io/cli-v2/pkg/store" @@ -134,14 +135,18 @@ func runHelmMigrate(ctx context.Context, opts *MigrateOptions) error { } log.G(ctx).Infof("Cloned installation repo %q", *runtime.Repo) + destFs := apfs.Create(memfs.New()) + if isSharedConfigInInstallationRepo(user.ActiveAccount.SharedConfigRepo, runtime.Repo) { + destFs = opts.cloneOpts.FS + } destCloneOpts := &apgit.CloneOptions{ Provider: user.ActiveAccount.GitProvider.String(), Repo: *user.ActiveAccount.SharedConfigRepo, Auth: opts.cloneOpts.Auth, - FS: apfs.Create(memfs.New()), + FS: destFs, } destCloneOpts.Parse() - destRepo, destFs, err := destCloneOpts.GetRepo(ctx) + _, destFs, err = destCloneOpts.GetRepo(ctx) if err != nil { return fmt.Errorf("failed getting shared config repo: %w", err) } @@ -171,7 +176,12 @@ func runHelmMigrate(ctx context.Context, opts *MigrateOptions) error { return fmt.Errorf("failed pushing changes to installation repo: %w", err) } - log.G(ctx).Infof("Pushed changes to installation repo %q, sha: %s", *user.ActiveAccount.SharedConfigRepo, sha) + log.G(ctx).Infof("Pushed changes to installation repo %q, sha: %s", *runtime.Repo, sha) + + destRepo, _, err := destCloneOpts.GetRepo(ctx) + if err != nil { + return fmt.Errorf("failed getting shared config repo: %w", err) + } sha, err = destRepo.Persist(ctx, &apgit.PushOptions{ CommitMsg: "moved resources from installation repo", }) @@ -179,7 +189,7 @@ func runHelmMigrate(ctx context.Context, opts *MigrateOptions) error { return fmt.Errorf("failed pushing changes to internal-shared-config repo: %w", err) } - log.G(ctx).Infof("Pushed changes to shared-config-repo %q, sha: %s", *runtime.Repo, sha) + log.G(ctx).Infof("Pushed changes to shared-config-repo %q, sha: %s", *user.ActiveAccount.SharedConfigRepo, sha) log.G(ctx).Infof("Done migrating resources from %q to %q", *runtime.Repo, *user.ActiveAccount.SharedConfigRepo) err = removeFromCluster(ctx, opts.helmReleaseName, *runtime.Metadata.Namespace, opts.kubeContext, srcCloneOpts, opts.kubeFactory) @@ -631,3 +641,10 @@ func filterStatus(manifest []byte) []byte { return []byte(strings.Join(res, "\n")) } + +func isSharedConfigInInstallationRepo(iscRepo, installationRepo *string) bool { + iscRepoHost, _, _, _, _, _, _ := aputil.ParseGitUrl(*iscRepo) + installationRepoHost, _, _, _, _, _, _ := aputil.ParseGitUrl(*installationRepo) + + return iscRepoHost == installationRepoHost +} diff --git a/docs/releases/release_notes.md b/docs/releases/release_notes.md index 6647d03e..2dae41f0 100644 --- a/docs/releases/release_notes.md +++ b/docs/releases/release_notes.md @@ -23,7 +23,7 @@ cf version ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.51/cf-linux-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.55/cf-linux-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-linux-amd64 /usr/local/bin/cf @@ -36,7 +36,7 @@ cf version ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.51/cf-darwin-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.55/cf-darwin-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-darwin-amd64 /usr/local/bin/cf