Skip to content

Commit

Permalink
git ls-remote is faster than checking tags
Browse files Browse the repository at this point in the history
However for providers, we should also check the rss feed
for the latest entries as it's a more expensive check.

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
  • Loading branch information
cam72cam committed Dec 8, 2023
1 parent b49ffbd commit 3435ff2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 95 deletions.
4 changes: 2 additions & 2 deletions src/cmd/bump-versions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
os.Exit(1)
}

err = modules.Parallel(20, func(m module.Module) error {
err = modules.Parallel(200, func(m module.Module) error {
return m.UpdateMetadataFile()
})
if err != nil {
Expand All @@ -49,7 +49,7 @@ func main() {
logger.Error("Failed to list providers", slog.Any("err", err))
os.Exit(1)
}
err = providers.Parallel(20, func(p provider.Provider) error {
err = providers.Parallel(200, func(p provider.Provider) error {
return p.UpdateMetadataFile()
})
if err != nil {
Expand Down
10 changes: 0 additions & 10 deletions src/internal/module/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import (
func (m Module) UpdateMetadataFile() error {
m.Logger.Info("Beginning version bump process for module", slog.String("module", m.Namespace+"/"+m.Name+"/"+m.TargetSystem))

shouldUpdate, err := m.shouldUpdateMetadataFile()
if err != nil {
m.Logger.Error("Failed to determine update status", slog.Any("err", err))
return err
}
if !shouldUpdate {
m.Logger.Info("No version bump required")
return nil
}

meta, err := m.BuildMetadata()
if err != nil {
return err
Expand Down
73 changes: 0 additions & 73 deletions src/internal/module/update.go

This file was deleted.

14 changes: 14 additions & 0 deletions src/internal/provider/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package provider

import (
"fmt"
"log/slog"
"slices"

"github.com/opentofu/registry-stable/internal"
Expand Down Expand Up @@ -63,6 +64,19 @@ func (p Provider) buildMetadata() (*Metadata, error) {
// filter the releases to only include those that do not already exist in the metadata
newReleases := meta.filterNewReleases(releases)

if len(newReleases) == 0 {
p.Logger.Info("No version bump required, all versions exist")
return &meta, nil
}

shouldUpdate, err := p.shouldUpdateMetadataFile()
if err != nil {
p.Logger.Error("Failed to determine update status, forcing update", slog.Any("err", err))
} else if !shouldUpdate {
p.Logger.Info("No version bump required, latest versions exist")
return &meta, nil
}

type versionResult struct {
v *Version
err error
Expand Down
11 changes: 1 addition & 10 deletions src/internal/provider/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,12 @@ import (
func (p Provider) UpdateMetadataFile() error {
p.Logger.Info("Beginning version bump process")

shouldUpdate, err := p.shouldUpdateMetadataFile()
if err != nil {
p.Logger.Error("Failed to determine update status", slog.Any("err", err))
return err
}
if !shouldUpdate {
p.Logger.Info("No version bump required")
return nil
}

meta, err := p.buildMetadata()
if err != nil {
p.Logger.Error("Failed to version bump provider", slog.Any("err", err))
return err
}

p.Logger.Info("Completed provider version bump successfully")
return p.WriteMetadata(*meta)
}
Expand Down

0 comments on commit 3435ff2

Please sign in to comment.