Skip to content

Commit

Permalink
make sure .gitconfig is always present
Browse files Browse the repository at this point in the history
  • Loading branch information
Franr committed Jan 12, 2025
1 parent 76ca5ae commit 89c0162
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: |
mkdir -p ../theadamproject
# These are later mounted in the container
mkdir ~/.ssh && touch ~/.gitconfig
mkdir ~/.ssh
- name: Project Init
run: |
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ RUN git clone https://github.com/bats-core/bats-assert.git

# Needed as is mounted later on
RUN mkdir /root/.ssh
# Needed for git to run propertly
RUN touch /root/.gitconfig

RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local POETRY_VERSION=1.8.2 python3 -

Expand Down
5 changes: 4 additions & 1 deletion leverage/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ def __init__(self, client, mounts=None, env_vars=None):
# SSH AGENT
SSH_AUTH_SOCK = os.getenv("SSH_AUTH_SOCK")

# make sure .gitconfig exists before mounting it
self.paths.host_git_config_file.touch(exist_ok=True)

self.environment.update(
{
"COMMON_CONFIG_FILE": self.paths.common_tfvars,
Expand All @@ -479,7 +482,7 @@ def __init__(self, client, mounts=None, env_vars=None):
target=self.paths.guest_aws_credentials_dir,
type="bind",
),
Mount(source=(self.paths.home / ".gitconfig").as_posix(), target="/etc/gitconfig", type="bind"),
Mount(source=self.paths.host_git_config_file.as_posix(), target="/etc/gitconfig", type="bind"),
]
self.mounts.extend(extra_mounts)
# if you have set the tf plugin cache locally
Expand Down
4 changes: 4 additions & 0 deletions leverage/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ def host_aws_profiles_file(self):
def host_aws_credentials_file(self):
return self.host_aws_credentials_dir / "credentials"

@property
def host_git_config_file(self):
return self.home / ".gitconfig"

@property
def local_backend_tfvars(self):
return self.account_config_dir / self.BACKEND_TF_VARS
Expand Down

0 comments on commit 89c0162

Please sign in to comment.