From 08a587b3363f83a18a9b1cfe3951f330f2fa7975 Mon Sep 17 00:00:00 2001 From: bdeshi Date: Thu, 7 May 2026 16:24:25 +0600 Subject: [PATCH] feat: add plugin code, dockerfile, and docs --- .dockerignore | 0 Dockerfile | 8 +++++++ LICENSE | 18 +++++++++++++++ README.md | 5 ++++ YqTransformer.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100755 YqTransformer.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b89d81d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +ARG YQVERSION=4.48.1 +FROM mikefarah/yq:${YQVERSION} + +COPY --link --chmod=755 YqTransformer.sh /usr/local/bin/YqTransformer.sh +USER root +RUN apk add --no-cache bash +USER 1000 +ENTRYPOINT ["/usr/local/bin/YqTransformer.sh"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c9fe01a --- /dev/null +++ b/LICENSE @@ -0,0 +1,18 @@ +MIT License + +Copyright (c) 2026 bdeshi + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO +EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1c9bce9 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# kustomize-plugin-yqtransformer + +This is a Kustomize plugin that modifies resources with [yq][yq] expressions. + +[yq]: https://github.com/mikefarah/yq diff --git a/YqTransformer.sh b/YqTransformer.sh new file mode 100755 index 0000000..e27e2b9 --- /dev/null +++ b/YqTransformer.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# this kustomize transformer plugin modifies resources with yq expressions. +# the plugin accepts the following manifest structure: +# ```yaml +# targets: +# - +# expression: +# ``` +# where each `target filter` is a partial resource manifest. the `yq expression` +# is applied to any resources that match *all attributes* in any target filter. + +set -euo pipefail + +# collect inputs +resource_list="$(