diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 69f5eb2..ba97256 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: - id: requirements-txt-fixer - id: check-ast repo: 'https://github.com/pre-commit/pre-commit-hooks' - rev: v4.1.0 + rev: v4.2.0 - hooks: - id: black language_version: python3.9 @@ -37,7 +37,7 @@ repos: - --line-length - "140" repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.3.0 - repo: https://gitlab.com/pycqa/flake8 rev: 3.9.2 hooks: diff --git a/.vscode/launch.json b/.vscode/launch.json index c5bc7c1..f4c2e02 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -213,18 +213,6 @@ "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/.vscode/settings.json b/.vscode/settings.json index 9884fbc..af6330f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,8 +8,7 @@ "*test.py" ], "python.testing.pytestEnabled": false, - "python.testing.nosetestsEnabled": false, "python.testing.unittestEnabled": false, "python.testing.promptToConfigure": false, - "python.pythonPath": "/home/drew/Nextcloud/TECH/git/private/helmizer/venv/bin/python" + "python.defaultInterpreterPath": "./helmizer/venv/bin/python" } diff --git a/CHANGELOG.md b/CHANGELOG.md index a48983b..04cc6a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog - [Changelog](#changelog) + - [v0.11.0](#v0110) - [v0.10.0](#v0100) - [v0.9.1](#v091) - [v0.9.0](#v090) @@ -15,6 +16,18 @@ --- +## [v0.11.0](https://github.com/DaemonDude23/helmizer/releases/tag/v0.11.0) + +April 11 2022 + +**Enhancements** + +- Added support for `buildMetadata and `patches`. + +**Housekeeping** + +- Cleaned up vscode configs. + ## [v0.10.0](https://github.com/DaemonDude23/helmizer/releases/tag/v0.10.0) January 21 2022 diff --git a/README.md b/README.md index 78a359b..7f9c407 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,21 @@ ## About +**TLDR** + +Generates a `kustomization.yaml file`, optionally providing the ability to run commands (e.g. `helm template`) on your OS prior to generating a kustomization, and will compose the kustomization fields that deal with file paths (e.g. `resources`) with glob-like features, as well as pass-through all other kustomization configuration properties. No need to explicitly enumerate every file to be kustomized individually. + +It takes a config file as input, telling **Helmizer** if you want to run any commands. Then if you give it one or more directories for `resources`, for example, it will recursively lookup all of those files and render them into your kustomization.yaml. Want to skip including one file like `templates/secret.yaml`? Just add the relative path to `helmizer.ignore` to `helmizer.yaml`. + +--- + [Thou shall not _glob_](https://github.com/kubernetes-sigs/kustomize/issues/3205), said the **kustomize** developers (thus far). **Helmizer** takes various inputs from a YAML config file (`helmizer.yaml` by default) and constructs a [kustomization file](https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/) from those inputs. It can run a sequence of commands before rendering the kustomization file. Instead of manually entering the paths to [`resources`](https://kubectl.docs.kubernetes.io/references/kustomize/resource/) in a kustomization file, this tool will walk any number of directories containing resources and populate the kustomization with these resources. Or only pull in individual files, it's your choice. -I began transitioning my `helm` charts to local templates via [`helm template`](https://helm.sh/docs/helm/helm_template/), which were then applied to the cluster separately via [Kustomize](https://kustomize.io/). I didn't enjoy having to manually manage the relative paths to files in the **kustomization**. I wanted a repeatable process to generate **Kubernetes** manifests from a helm chart, _and_ tack on any patches or related resources later with a single command. Thus, **helmizer**. **But [Helm](https://helm.sh/) is in no way required to make this tool useful** - have it walk your raw manifests as well. - -**TLDR** - -Provides the ability to run commands (e.g. `helm template`) on your OS prior to generating a kustomization, and will compose the kustomization fields that deal with file paths (e.g. `resources`) with glob-like features, as well as pass-through all other kustomization configurations. No need to explicitly enumerate every file individually. +I began transitioning my `helm` charts to local manifests via [`helm template`](https://helm.sh/docs/helm/helm_template/), which were then applied to the cluster separately via [Kustomize](https://kustomize.io/). I didn't enjoy having to manually manage the relative paths to files in the **kustomization**. I wanted a repeatable process to generate **Kubernetes** manifests from a helm chart, _and_ tack on any patches or related resources later with a single command. Thus, **helmizer**. **But [Helm](https://helm.sh/) is in no way required to make this tool useful** - have it walk your raw manifests as well. This is just a wrapper that allows combining steps, and glob-like behavior, to managing `kustomization.yaml` files. ## Usage @@ -157,7 +161,7 @@ kustomize: # this is essentially an overlay for your eventual kustomization.yam For local installation/use of the raw script, I use a local virtual environment to isolate dependencies: ```bash -git clone https://github.com/DaemonDude23/helmizer.git -b v0.10.0 +git clone https://github.com/DaemonDude23/helmizer.git -b v0.11.0 cd helmizer ``` @@ -274,7 +278,7 @@ In this example (*Nix OS), we're redirecting program output to the (e.g. `kustom docker run --name helmizer \ --rm \ -v "$PWD"/examples:/tmp/helmizer -w /tmp/helmizer \ - docker.pkg.github.com/DaemonDude23/helmizer/helmizer:v0.10.0 /usr/src/app/helmizer.py \ + docker.pkg.github.com/DaemonDude23/helmizer/helmizer:v0.11.0 /usr/src/app/helmizer.py \ ./resources/ > ./examples/resources/kustomization.yaml ``` diff --git a/src/helmizer.py b/src/helmizer.py index d06d196..64d4e48 100755 --- a/src/helmizer.py +++ b/src/helmizer.py @@ -41,7 +41,7 @@ def __init__(self, helmizer_config, arguments): pass # get lists - for key in ["configMapGenerator", "images", "patchesJson6902", "replicas", "replacements", "vars"]: + for key in ["buildMetadata", "configMapGenerator", "images", "patches", "patchesJson6902", "replicas", "replacements", "vars"]: try: list_key = self.get_list(key) if list_key: @@ -216,10 +216,8 @@ def get_dict(self, key): logging.debug(f"{key}: {dict_raw_yaml}") except NotFoundError: logging.debug(f"key not found: {key}") - pass except KeyError: logging.debug(f"key not found: {key}") - pass except TypeError: pass return dict_raw_yaml @@ -232,10 +230,8 @@ def get_str(self, key): logging.debug(f"{key}: {str_raw_yaml}") except NotFoundError: logging.debug(f"key not found: {key}") - pass except KeyError: logging.debug(f"key not found: {key}") - pass except TypeError: pass return str_raw_yaml @@ -248,10 +244,8 @@ def get_list(self, key): logging.debug(f"{key}: {list_raw_yaml}") except NotFoundError: logging.debug(f"key not found: {key}") - pass except KeyError: logging.debug(f"key not found: {key}") - pass except TypeError: pass return list_raw_yaml @@ -335,7 +329,7 @@ def init_arg_parser(): help="quiet output from subprocesses", default=False, ) - args.add_argument("--version", "-v", action="version", version="v0.10.0") + args.add_argument("--version", "-v", action="version", version="v0.11.0") args.add_argument( "helmizer_config", action="store",