From 8c27e0ad5a7d64a549669d5e60ee60dde07bae5a Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Fri, 23 Apr 2021 11:01:15 +0200 Subject: [PATCH] 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 --- controllers/gitrepository_controller.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/controllers/gitrepository_controller.go b/controllers/gitrepository_controller.go index db3bd54ef..0290ce0fa 100644 --- a/controllers/gitrepository_controller.go +++ b/controllers/gitrepository_controller.go @@ -21,6 +21,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "strings" "time" @@ -272,15 +273,16 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, repository sour defer unlock() // archive artifact and check integrity - ps, err := sourceignore.LoadIgnorePatterns(tmpGit, nil) + ignoreDomain := strings.Split(tmpGit, string(filepath.Separator)) + ps, err := sourceignore.LoadIgnorePatterns(tmpGit, ignoreDomain) if err != nil { err = fmt.Errorf(".sourceignore error: %w", err) return sourcev1.GitRepositoryNotReady(repository, sourcev1.StorageOperationFailedReason, err.Error()), err } if repository.Spec.Ignore != nil { - ps = append(ps, sourceignore.ReadPatterns(strings.NewReader(*repository.Spec.Ignore), nil)...) + ps = append(ps, sourceignore.ReadPatterns(strings.NewReader(*repository.Spec.Ignore), ignoreDomain)...) } - if err := r.Storage.Archive(&artifact, tmpGit, SourceIgnoreFilter(ps, nil)); err != nil { + if err := r.Storage.Archive(&artifact, tmpGit, SourceIgnoreFilter(ps, ignoreDomain)); err != nil { err = fmt.Errorf("storage archive error: %w", err) return sourcev1.GitRepositoryNotReady(repository, sourcev1.StorageOperationFailedReason, err.Error()), err }