Skip to content

Commit

Permalink
TMP: use json instead
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Dec 13, 2024
1 parent 5cb7b39 commit 3649368
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

FROM python:3.11-slim-bookworm AS olympia

ENV BUILD_INFO=/build-info
ENV BUILD_INFO=/build-info.json

# Set shell to bash with logs and errors for build
SHELL ["/bin/bash", "-xue", "-c"]
Expand Down Expand Up @@ -33,11 +33,13 @@ ARG DOCKER_TARGET
# Create the build file hard coding build variables to the image
RUN <<EOF
cat <<INNEREOF > ${BUILD_INFO}
commit="${DOCKER_COMMIT}"
version="${DOCKER_VERSION}"
build="${DOCKER_BUILD}"
target="${DOCKER_TARGET}"
source="https://github.com/mozilla/addons-server"
{
"commit": "${DOCKER_COMMIT}",
"version": "${DOCKER_VERSION}",
"build": "${DOCKER_BUILD}",
"target": "${DOCKER_TARGET}",
"source": "https://github.com/mozilla/addons-server"
}
INNEREOF
# Set permissions to make the file readable by all but only writable by root
chmod 644 ${BUILD_INFO}
Expand Down
6 changes: 1 addition & 5 deletions src/olympia/core/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@ def tearDown(self):
shutil.rmtree(self.tmp_dir)

def with_build_info(self, **kwargs):
data = '\n'.join(
f'{key}="{value}"' for key, value in {**default_version, **kwargs}.items()
)
data = json.dumps({**default_version, **kwargs})
with open(self.build_info_path, 'w') as f:
f.write(data)
f.close()

def with_pkg_json(self, data):
with open(self.pkg_json_path, 'w') as f:
f.write(json.dumps(data))
f.close()

def test_get_version_json_defaults(self):
result = get_version_json(build_info_path=self.build_info_path)
Expand Down
6 changes: 2 additions & 4 deletions src/olympia/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ def get_version_json(
# be overridden at runtime.
if os.path.exists(build_info_path):
with open(build_info_path) as f:
for line in f:
key, value = line.strip().split('=', 1)
if value.startswith('"') and value.endswith('"'):
value = value[1:-1]
data = json.loads(f.read())
for key, value in data.items():
contents[key] = value

py_info = sys.version_info
Expand Down

0 comments on commit 3649368

Please sign in to comment.