From ffe0f71b6b618c3040b594ad6c41fa2c9d4bab47 Mon Sep 17 00:00:00 2001 From: Antonin <9219052+antonincms@users.noreply.github.com> Date: Sat, 6 May 2023 17:38:59 +0200 Subject: [PATCH] Upgrade jsonnet and gojsonnet to 0.20.0 The related jsonnet changelog are : - https://github.com/google/jsonnet/releases/tag/v0.18.0 - https://github.com/google/jsonnet/releases/tag/v0.19.0 - https://github.com/google/jsonnet/releases/tag/v0.19.1 - https://github.com/google/jsonnet/releases/tag/v0.20.0 Update search_imports function to return bytes according to the v0.19.0 changes mentioned there: https://github.com/google/jsonnet/releases/tag/v0.19.1 --- kapitan/resources.py | 6 ++++-- poetry.lock | 8 ++++---- pyproject.toml | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/kapitan/resources.py b/kapitan/resources.py index e77f4c885..e568d6618 100644 --- a/kapitan/resources.py +++ b/kapitan/resources.py @@ -210,12 +210,14 @@ def search_imports(cwd, import_str, search_paths): - search_paths is the location where to look for import_str if not in cwd The only supported parameters are cwd and import_str, so search_paths needs to be closured. + This function returns a tuple[str, bytes] since jsonnet 0.19.0 require the + content of the file to be provided as a bytes type instead of a str. """ basename = os.path.basename(import_str) full_import_path = os.path.normpath(os.path.join(cwd, import_str)) if full_import_path in JSONNET_CACHE: - return full_import_path, JSONNET_CACHE[full_import_path] + return full_import_path, JSONNET_CACHE[full_import_path].encode() if not os.path.exists(full_import_path): # if import_str not found, search in install_path @@ -246,7 +248,7 @@ def search_imports(cwd, import_str, search_paths): normalised_path_content = f.read() JSONNET_CACHE[normalised_path] = normalised_path_content - return normalised_path, normalised_path_content + return normalised_path, normalised_path_content.encode() def inventory(search_paths, target, inventory_path=None): diff --git a/poetry.lock b/poetry.lock index d33ff334f..608708f23 100644 --- a/poetry.lock +++ b/poetry.lock @@ -422,13 +422,13 @@ gitdb = ">=4.0.1,<5" [[package]] name = "gojsonnet" -version = "0.17.0" +version = "0.20.0" description = "Python bindings for Jsonnet - The data templating language" category = "main" optional = true python-versions = "*" files = [ - {file = "gojsonnet-0.17.0.tar.gz", hash = "sha256:f6fc47d9b1dd0099158978216880c86cb0fcae866b4ca54a5e42e7416bec3b98"}, + {file = "gojsonnet-0.20.0.tar.gz", hash = "sha256:9aede3b5734dee1c99dbec75dee3b086baaae92bd262d93f9217e21bf19c9682"}, ] [[package]] @@ -665,13 +665,13 @@ files = [ [[package]] name = "jsonnet" -version = "0.18.0" +version = "0.20.0" description = "Python bindings for Jsonnet - The data templating language" category = "main" optional = false python-versions = "*" files = [ - {file = "jsonnet-0.18.0.tar.gz", hash = "sha256:4ccd13427e9097b6b7d6d38f78f638a55ab8b452a257639e8e9af2178ec235d4"}, + {file = "jsonnet-0.20.0.tar.gz", hash = "sha256:7e770c7bf3a366b97b650a39430450f77612e74406731eb75c5bd59f3f104d4f"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 07e37a725..00a37e32b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ gitpython = "^3.1.30" google-api-python-client = "^2.15.0" hvac = "^0.11.0" jinja2 = "^3.0.1" -jsonnet = "^0.18.0" +jsonnet = "^0.20.0" jsonschema = "^4.17.3" kadet = "^0.2.2" python-gnupg = "^0.4.7" @@ -61,7 +61,7 @@ certifi = "*" gitdb = "^4.0.10" packaging = "^23.0" typing-extensions = "^4.0.0" -gojsonnet = { version = "^0.17.0", optional = true } +gojsonnet = { version = "^0.20.0", optional = true } docker = { version = "^5.0.0", optional = true } [tool.poetry.extras]