Skip to content

Commit

Permalink
Add fallback to mach-composer update —cloud to git
Browse files Browse the repository at this point in the history
When a component isn’t in the cloud, use git
  • Loading branch information
mvantellingen committed Mar 3, 2023
1 parent c9074c4 commit 4b4e842
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions internal/updater/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4b4e842

Please sign in to comment.