From 195cba50f1c1768e358a11cbc1e1c92fda404f04 Mon Sep 17 00:00:00 2001 From: Andrew Aadland Date: Fri, 21 Jan 2022 20:45:08 -0800 Subject: [PATCH] v0.10.0 --- .github/workflows/main.yaml | 33 +++++++++++++++++++++++++++ .pre-commit-config.yaml | 6 ++--- .vscode/launch.json | 12 ++++++++++ CHANGELOG.md | 22 ++++++++++++++++-- README.md | 5 +++- build.sh | 1 - src/helmizer-linux-x86_64.spec | 39 ++++++++++++++++++++++++++++++++ src/helmizer-windows-x86_64.spec | 39 ++++++++++++++++++++++++++++++++ src/helmizer.py | 23 +++++++++++++------ src/requirements-newest.txt | 3 --- src/requirements-old.txt | 4 ++++ src/requirements.txt | 9 ++++---- 12 files changed, 175 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/main.yaml create mode 100644 src/helmizer-linux-x86_64.spec create mode 100644 src/helmizer-windows-x86_64.spec delete mode 100644 src/requirements-newest.txt create mode 100644 src/requirements-old.txt diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..44de45a --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,33 @@ +name: Package Application with Pyinstaller +on: + push: + branches: [ main ] + # tags: + # - 'v*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: PyInstaller Linux + uses: JackMcKew/pyinstaller-action-linux@0.1.4 + with: + path: src + spec: helmizer-linux-x86_64.spec + - name: PyInstaller Windows + uses: JackMcKew/pyinstaller-action-windows@v0.1.2 + with: + path: src + spec: helmizer-windows-x86_64.spec + - name: Release + uses: softprops/action-gh-release@v1 + # if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: true + # tag_name: pyinstaller + fail_on_unmatched_files: true + files: | + src/dist/linux/helmizer-linux-x86_64 + src/dist/windows/helmizer-windows-x86_64.exe diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 148e4ec..69f5eb2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,8 +28,8 @@ repos: id: check-added-large-files - id: requirements-txt-fixer - id: check-ast - repo: 'git://github.com/pre-commit/pre-commit-hooks' - rev: v4.0.1 + repo: 'https://github.com/pre-commit/pre-commit-hooks' + rev: v4.1.0 - hooks: - id: black language_version: python3.9 @@ -37,7 +37,7 @@ repos: - --line-length - "140" repo: https://github.com/psf/black - rev: 21.10b0 + rev: 21.12b0 - repo: https://gitlab.com/pycqa/flake8 rev: 3.9.2 hooks: diff --git a/.vscode/launch.json b/.vscode/launch.json index f4c2e02..c5bc7c1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -213,6 +213,18 @@ "program": "${workspaceFolder}/src/helmizer.py", "request": "launch", "type": "python" + }, + { + "args": [ + "--debug", + "/home/drew/Nextcloud/TECH/git/private/lab-k8s/flux/kustomize/helm/cert-manager/helmizer.yaml" + ], + "console": "integratedTerminal", + "cwd": "${workspaceFolder}", + "name": "TEMP", + "program": "${workspaceFolder}/src/helmizer.py", + "request": "launch", + "type": "python" } ], "version": "0.2.0" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cd9f78..a48983b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog - [Changelog](#changelog) + - [v0.10.0](#v0100) - [v0.9.1](#v091) - [v0.9.0](#v090) - [v0.8.0](#v080) @@ -14,6 +15,23 @@ --- +## [v0.10.0](https://github.com/DaemonDude23/helmizer/releases/tag/v0.10.0) + +January 21 2022 + +**Bugfixes** + +- Fixed `helmizer.ignore` to optionally ignore directories recursively so that one doesn't have to enumerate each individual file path. + +**Enhancements** + +- Added CI for generating PyInstaller images for Linux and Windows. + +**Housekeeping** + +- `pre-commit` updates. +- Tweaked `requirements`. + ## [v0.9.1](https://github.com/DaemonDude23/helmizer/releases/tag/v0.9.1) November 11 2021 @@ -31,7 +49,7 @@ November 7 2021 - Fixed exceptions when not including keys in helmizer.yaml, falling back to defaults if not defined. -**Enhancements:** +**Enhancements** - Added configuration support for **all** keys in a kustomization. - Standardized functions to return various data types depending on kustomization key structure @@ -46,7 +64,7 @@ November 7 2021 June 10 2021 -**Enhancements:** +**Enhancements** - Added configuration support for: - [`components`](https://kubectl.docs.kubernetes.io/guides/config_management/components/) diff --git a/README.md b/README.md index 2595553..287916a 100644 --- a/README.md +++ b/README.md @@ -171,8 +171,11 @@ sudo ln -s /absolute/path/to/src/helmizer.py /usr/local/bin/helmizer ``` 2. Install dependencies: ```bash +# latest and greatest dependency versions pip3 install -U -r ./src/requirements.txt -pip3 install -U -r ./src/requirements-newest.txt + +# more flexible requirements +pip3 install -U -r ./src/requirements-old.txt ``` ### virtualenv with pip diff --git a/build.sh b/build.sh index 6d91251..6960a7e 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,6 @@ set -e TAG="${1}" -#REGISTRY_URL="docker.pkg.github.com/DaeonDude23/helmizer/helmizer" REGISTRY_URL="docker.k8s.home/daemondude23/helmizer/helmizer" if [ $# -eq 0 ]; then diff --git a/src/helmizer-linux-x86_64.spec b/src/helmizer-linux-x86_64.spec new file mode 100644 index 0000000..1ed90ea --- /dev/null +++ b/src/helmizer-linux-x86_64.spec @@ -0,0 +1,39 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis(['helmizer.py'], + pathex=['./src/'], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) + +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='helmizer-linux-x86_64', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None ) diff --git a/src/helmizer-windows-x86_64.spec b/src/helmizer-windows-x86_64.spec new file mode 100644 index 0000000..93f31e4 --- /dev/null +++ b/src/helmizer-windows-x86_64.spec @@ -0,0 +1,39 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis(['helmizer.py'], + pathex=['./src/'], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) + +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='helmizer-windows-x86_64', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None ) diff --git a/src/helmizer.py b/src/helmizer.py index 4b42ec2..439d6bb 100755 --- a/src/helmizer.py +++ b/src/helmizer.py @@ -76,7 +76,6 @@ def sort_keys(self): pass logging.debug("keys sorted") - def print_kustomization(self): try: print(yaml.dump(self.yaml, sort_keys=False)) @@ -174,20 +173,30 @@ def get_files(self, arguments, key): elif validate_url(str_child_path): list_target_paths.append(str_child_path) - # convert absolute paths into paths relative to the kustomization directory - for final_target_path in list_target_paths: - list_final_target_paths.append(path.relpath(final_target_path, str_kustomization_path)) - # remove any ignored files try: + # walk directory to remove multiple files for ignore in self.helmizer_config["helmizer"]["ignore"].get(list): - logging.debug(f"Removing ignored file from final list: {ignore}") - list_final_target_paths.remove(ignore) + str_ignore_abspath = path.abspath(path.join(str_kustomization_path, ignore)) + if path.isdir(str_ignore_abspath): + for (dirpath, _, filenames) in walk(str_ignore_abspath): + for filename in filenames: + file_path = path.join(dirpath, filename) + logging.debug(f"Removing ignored file from final list: {file_path}") + list_target_paths.remove(file_path) + # remove a file + else: + logging.debug(f"Removing ignored file from final list: {path.join(str_kustomization_path, ignore)}") + list_target_paths.remove(path.join(str_kustomization_path, ignore)) # just one file except ValueError: pass except NotFoundError: pass + # convert absolute paths into paths relative to the kustomization directory + for final_target_path in list_target_paths: + list_final_target_paths.append(path.relpath(final_target_path, str_kustomization_path)) + return list_final_target_paths except NotFoundError: diff --git a/src/requirements-newest.txt b/src/requirements-newest.txt deleted file mode 100644 index d643751..0000000 --- a/src/requirements-newest.txt +++ /dev/null @@ -1,3 +0,0 @@ -confuse==1.6.0 # https://pypi.org/project/confuse/ -PyYaml==6.0.0 # https://pypi.org/project/PyYAML/ -validators==0.18.0 # https://pypi.org/project/validators/ diff --git a/src/requirements-old.txt b/src/requirements-old.txt new file mode 100644 index 0000000..9b850e9 --- /dev/null +++ b/src/requirements-old.txt @@ -0,0 +1,4 @@ +# these are mostly untested guestimates, but more loose to avoid dependency hell +confuse>=1.0.0 # https://pypi.org/project/confuse/ +PyYaml>=5.0.0 # https://pypi.org/project/PyYAML/ +validators>=0.14.0 # https://pypi.org/project/validators/ diff --git a/src/requirements.txt b/src/requirements.txt index 055958d..cd7757f 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -1,4 +1,5 @@ -# these are mostly untested guestimates, but more loose to avoid dependency hell -confuse>=1.4.0 # https://pypi.org/project/confuse/ -PyYaml>=5.3.1 # https://pypi.org/project/PyYAML/ -validators>=0.18.0 # https://pypi.org/project/validators/ +confuse==1.6.0 +decorator==5.1.0 +PyYAML==6.0 +six==1.16.0 +validators==0.18.0