Skip to content

Commit 8c27e0a

Browse files
committed
Configure ignore domain for GitRepository rules
Unlike Bucket resources which are matched by key as presented by S3, ignore rules for GitRepository objects do have a domain: the temporary directory of the Git repository. Signed-off-by: Hidde Beydals <[email protected]>
1 parent 14cf348 commit 8c27e0a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

controllers/gitrepository_controller.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"io/ioutil"
2323
"os"
24+
"path/filepath"
2425
"strings"
2526
"time"
2627

@@ -272,15 +273,16 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, repository sour
272273
defer unlock()
273274

274275
// archive artifact and check integrity
275-
ps, err := sourceignore.LoadIgnorePatterns(tmpGit, nil)
276+
ignoreDomain := strings.Split(tmpGit, string(filepath.Separator))
277+
ps, err := sourceignore.LoadIgnorePatterns(tmpGit, ignoreDomain)
276278
if err != nil {
277279
err = fmt.Errorf(".sourceignore error: %w", err)
278280
return sourcev1.GitRepositoryNotReady(repository, sourcev1.StorageOperationFailedReason, err.Error()), err
279281
}
280282
if repository.Spec.Ignore != nil {
281-
ps = append(ps, sourceignore.ReadPatterns(strings.NewReader(*repository.Spec.Ignore), nil)...)
283+
ps = append(ps, sourceignore.ReadPatterns(strings.NewReader(*repository.Spec.Ignore), ignoreDomain)...)
282284
}
283-
if err := r.Storage.Archive(&artifact, tmpGit, SourceIgnoreFilter(ps, nil)); err != nil {
285+
if err := r.Storage.Archive(&artifact, tmpGit, SourceIgnoreFilter(ps, ignoreDomain)); err != nil {
284286
err = fmt.Errorf("storage archive error: %w", err)
285287
return sourcev1.GitRepositoryNotReady(repository, sourcev1.StorageOperationFailedReason, err.Error()), err
286288
}

0 commit comments

Comments
 (0)