From 15df5468663d636ab97fbf05b8c3299944a948c5 Mon Sep 17 00:00:00 2001 From: Alessandro De Maria Date: Fri, 19 Jan 2024 12:32:55 +0000 Subject: [PATCH 1/9] Adds Python 3.12 to the test set --- .github/workflows/test-build-publish.yml | 2 +- pyproject.toml | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-build-publish.yml b/.github/workflows/test-build-publish.yml index ed5ad725f..40099e3e2 100644 --- a/.github/workflows/test-build-publish.yml +++ b/.github/workflows/test-build-publish.yml @@ -51,7 +51,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.10', '3.11', '3.12'] steps: - name: Checkout kapitan recursively diff --git a/pyproject.toml b/pyproject.toml index 877a15a7b..754311e04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,9 +20,9 @@ classifiers = [ "Intended Audience :: Developers", "Topic :: Software Development :: Build Tools", "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] license = "Apache-2.0" version = "0.32.0" @@ -71,11 +71,10 @@ test = ["docker"] [tool.black] line-length = 110 -target-version = ['py38'] +target-version = ['py310'] exclude = ''' ( /( - .*reclass.* | .*version.py ) ) From ddb4eb8eb67f6d61785f6934645c7337d32082ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 13:51:29 +0000 Subject: [PATCH 2/9] chore: bump cryptography from 42.0.6 to 42.0.7 Bumps [cryptography](https://github.com/pyca/cryptography) from 42.0.6 to 42.0.7. - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pyca/cryptography/compare/42.0.6...42.0.7) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 66 ++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/poetry.lock b/poetry.lock index 5f2c3e461..a2812cb4b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -394,43 +394,43 @@ toml = ["tomli"] [[package]] name = "cryptography" -version = "42.0.6" +version = "42.0.7" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." optional = false python-versions = ">=3.7" files = [ - {file = "cryptography-42.0.6-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:073104df012fc815eed976cd7d0a386c8725d0d0947cf9c37f6c36a6c20feb1b"}, - {file = "cryptography-42.0.6-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:5967e3632f42b0c0f9dc2c9da88c79eabdda317860b246d1fbbde4a8bbbc3b44"}, - {file = "cryptography-42.0.6-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b99831397fdc6e6e0aa088b060c278c6e635d25c0d4d14bdf045bf81792fda0a"}, - {file = "cryptography-42.0.6-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:089aeb297ff89615934b22c7631448598495ffd775b7d540a55cfee35a677bf4"}, - {file = "cryptography-42.0.6-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:97eeacae9aa526ddafe68b9202a535f581e21d78f16688a84c8dcc063618e121"}, - {file = "cryptography-42.0.6-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f4cece02478d73dacd52be57a521d168af64ae03d2a567c0c4eb6f189c3b9d79"}, - {file = "cryptography-42.0.6-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:aeb6f56b004e898df5530fa873e598ec78eb338ba35f6fa1449970800b1d97c2"}, - {file = "cryptography-42.0.6-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:8b90c57b3cd6128e0863b894ce77bd36fcb5f430bf2377bc3678c2f56e232316"}, - {file = "cryptography-42.0.6-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:d16a310c770cc49908c500c2ceb011f2840674101a587d39fa3ea828915b7e83"}, - {file = "cryptography-42.0.6-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:e3442601d276bd9e961d618b799761b4e5d892f938e8a4fe1efbe2752be90455"}, - {file = "cryptography-42.0.6-cp37-abi3-win32.whl", hash = "sha256:00c0faa5b021457848d031ecff041262211cc1e2bce5f6e6e6c8108018f6b44a"}, - {file = "cryptography-42.0.6-cp37-abi3-win_amd64.whl", hash = "sha256:b16b90605c62bcb3aa7755d62cf5e746828cfc3f965a65211849e00c46f8348d"}, - {file = "cryptography-42.0.6-cp39-abi3-macosx_10_12_universal2.whl", hash = "sha256:eecca86813c6a923cabff284b82ff4d73d9e91241dc176250192c3a9b9902a54"}, - {file = "cryptography-42.0.6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d93080d2b01b292e7ee4d247bf93ed802b0100f5baa3fa5fd6d374716fa480d4"}, - {file = "cryptography-42.0.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9ff75b88a4d273c06d968ad535e6cb6a039dd32db54fe36f05ed62ac3ef64a44"}, - {file = "cryptography-42.0.6-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:c05230d8aaaa6b8ab3ab41394dc06eb3d916131df1c9dcb4c94e8f041f704b74"}, - {file = "cryptography-42.0.6-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:9184aff0856261ecb566a3eb26a05dfe13a292c85ce5c59b04e4aa09e5814187"}, - {file = "cryptography-42.0.6-cp39-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:4bdb39ecbf05626e4bfa1efd773bb10346af297af14fb3f4c7cb91a1d2f34a46"}, - {file = "cryptography-42.0.6-cp39-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:e85f433230add2aa26b66d018e21134000067d210c9c68ef7544ba65fc52e3eb"}, - {file = "cryptography-42.0.6-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:65d529c31bd65d54ce6b926a01e1b66eacf770b7e87c0622516a840e400ec732"}, - {file = "cryptography-42.0.6-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:f1e933b238978ccfa77b1fee0a297b3c04983f4cb84ae1c33b0ea4ae08266cc9"}, - {file = "cryptography-42.0.6-cp39-abi3-win32.whl", hash = "sha256:bc954251edcd8a952eeaec8ae989fec7fe48109ab343138d537b7ea5bb41071a"}, - {file = "cryptography-42.0.6-cp39-abi3-win_amd64.whl", hash = "sha256:9f1a3bc2747166b0643b00e0b56cd9b661afc9d5ff963acaac7a9c7b2b1ef638"}, - {file = "cryptography-42.0.6-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:945a43ebf036dd4b43ebfbbd6b0f2db29ad3d39df824fb77476ca5777a9dde33"}, - {file = "cryptography-42.0.6-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:f567a82b7c2b99257cca2a1c902c1b129787278ff67148f188784245c7ed5495"}, - {file = "cryptography-42.0.6-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:3b750279f3e7715df6f68050707a0cee7cbe81ba2eeb2f21d081bd205885ffed"}, - {file = "cryptography-42.0.6-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:6981acac509cc9415344cb5bfea8130096ea6ebcc917e75503143a1e9e829160"}, - {file = "cryptography-42.0.6-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:076c92b08dd1ab88108bc84545187e10d3693a9299c593f98c4ea195a0b0ead7"}, - {file = "cryptography-42.0.6-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:81dbe47e28b703bc4711ac74a64ef8b758a0cf056ce81d08e39116ab4bc126fa"}, - {file = "cryptography-42.0.6-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:e1f5f15c5ddadf6ee4d1d624a2ae940f14bd74536230b0056ccb28bb6248e42a"}, - {file = "cryptography-42.0.6-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:43e521f21c2458038d72e8cdfd4d4d9f1d00906a7b6636c4272e35f650d1699b"}, - {file = "cryptography-42.0.6.tar.gz", hash = "sha256:f987a244dfb0333fbd74a691c36000a2569eaf7c7cc2ac838f85f59f0588ddc9"}, + {file = "cryptography-42.0.7-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:a987f840718078212fdf4504d0fd4c6effe34a7e4740378e59d47696e8dfb477"}, + {file = "cryptography-42.0.7-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:bd13b5e9b543532453de08bcdc3cc7cebec6f9883e886fd20a92f26940fd3e7a"}, + {file = "cryptography-42.0.7-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a79165431551042cc9d1d90e6145d5d0d3ab0f2d66326c201d9b0e7f5bf43604"}, + {file = "cryptography-42.0.7-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a47787a5e3649008a1102d3df55424e86606c9bae6fb77ac59afe06d234605f8"}, + {file = "cryptography-42.0.7-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:02c0eee2d7133bdbbc5e24441258d5d2244beb31da5ed19fbb80315f4bbbff55"}, + {file = "cryptography-42.0.7-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:5e44507bf8d14b36b8389b226665d597bc0f18ea035d75b4e53c7b1ea84583cc"}, + {file = "cryptography-42.0.7-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:7f8b25fa616d8b846aef64b15c606bb0828dbc35faf90566eb139aa9cff67af2"}, + {file = "cryptography-42.0.7-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:93a3209f6bb2b33e725ed08ee0991b92976dfdcf4e8b38646540674fc7508e13"}, + {file = "cryptography-42.0.7-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:e6b8f1881dac458c34778d0a424ae5769de30544fc678eac51c1c8bb2183e9da"}, + {file = "cryptography-42.0.7-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:3de9a45d3b2b7d8088c3fbf1ed4395dfeff79d07842217b38df14ef09ce1d8d7"}, + {file = "cryptography-42.0.7-cp37-abi3-win32.whl", hash = "sha256:789caea816c6704f63f6241a519bfa347f72fbd67ba28d04636b7c6b7da94b0b"}, + {file = "cryptography-42.0.7-cp37-abi3-win_amd64.whl", hash = "sha256:8cb8ce7c3347fcf9446f201dc30e2d5a3c898d009126010cbd1f443f28b52678"}, + {file = "cryptography-42.0.7-cp39-abi3-macosx_10_12_universal2.whl", hash = "sha256:a3a5ac8b56fe37f3125e5b72b61dcde43283e5370827f5233893d461b7360cd4"}, + {file = "cryptography-42.0.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:779245e13b9a6638df14641d029add5dc17edbef6ec915688f3acb9e720a5858"}, + {file = "cryptography-42.0.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0d563795db98b4cd57742a78a288cdbdc9daedac29f2239793071fe114f13785"}, + {file = "cryptography-42.0.7-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:31adb7d06fe4383226c3e963471f6837742889b3c4caa55aac20ad951bc8ffda"}, + {file = "cryptography-42.0.7-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:efd0bf5205240182e0f13bcaea41be4fdf5c22c5129fc7ced4a0282ac86998c9"}, + {file = "cryptography-42.0.7-cp39-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:a9bc127cdc4ecf87a5ea22a2556cab6c7eda2923f84e4f3cc588e8470ce4e42e"}, + {file = "cryptography-42.0.7-cp39-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:3577d029bc3f4827dd5bf8bf7710cac13527b470bbf1820a3f394adb38ed7d5f"}, + {file = "cryptography-42.0.7-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:2e47577f9b18723fa294b0ea9a17d5e53a227867a0a4904a1a076d1646d45ca1"}, + {file = "cryptography-42.0.7-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:1a58839984d9cb34c855197043eaae2c187d930ca6d644612843b4fe8513c886"}, + {file = "cryptography-42.0.7-cp39-abi3-win32.whl", hash = "sha256:e6b79d0adb01aae87e8a44c2b64bc3f3fe59515280e00fb6d57a7267a2583cda"}, + {file = "cryptography-42.0.7-cp39-abi3-win_amd64.whl", hash = "sha256:16268d46086bb8ad5bf0a2b5544d8a9ed87a0e33f5e77dd3c3301e63d941a83b"}, + {file = "cryptography-42.0.7-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:2954fccea107026512b15afb4aa664a5640cd0af630e2ee3962f2602693f0c82"}, + {file = "cryptography-42.0.7-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:362e7197754c231797ec45ee081f3088a27a47c6c01eff2ac83f60f85a50fe60"}, + {file = "cryptography-42.0.7-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:4f698edacf9c9e0371112792558d2f705b5645076cc0aaae02f816a0171770fd"}, + {file = "cryptography-42.0.7-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:5482e789294854c28237bba77c4c83be698be740e31a3ae5e879ee5444166582"}, + {file = "cryptography-42.0.7-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:e9b2a6309f14c0497f348d08a065d52f3020656f675819fc405fb63bbcd26562"}, + {file = "cryptography-42.0.7-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:d8e3098721b84392ee45af2dd554c947c32cc52f862b6a3ae982dbb90f577f14"}, + {file = "cryptography-42.0.7-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:c65f96dad14f8528a447414125e1fc8feb2ad5a272b8f68477abbcc1ea7d94b9"}, + {file = "cryptography-42.0.7-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:36017400817987670037fbb0324d71489b6ead6231c9604f8fc1f7d008087c68"}, + {file = "cryptography-42.0.7.tar.gz", hash = "sha256:ecbfbc00bf55888edda9868a4cf927205de8499e7fabe6c050322298382953f2"}, ] [package.dependencies] From 08baef5e1ea00274a2f9955e47f2804b80fc6572 Mon Sep 17 00:00:00 2001 From: Keith Gaughan Date: Tue, 28 May 2024 01:05:48 +0100 Subject: [PATCH 3/9] Completely remove any references to distutils Whereas #964 just attempted to replace copy_tree, this replaces all the remaining references to distutils. This ought to make it possible to proceed with #1119 and add Python 3.12 to the test set. Closes #963. --- kapitan/dependency_manager/base.py | 6 ++-- kapitan/initialiser.py | 2 +- kapitan/inputs/copy.py | 2 +- kapitan/inputs/external.py | 2 +- kapitan/inputs/remove.py | 2 +- kapitan/utils.py | 44 ++++++++++++++++++++---------- tests/test_remote_inventory.py | 2 +- 7 files changed, 38 insertions(+), 22 deletions(-) diff --git a/kapitan/dependency_manager/base.py b/kapitan/dependency_manager/base.py index 52c9fc698..f779732cc 100644 --- a/kapitan/dependency_manager/base.py +++ b/kapitan/dependency_manager/base.py @@ -7,7 +7,6 @@ import multiprocessing import os from collections import defaultdict, namedtuple -from distutils.dir_util import copy_tree from functools import partial from mimetypes import MimeTypes from shutil import copyfile, rmtree @@ -17,6 +16,7 @@ from kapitan.errors import GitSubdirNotFoundError, GitFetchingError, HelmFetchingError from kapitan.helm_cli import helm_cli from kapitan.utils import ( + copy_tree, make_request, unpack_downloaded_file, safe_copy_tree, @@ -129,7 +129,7 @@ def fetch_git_dependency(dep_mapping, save_dir, force, item_type="Dependency"): "{} {}: subdir {} not found in repo".format(item_type, source, sub_dir) ) if force: - copied = copy_tree(copy_src_path, output_path, verbose=0) + copied = copy_tree(copy_src_path, output_path) else: copied = safe_copy_tree(copy_src_path, output_path) if copied: @@ -245,7 +245,7 @@ def fetch_helm_chart(dep_mapping, save_dir, force): os.makedirs(parent_dir, exist_ok=True) if force: - copied = copy_tree(cached_repo_path, output_path, verbose=0) + copied = copy_tree(cached_repo_path, output_path) else: copied = safe_copy_tree(cached_repo_path, output_path) diff --git a/kapitan/initialiser.py b/kapitan/initialiser.py index 1f3f3c4c5..46d699150 100644 --- a/kapitan/initialiser.py +++ b/kapitan/initialiser.py @@ -9,7 +9,7 @@ import logging import os -from distutils.dir_util import copy_tree +from kapitan.utils import copy_tree logger = logging.getLogger(__name__) diff --git a/kapitan/inputs/copy.py b/kapitan/inputs/copy.py index e623864ce..4706950bd 100644 --- a/kapitan/inputs/copy.py +++ b/kapitan/inputs/copy.py @@ -8,7 +8,7 @@ import logging import os import shutil -from distutils.dir_util import copy_tree +from kapitan.utils import copy_tree from kapitan.inputs.base import InputType diff --git a/kapitan/inputs/external.py b/kapitan/inputs/external.py index 4f13e6ad9..6faaaa02b 100644 --- a/kapitan/inputs/external.py +++ b/kapitan/inputs/external.py @@ -10,7 +10,7 @@ import logging import os import shutil -from distutils.dir_util import copy_tree +from kapitan.utils import copy_tree from kapitan.inputs.base import InputType diff --git a/kapitan/inputs/remove.py b/kapitan/inputs/remove.py index 4628392c6..3213d8e73 100644 --- a/kapitan/inputs/remove.py +++ b/kapitan/inputs/remove.py @@ -8,7 +8,7 @@ import logging import os import shutil -from distutils.dir_util import copy_tree +from kapitan.utils import copy_tree from kapitan.inputs.base import InputType diff --git a/kapitan/utils.py b/kapitan/utils.py index f5d0783c3..54ebe2ed3 100644 --- a/kapitan/utils.py +++ b/kapitan/utils.py @@ -7,20 +7,19 @@ from __future__ import print_function import collections +import glob import json import logging import magic import math import os import re +import shutil import stat import sys import tarfile import traceback from collections import Counter, defaultdict -from distutils.dir_util import mkpath -from distutils.errors import DistutilsFileError -from distutils.file_util import _copy_file_contents from functools import lru_cache, wraps from hashlib import sha256 from zipfile import ZipFile @@ -560,19 +559,23 @@ def unpack_downloaded_file(file_path, output_path, content_type): return is_unpacked +class SafeCopyError(Exception): + """Raised when a file or directory cannot be safely copied.""" + + def safe_copy_file(src, dst): """Copy a file from 'src' to 'dst'. - Similar to distutils.file_util.copy_file except + Similar to shutil.copyfile except if the file exists in 'dst' it's not clobbered or overwritten. - returns a tupple (src, val) + returns a tuple (src, val) file not copied if val = 0 else 1 """ if not os.path.isfile(src): - raise DistutilsFileError("Can't copy {}: doesn't exist or is not a regular file".format(src)) + raise SafeCopyError("Can't copy {}: doesn't exist or is not a regular file".format(src)) if os.path.isdir(dst): dir = dst @@ -583,7 +586,7 @@ def safe_copy_file(src, dst): if os.path.isfile(dst): logger.debug("Not updating %s (file already exists)", dst) return (dst, 0) - _copy_file_contents(src, dst) + shutil.copyfile(src, dst) logger.debug("Copied %s to %s", src, dir) return (dst, 1) @@ -591,21 +594,23 @@ def safe_copy_file(src, dst): def safe_copy_tree(src, dst): """Recursively copies the 'src' directory tree to 'dst' - Both 'src' and 'dst' must be directories. - similar to distutil.dir_util.copy_tree except - it doesn't overwite an existing file and doesn't - copy any file starting with "." + Both 'src' and 'dst' must be directories. Similar to copy_tree except + it doesn't overwite an existing file and doesn't copy any file starting + with "." Returns a list of copied file paths. """ if not os.path.isdir(src): - raise DistutilsFileError("Cannot copy tree {}: not a directory".format(src)) + raise SafeCopyError("Cannot copy tree {}: not a directory".format(src)) try: names = os.listdir(src) except OSError as e: - raise DistutilsFileError("Error listing files in {}: {}".format(src, e.strerror)) + raise SafeCopyError("Error listing files in {}: {}".format(src, e.strerror)) - mkpath(dst) + try: + os.makedirs(dst, exist_ok=True) + except FileExistsError: + pass outputs = [] for name in names: @@ -624,3 +629,14 @@ def safe_copy_tree(src, dst): outputs.append(dst_name) return outputs + + +def copy_tree(src, dst): + """Recursively copy a given directory from `src` to `dst`. + + Returns a list of the copied files. + """ + before = set(glob.iglob("*", recursive=True)) + shutil.copytree(src, dst, dirs_exist_ok=True) + after = set(glob.iglob("*", recursive=True)) + return list(after - before) diff --git a/tests/test_remote_inventory.py b/tests/test_remote_inventory.py index 863e9b343..22c46f555 100644 --- a/tests/test_remote_inventory.py +++ b/tests/test_remote_inventory.py @@ -4,7 +4,7 @@ import unittest import tempfile from shutil import rmtree -from distutils.dir_util import copy_tree +from kapitan.utils import copy_tree from kapitan.cached import reset_cache from kapitan.cli import main import yaml From d64f3c469f02fd10dfbe8c4d5b74d407bf5d9509 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 13:15:13 +0000 Subject: [PATCH 4/9] chore: bump azure-identity from 1.16.0 to 1.17.1 Bumps [azure-identity](https://github.com/Azure/azure-sdk-for-python) from 1.16.0 to 1.17.1. - [Release notes](https://github.com/Azure/azure-sdk-for-python/releases) - [Changelog](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/esrp_release.md) - [Commits](https://github.com/Azure/azure-sdk-for-python/compare/azure-identity_1.16.0...azure-identity_1.17.1) --- updated-dependencies: - dependency-name: azure-identity dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- poetry.lock | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index a2812cb4b..9ffee1161 100644 --- a/poetry.lock +++ b/poetry.lock @@ -62,13 +62,13 @@ aio = ["aiohttp (>=3.0)"] [[package]] name = "azure-identity" -version = "1.16.0" +version = "1.17.1" description = "Microsoft Azure Identity Library for Python" optional = false python-versions = ">=3.8" files = [ - {file = "azure-identity-1.16.0.tar.gz", hash = "sha256:6ff1d667cdcd81da1ceab42f80a0be63ca846629f518a922f7317a7e3c844e1b"}, - {file = "azure_identity-1.16.0-py3-none-any.whl", hash = "sha256:722fdb60b8fdd55fa44dc378b8072f4b419b56a5e54c0de391f644949f3a826f"}, + {file = "azure-identity-1.17.1.tar.gz", hash = "sha256:32ecc67cc73f4bd0595e4f64b1ca65cd05186f4fe6f98ed2ae9f1aa32646efea"}, + {file = "azure_identity-1.17.1-py3-none-any.whl", hash = "sha256:db8d59c183b680e763722bfe8ebc45930e6c57df510620985939f7f3191e0382"}, ] [package.dependencies] @@ -76,6 +76,7 @@ azure-core = ">=1.23.0" cryptography = ">=2.5" msal = ">=1.24.0" msal-extensions = ">=0.3.0" +typing-extensions = ">=4.0.0" [[package]] name = "azure-keyvault-keys" From 2f706e3af17019f0041e1b4b7c693b9b6e895b33 Mon Sep 17 00:00:00 2001 From: Paul Brissaud Date: Wed, 26 Jun 2024 14:28:33 +0200 Subject: [PATCH 5/9] feat: Add a --no-reveal flag in compile command to avoid revealing refs --- kapitan/cli.py | 6 +++--- tests/test_compile.py | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kapitan/cli.py b/kapitan/cli.py index 1324c8f0c..179668638 100644 --- a/kapitan/cli.py +++ b/kapitan/cli.py @@ -251,7 +251,7 @@ def build_parser(): compile_parser.add_argument( "--reveal", help="reveal refs (warning: this will potentially write sensitive data)", - action="store_true", + action=argparse.BooleanOptionalAction, default=from_dot_kapitan("compile", "reveal", False), ) compile_parser.add_argument( @@ -662,8 +662,8 @@ def main(): parser.print_help() sys.exit(1) - cached.args = args - + cached.args = args + if hasattr(args, "verbose") and args.verbose: logging_level = logging.DEBUG elif hasattr(args, "quiet") and args.quiet: diff --git a/tests/test_compile.py b/tests/test_compile.py index 99a1ac7c7..a55772fc1 100644 --- a/tests/test_compile.py +++ b/tests/test_compile.py @@ -39,6 +39,14 @@ def test_plain_ref_revealed(self): with open(g) as f: self.assertTrue("?{plain:" not in f.read()) + def test_compile_no_reveal(self): + # check if the --no-reveal flag takes precedence over --reveal when passed together + sys.argv = ["kapitan", "compile", "-t", "reveal-output", "--reveal", "--no-reveal"] + main() + + with open("compiled/reveal-output/main.json") as f: + self.assertTrue("?{gpg:" in f.read()) + def tearDown(self): os.chdir(os.getcwd() + "/../../") reset_cache() @@ -86,7 +94,7 @@ def test_compile(self): def tearDown(self): os.chdir(os.getcwd() + "/../../") reset_cache() - + class CompileTestResourcesTestJinja2InputParams(unittest.TestCase): def setUp(self): os.chdir(os.getcwd() + "/tests/test_resources/") From 15d989fe0c16bef1aa850f3ad40be1c3cd3f4067 Mon Sep 17 00:00:00 2001 From: Paul Brissaud Date: Wed, 26 Jun 2024 14:28:33 +0200 Subject: [PATCH 6/9] feat: Add a --no-reveal flag in compile command to avoid revealing refs --- .../inventory/targets/reveal-output.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/test_resources/inventory/targets/reveal-output.yml diff --git a/tests/test_resources/inventory/targets/reveal-output.yml b/tests/test_resources/inventory/targets/reveal-output.yml new file mode 100644 index 000000000..7f90501cb --- /dev/null +++ b/tests/test_resources/inventory/targets/reveal-output.yml @@ -0,0 +1,12 @@ +parameters: + input: $?{gpg:targets/nginx-ingress/electionID||randomstr|base64} + kapitan: + vars: + target: reveal-output + compile: + - name: generate-toml-jsonnet + input_type: jsonnet + output_path: . + output_type: json + input_paths: + - components/input-to-output/main.jsonnet From bf08d8ef6f44d199d2224ab89148d9beadf4c706 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 19:27:41 +0000 Subject: [PATCH 7/9] chore: bump packaging from 23.2 to 24.1 Bumps [packaging](https://github.com/pypa/packaging) from 23.2 to 24.1. - [Release notes](https://github.com/pypa/packaging/releases) - [Changelog](https://github.com/pypa/packaging/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pypa/packaging/compare/23.2...24.1) --- updated-dependencies: - dependency-name: packaging dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- poetry.lock | 12 ++++++------ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/poetry.lock b/poetry.lock index 9ffee1161..78c643cf4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "addict" @@ -907,13 +907,13 @@ portalocker = [ [[package]] name = "packaging" -version = "23.2" +version = "24.1" description = "Core utilities for Python packages" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, - {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, + {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, + {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] [[package]] @@ -1791,4 +1791,4 @@ test = ["docker", "reclass-rs"] [metadata] lock-version = "2.0" python-versions = "^3.10,<3.12" -content-hash = "48b76bd2c1b404e0dc0176867aac3cd052cdb177bfb7ce2381f33a1b00293957" +content-hash = "efaf8fe4b18b0a7f2f5d6cf993dcc11f39bc3c5f11b32c40b82ce0e2b213864f" diff --git a/pyproject.toml b/pyproject.toml index 5be2245ea..c8290cf17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ python-magic = "^0.4.27" azure-identity = "^1.12.0" certifi = "*" gitdb = "^4.0.10" -packaging = "^23.0" +packaging = ">=23,<25" typing-extensions = "^4.0.0" gojsonnet = { version = "^0.20.0", optional = true } docker = { version = ">=5,<8", optional = true } From 97588f2957b912b55731ab9f5386ffcfa99b327e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 19:27:50 +0000 Subject: [PATCH 8/9] chore: bump urllib3 from 2.2.1 to 2.2.2 Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.2.1 to 2.2.2. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/2.2.1...2.2.2) --- updated-dependencies: - dependency-name: urllib3 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 9ffee1161..f1ac7a024 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "addict" @@ -1750,13 +1750,13 @@ files = [ [[package]] name = "urllib3" -version = "2.2.1" +version = "2.2.2" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.2.1-py3-none-any.whl", hash = "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"}, - {file = "urllib3-2.2.1.tar.gz", hash = "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19"}, + {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, + {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, ] [package.extras] From 6aeb053d6af68b8e542214936902da7ed1809a17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Jul 2024 01:47:56 +0000 Subject: [PATCH 9/9] chore: bump certifi from 2024.2.2 to 2024.7.4 Bumps [certifi](https://github.com/certifi/python-certifi) from 2024.2.2 to 2024.7.4. - [Commits](https://github.com/certifi/python-certifi/compare/2024.02.02...2024.07.04) --- updated-dependencies: - dependency-name: certifi dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index d45c9afeb..9d4a6d7d7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -146,13 +146,13 @@ files = [ [[package]] name = "certifi" -version = "2024.2.2" +version = "2024.7.4" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, - {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, + {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"}, + {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"}, ] [[package]]