Skip to content

Commit

Permalink
testutil: remove "match" for centos8/9 compatbility
Browse files Browse the repository at this point in the history
Support for `match` in python is only available in version 3.10.
However centos/rhel 8 and 9 have lower versions so this will
need to be moved to `if/elif/else` for now.
  • Loading branch information
mvo5 committed Jan 18, 2024
1 parent 1b3b653 commit 0b066be
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions test/testutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@ def has_x86_64_v3_cpu():


def can_start_rootful_containers():
match platform.system():
case "Linux":
# on linux we need to run "podman" with sudo to get full
# root containers
return os.getuid() == 0
case "Darwin":
# on darwin a container is root if the podman machine runs
# in "rootful" mode, i.e. no need to run "podman" as root
# as it's just proxying to the VM
res = subprocess.run([
"podman", "machine", "inspect", "--format={{.Rootful}}",
], capture_output=True, encoding="utf8", check=True)
return res.stdout.strip() == "true"
case unknown:
raise ValueError(f"unknown platform {unknown}")
system = platform.system()
if system == "Linux":
# on linux we need to run "podman" with sudo to get full
# root containers
return os.getuid() == 0
elif system == "Darwin":
# on darwin a container is root if the podman machine runs
# in "rootful" mode, i.e. no need to run "podman" as root
# as it's just proxying to the VM
res = subprocess.run([
"podman", "machine", "inspect", "--format={{.Rootful}}",
], capture_output=True, encoding="utf8", check=True)
return res.stdout.strip() == "true"
else:
raise ValueError(f"unknown platform {system}")


def write_aws_creds(path):
Expand Down

0 comments on commit 0b066be

Please sign in to comment.