Skip to content

Commit

Permalink
Run: Fix problem where ~/.config wasn't being mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan Gallagher committed Oct 2, 2024
1 parent 3a83bd5 commit bf54398
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions debpic/python/debpic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ def test_run_container(self):
assert self.cli_commands.pop(0) == "gpgconf --list-dir homedir"
assert (
self.cli_commands.pop(0)
== """docker run --mount type=bind,src=${PWD},dst=/workspaces/code --mount type=volume,src=debpic_cache,dst=/home/docker/.cache --user 1000:$(id -g 1000) --network host --tty --rm --env DEB_BUILD_OPTIONS="" test_name /bin/bash -c 'if [[ -x /usr/bin/hook ]]; then /usr/bin/hook; fi && dpkg-buildpackage && mv-debs && dpkg-buildpackage --target=clean'"""
== """docker run --mount type=bind,src=${PWD},dst=/workspaces/code --mount type=volume,src=debpic_cache,dst=/home/docker/.cache --mount type=bind,src=$HOME/.config,dst=/home/docker/.config,readonly --user 1000:$(id -g 1000) --network host --tty --rm --env DEB_BUILD_OPTIONS="" test_name /bin/bash -c 'if [[ -x /usr/bin/hook ]]; then /usr/bin/hook; fi && dpkg-buildpackage && mv-debs && dpkg-buildpackage --target=clean'"""
)
run.run_container("test_name", "echo I'm a test command")
assert self.cli_commands.pop(0) == "gpgconf --list-dirs agent-socket"
assert self.cli_commands.pop(0) == "gpgconf --list-dir homedir"
assert (
self.cli_commands.pop(0)
== """docker run --mount type=bind,src=${PWD},dst=/workspaces/code --mount type=volume,src=debpic_cache,dst=/home/docker/.cache --user 1000:$(id -g 1000) --network host --tty --rm --env DEB_BUILD_OPTIONS=\"\" test_name /bin/bash -c 'if [[ -x /usr/bin/hook ]]; then /usr/bin/hook; fi && echo I'm a test command'"""
== """docker run --mount type=bind,src=${PWD},dst=/workspaces/code --mount type=volume,src=debpic_cache,dst=/home/docker/.cache --mount type=bind,src=$HOME/.config,dst=/home/docker/.config,readonly --user 1000:$(id -g 1000) --network host --tty --rm --env DEB_BUILD_OPTIONS=\"\" test_name /bin/bash -c 'if [[ -x /usr/bin/hook ]]; then /usr/bin/hook; fi && echo I'm a test command'"""
)

run.run_container("test_name", "", "", "--interactive")
assert self.cli_commands.pop(0) == "gpgconf --list-dirs agent-socket"
assert self.cli_commands.pop(0) == "gpgconf --list-dir homedir"
assert (
self.cli_commands.pop(0)
== """docker run --mount type=bind,src=${PWD},dst=/workspaces/code --mount type=volume,src=debpic_cache,dst=/home/docker/.cache --user 1000:$(id -g 1000) --network host --tty --rm --env DEB_BUILD_OPTIONS="" --interactive test_name """
== """docker run --mount type=bind,src=${PWD},dst=/workspaces/code --mount type=volume,src=debpic_cache,dst=/home/docker/.cache --mount type=bind,src=$HOME/.config,dst=/home/docker/.config,readonly --user 1000:$(id -g 1000) --network host --tty --rm --env DEB_BUILD_OPTIONS="" --interactive test_name """
)
3 changes: 2 additions & 1 deletion debpic/python/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def run_container(
--mount type=bind,src={gpg_home}/trustdb.gpg,dst=/home/docker/.gnupg/trustdb.gpg,readonly"""

config_mount_cmd = ""
if os.path.exists("$HOME/.config"):
home = os.path.expanduser("~")
if os.path.exists(f"{home}/.config"):
config_mount_cmd = (
"--mount type=bind,src=$HOME/.config,dst=/home/docker/.config,readonly"
)
Expand Down

0 comments on commit bf54398

Please sign in to comment.