Skip to content

Commit 11774f0

Browse files
authored
[BV-267] Make sure .gitconfig is always present (#295)
* make sure .gitconfig is always present * update integration tests
1 parent 76ca5ae commit 11774f0

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

.github/workflows/tests-integration.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
run: |
6262
mkdir -p ../theadamproject
6363
# These are later mounted in the container
64-
mkdir ~/.ssh && touch ~/.gitconfig
64+
mkdir ~/.ssh
6565
6666
- name: Project Init
6767
run: |

Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ RUN git clone https://github.com/bats-core/bats-assert.git
1616

1717
# Needed as is mounted later on
1818
RUN mkdir /root/.ssh
19-
# Needed for git to run propertly
20-
RUN touch /root/.gitconfig
2119

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

leverage/container.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ def __init__(self, client, mounts=None, env_vars=None):
455455
# SSH AGENT
456456
SSH_AUTH_SOCK = os.getenv("SSH_AUTH_SOCK")
457457

458+
# make sure .gitconfig exists before mounting it
459+
self.paths.host_git_config_file.touch(exist_ok=True)
460+
458461
self.environment.update(
459462
{
460463
"COMMON_CONFIG_FILE": self.paths.common_tfvars,
@@ -479,7 +482,7 @@ def __init__(self, client, mounts=None, env_vars=None):
479482
target=self.paths.guest_aws_credentials_dir,
480483
type="bind",
481484
),
482-
Mount(source=(self.paths.home / ".gitconfig").as_posix(), target="/etc/gitconfig", type="bind"),
485+
Mount(source=self.paths.host_git_config_file.as_posix(), target="/etc/gitconfig", type="bind"),
483486
]
484487
self.mounts.extend(extra_mounts)
485488
# if you have set the tf plugin cache locally

leverage/path.py

+4
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ def host_aws_profiles_file(self):
197197
def host_aws_credentials_file(self):
198198
return self.host_aws_credentials_dir / "credentials"
199199

200+
@property
201+
def host_git_config_file(self):
202+
return self.home / ".gitconfig"
203+
200204
@property
201205
def local_backend_tfvars(self):
202206
return self.account_config_dir / self.BACKEND_TF_VARS

tests/bats/leverage.bats

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ teardown(){
3535
cp "$BUILD_SCRIPTS/simple_build.py" "$ACC_DIR/build.py"
3636
cd "$ACC_DIR"
3737

38-
run leverage -l
38+
run leverage run -l
3939

4040
assert_line --index 0 "Tasks in build file \`build.py\`:"
4141
assert_line --index 1 --regexp "^ hello\s+Say hello.$"
@@ -49,7 +49,7 @@ teardown(){
4949
cp "$BUILD_SCRIPTS/simple_build.py" "$ROOT_DIR/build.py"
5050
cd "$ROOT_DIR/account"
5151

52-
run leverage -l
52+
run leverage run -l
5353

5454
assert_line --index 0 "Tasks in build file \`build.py\`:"
5555
assert_line --index 1 --regexp "^ hello\s+Say hello.$"

0 commit comments

Comments
 (0)