Skip to content

Commit 11ea1cf

Browse files
committed
create wrapper around Mirror method
1 parent b169d4c commit 11ea1cf

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

pkg/mirror/example_noworktree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ repositories:
4848

4949
// perform 1st mirror to ensure all repositories
5050
// initial mirror might take longer
51-
if err := repos.Mirror(ctx, 5*time.Minute); err != nil {
51+
if err := repos.MirrorAll(ctx, 5*time.Minute); err != nil {
5252
panic(err)
5353
}
5454

pkg/mirror/example_worktree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ repositories:
5151

5252
// perform 1st mirror to ensure all repositories
5353
// initial mirror might take longer
54-
if err := repos.Mirror(ctx, 5*time.Minute); err != nil {
54+
if err := repos.MirrorAll(ctx, 5*time.Minute); err != nil {
5555
panic(err)
5656
}
5757

pkg/mirror/repo_pool.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ func (rp *RepoPool) AddRepository(repo *Repository) error {
6868
return nil
6969
}
7070

71-
// Mirror will trigger mirror on every repo in foreground with given timeout.
71+
// MirrorAll will trigger mirror on every repo in foreground with given timeout.
7272
// It will error out if any of the repository mirror errors.
73-
// Ideally Mirror should be used for the first mirror cycle to ensure repositories are
73+
// Ideally MirrorAll should be used for the first mirror cycle to ensure repositories are
7474
// successfully mirrored
75-
func (rp *RepoPool) Mirror(ctx context.Context, timeout time.Duration) error {
75+
func (rp *RepoPool) MirrorAll(ctx context.Context, timeout time.Duration) error {
7676
for _, repo := range rp.repos {
7777
mCtx, cancel := context.WithTimeout(ctx, timeout)
7878
err := repo.Mirror(mCtx)
@@ -85,6 +85,16 @@ func (rp *RepoPool) Mirror(ctx context.Context, timeout time.Duration) error {
8585
return nil
8686
}
8787

88+
// Mirror is wrapper around repositories Mirror method
89+
func (rp *RepoPool) Mirror(ctx context.Context, remote string) error {
90+
repo, err := rp.Repository(remote)
91+
if err != nil {
92+
return err
93+
}
94+
95+
return repo.Mirror(ctx)
96+
}
97+
8898
// StartLoop will start mirror loop on all repositories
8999
// if its not already started
90100
func (rp *RepoPool) StartLoop() {

pkg/mirror/z_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ func Test_RepoPool_Success(t *testing.T) {
11651165
}
11661166

11671167
// run initial mirror
1168-
if err := rp.Mirror(context.TODO(), testTimeout); err != nil {
1168+
if err := rp.MirrorAll(context.TODO(), testTimeout); err != nil {
11691169
t.Fatalf("unexpected err:%s", err)
11701170
}
11711171

0 commit comments

Comments
 (0)