Skip to content

Commit 6cbf2ac

Browse files
authored
Merge pull request #2067 from containers/fix-list-oci-docker
docker: fix list command for oci images when running in a non-UTC timezone
2 parents deb2145 + 63a79c3 commit 6cbf2ac

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

ramalama/common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def exec_cmd(args, stdout2null: bool = False, stderr2null: bool = False):
135135
raise
136136

137137

138-
def run_cmd(args, cwd=None, stdout=subprocess.PIPE, ignore_stderr=False, ignore_all=False, encoding=None):
138+
def run_cmd(args, cwd=None, stdout=subprocess.PIPE, ignore_stderr=False, ignore_all=False, encoding=None, env=None):
139139
"""
140140
Run the given command arguments.
141141
@@ -151,6 +151,7 @@ def run_cmd(args, cwd=None, stdout=subprocess.PIPE, ignore_stderr=False, ignore_
151151
logger.debug(f"Working directory: {cwd}")
152152
logger.debug(f"Ignore stderr: {ignore_stderr}")
153153
logger.debug(f"Ignore all: {ignore_all}")
154+
logger.debug(f"env: {env}")
154155

155156
serr = None
156157
if ignore_all or ignore_stderr:
@@ -160,7 +161,10 @@ def run_cmd(args, cwd=None, stdout=subprocess.PIPE, ignore_stderr=False, ignore_
160161
if ignore_all:
161162
sout = subprocess.DEVNULL
162163

163-
result = subprocess.run(args, check=True, cwd=cwd, stdout=sout, stderr=serr, encoding=encoding)
164+
if env:
165+
env = os.environ | env
166+
167+
result = subprocess.run(args, check=True, cwd=cwd, stdout=sout, stderr=serr, encoding=encoding, env=env)
164168
logger.debug(f"Command finished with return code: {result.returncode}")
165169

166170
return result

ramalama/oci_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def list_manifests(args: EngineArgType):
2727
"manifest=true",
2828
"--format",
2929
(
30-
'{"name":"oci://{{ .Repository }}:{{ .Tag }}","modified":"{{ .CreatedAt }}", "size":{{ .VirtualSize'
31-
' }}, "ID":"{{ .ID }}"},'
30+
'{"name":"oci://{{ .Repository }}:{{ .Tag }}","modified":"{{ .CreatedAt }}",'
31+
'"size":{{ .VirtualSize }}, "ID":"{{ .ID }}"},'
3232
),
3333
]
3434
output = run_cmd(conman_args).stdout.decode("utf-8").strip()
@@ -91,7 +91,7 @@ def list_models(args: EngineArgType):
9191
"--format",
9292
formatLine,
9393
]
94-
output = run_cmd(conman_args).stdout.decode("utf-8").strip()
94+
output = run_cmd(conman_args, env={"TZ": "UTC"}).stdout.decode("utf-8").strip()
9595
if output == "":
9696
return []
9797

0 commit comments

Comments
 (0)