Repository navigation
feat(testing): let GitRepo give every user access to the repository it creates - #1470
Merged
Merged
Conversation
…t creates GitRepo copies its source directory, which keeps the source's permissions, and creates the repository as the user that runs the tests. When the Infrahub containers run as another user, they cannot read a repository copied from a private directory, such as one from pytest's tmp_path, and cannot push to any of them. With shared=True, GitRepo sets core.sharedRepository so that Git creates later files with the same access, and gives every user read and write access to the files that exist already. The default, False, keeps the current behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
7bf7df0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c2b8b652.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://pog-em-gitrepo-shared-access.infrahub-sdk-python.pages.dev |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## infrahub-release-1.12 #1470 +/- ##
======================================================
Coverage 87.74% 87.74%
======================================================
Files 155 155
Lines 15517 15539 +22
Branches 2085 2091 +6
======================================================
+ Hits 13615 13635 +20
+ Misses 1345 1344 -1
- Partials 557 560 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
ogenstad
marked this pull request as ready for review
November 3, 2026 09:19
Contributor
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="infrahub_sdk/testing/repository.py">
<violation number="1" location="infrahub_sdk/testing/repository.py:95">
P2: This only chmods the repository tree; a private `dst_directory` or ancestor still blocks other users from traversing to it. Under a mode-0700 temporary parent, `shared=True` therefore still fails for the other container user; make the path traversable or document this requirement.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| config.write_to_path() | ||
|
|
||
| root_directory = self.dst_directory / self.name | ||
| root_directory.chmod(0o777) |
Contributor
There was a problem hiding this comment.
P2: This only chmods the repository tree; a private dst_directory or ancestor still blocks other users from traversing to it. Under a mode-0700 temporary parent, shared=True therefore still fails for the other container user; make the path traversable or document this requirement.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At infrahub_sdk/testing/repository.py, line 95:
<comment>This only chmods the repository tree; a private `dst_directory` or ancestor still blocks other users from traversing to it. Under a mode-0700 temporary parent, `shared=True` therefore still fails for the other container user; make the path traversable or document this requirement.</comment>
<file context>
@@ -75,6 +78,33 @@ def init(self) -> None:
+ config.write_to_path()
+
+ root_directory = self.dst_directory / self.name
+ root_directory.chmod(0o777)
+ for root, directories, files in os.walk(root_directory):
+ for directory in directories:
</file context>
gmazoyer
approved these changes
Nov 3, 2026
2 of 3 tasks
ogenstad
added a commit
to opsmill/infrahub
that referenced
this pull request
Nov 3, 2026
…1.12 The SDK now includes opsmill/infrahub-sdk-python#1470, which adds the shared argument to GitRepo, and opsmill/infrahub-sdk-python#1469. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
GitRepoininfrahub_sdk.testing.repositorycreates the Git repositories that tests add to Infrahub as remotes. It creates them as the user that runs the tests, and the copy ofsrc_directorykeeps the permissions of the source. When the Infrahub containers that mount these repositories run as another user, for example when pytest runs as root and the containers do not:tmp_path(mode 0700), and fail with "does not appear to be a git repository"The goal is to let a test create repositories that the containers can read and push to, without changing anything for existing callers.
What changed
GitRepohas a newsharedfield,Falseby default.shared=True,GitRepo.initgives every user read and write access to the repository after the first commit:core.sharedRepositoryto0666, so that Git creates the files of a later commit or push with the same access.GitRepouses to create the repository, does not applycore.sharedRepositoryitself.shared=False, the behavior is the same as before. The new field is the last field of the dataclass, so callers that pass the other fields by position are not affected.How to review
infrahub_sdk/testing/repository.py: the new field andGitRepo._share.tests/unit/sdk/test_repository.py: one test checks that the default keeps the permissions of a private source, and one checks the permissions and the Git setting withshared=True.How to test
The unit tests check the permissions, but cannot run Git as a second user. The end-to-end check is running the Infrahub E2E tests that push to these repositories with the containers and pytest running as different users. This PR stays a draft until that check has passed.
🤖 Generated with Claude Code