From 4b4e8421873539e71aa4f23f05a5c74500aa35c2 Mon Sep 17 00:00:00 2001 From: Michael van Tellingen Date: Fri, 3 Mar 2023 16:13:28 +0100 Subject: [PATCH] =?UTF-8?q?Add=20fallback=20to=20`mach-composer=20update?= =?UTF-8?q?=20=E2=80=94cloud`=20to=20git?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a component isn’t in the cloud, use git --- CHANGELOG.md | 2 ++ internal/updater/updates.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9128ce4f..43b2d2f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## 2.7.2 (2023-03-03) - Remove the `-lockfile=readonly` argument to terraform apply. This was introduced in 2.7.0 but didn't work correctly. + - Add fallback to check in git when using `mach-composer update --cloud` when + a component isn't found. ## 2.7.1 (2023-03-01) - Default to branch `main` when no branch is defined for a component when diff --git a/internal/updater/updates.go b/internal/updater/updates.go index 2fe89d86..039f970d 100644 --- a/internal/updater/updates.go +++ b/internal/updater/updates.go @@ -161,11 +161,19 @@ func getLastVersionCloud(ctx context.Context, cfg *PartialConfig, c *config.Comp Execute() if err != nil { + if strings.HasPrefix(c.Source, "git:") { + zerolog.Ctx(ctx).Warn().Msgf("Error checking for %s in MACH Composer Cloud, falling back to Git", c.Name) + return getLastVersionGit(ctx, cfg, c, origin) + } zerolog.Ctx(ctx).Error().Err(err).Msgf("Error checking for latest version of %s", c.Name) return nil, nil } if version == nil { + if strings.HasPrefix(c.Source, "git:") { + zerolog.Ctx(ctx).Warn().Msgf("No version found for %s in MACH Composer Cloud, falling back to Git", c.Name) + return getLastVersionGit(ctx, cfg, c, origin) + } zerolog.Ctx(ctx).Warn().Msgf("No version found for %s", c.Name) return nil, nil }