Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions internal/strategy/git/bundle.go

This file was deleted.

120 changes: 0 additions & 120 deletions internal/strategy/git/bundle_test.go

This file was deleted.

26 changes: 1 addition & 25 deletions internal/strategy/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ import (
)

func Register(r *strategy.Registry, scheduler jobscheduler.Scheduler, cloneManagerProvider gitclone.ManagerProvider, tokenManagerProvider githubapp.TokenManagerProvider) {
strategy.Register(r, "git", "Caches Git repositories, including bundle and tarball snapshots.", func(ctx context.Context, config Config, cache cache.Cache, mux strategy.Mux) (*Strategy, error) {
strategy.Register(r, "git", "Caches Git repositories, including tarball snapshots.", func(ctx context.Context, config Config, cache cache.Cache, mux strategy.Mux) (*Strategy, error) {
return New(ctx, config, scheduler, cache, mux, cloneManagerProvider, tokenManagerProvider)
})
}

type Config struct {
BundleInterval time.Duration `hcl:"bundle-interval,optional" help:"How often to generate bundles. 0 disables bundling." default:"0"`
SnapshotInterval time.Duration `hcl:"snapshot-interval,optional" help:"How often to generate tar.zstd snapshots. 0 disables snapshots." default:"0"`
}

Expand Down Expand Up @@ -98,9 +97,6 @@ func New(
slog.String("error", err.Error()))
}
for _, repo := range existing {
if s.config.BundleInterval > 0 {
s.scheduleBundleJobs(repo)
}
if s.config.SnapshotInterval > 0 {
s.scheduleSnapshotJobs(repo)
}
Expand Down Expand Up @@ -140,7 +136,6 @@ func New(
mux.Handle("POST /git/{host}/{path...}", http.HandlerFunc(s.handleRequest))

logger.InfoContext(ctx, "Git strategy initialized",
"bundle_interval", config.BundleInterval,
"snapshot_interval", config.SnapshotInterval)

return s, nil
Expand Down Expand Up @@ -169,11 +164,6 @@ func (s *Strategy) handleRequest(w http.ResponseWriter, r *http.Request) {
slog.String("host", host),
slog.String("path", pathValue))

if strings.HasSuffix(pathValue, "/bundle") {
s.handleBundleRequest(w, r, host, pathValue)
return
}

if strings.HasSuffix(pathValue, "/snapshot") {
s.handleSnapshotRequest(w, r, host, pathValue)
return
Expand Down Expand Up @@ -349,10 +339,6 @@ func ExtractRepoPath(pathValue string) string {
return repoPath
}

func (s *Strategy) handleBundleRequest(w http.ResponseWriter, r *http.Request, host, pathValue string) {
s.serveCachedArtifact(w, r, host, pathValue, "bundle")
}

func (s *Strategy) serveCachedArtifact(w http.ResponseWriter, r *http.Request, host, pathValue, artifact string) {
ctx := r.Context()
logger := logging.FromContext(ctx)
Expand Down Expand Up @@ -420,10 +406,6 @@ func (s *Strategy) startClone(ctx context.Context, repo *gitclone.Repository) {
slog.String("upstream", repo.UpstreamURL()),
slog.String("path", repo.Path()))

if s.config.BundleInterval > 0 {
s.scheduleBundleJobs(repo)
}

if s.config.SnapshotInterval > 0 {
s.scheduleSnapshotJobs(repo)
}
Expand Down Expand Up @@ -457,9 +439,3 @@ func (s *Strategy) backgroundFetch(ctx context.Context, repo *gitclone.Repositor
slog.String("error", err.Error()))
}
}

func (s *Strategy) scheduleBundleJobs(repo *gitclone.Repository) {
s.scheduler.SubmitPeriodicJob(repo.UpstreamURL(), "bundle-periodic", s.config.BundleInterval, func(ctx context.Context) error {
return s.generateAndUploadBundle(ctx, repo)
})
}