From f03b6fa3d595ae7761cae1dba569a80cd62ec38e Mon Sep 17 00:00:00 2001 From: Markus Vahlenkamp Date: Wed, 15 Nov 2023 22:53:00 +0100 Subject: [PATCH] Repo clone ACL (#1720) * adjust ACLs on Repo Clone * added git dir --------- Co-authored-by: Roman Dodin --- .github/workflows/cicd.yml | 1 + git/git.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 484890fdb..a1630fb9b 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -44,6 +44,7 @@ jobs: - 'errors/**' - 'cert/**' - 'virt/**' + - 'git/**' - 'border0_api/**' - '.github/workflows/cicd.yml' - 'go.mod' diff --git a/git/git.go b/git/git.go index 436ff5f7b..46f126a66 100644 --- a/git/git.go +++ b/git/git.go @@ -11,6 +11,7 @@ import ( "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/storage/memory" log "github.com/sirupsen/logrus" + "github.com/srl-labs/containerlab/utils" ) type GoGit struct { @@ -216,6 +217,12 @@ func (g *GoGit) cloneNonExisting() error { } co.ReferenceName = plumbing.NewBranchReferenceName(branchName) } + // pre-create the repo directory and adjust the ACLs + utils.CreateDirectory(g.gitRepo.GetName(), 0755) + err = utils.AdjustFileACLs(g.gitRepo.GetName()) + if err != nil { + log.Warnf("failed to adjust repository (%s) ACLs. continuin anyways", g.gitRepo.GetName()) + } // perform clone g.r, err = gogit.PlainClone(g.gitRepo.GetName(), false, co)