mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-27 18:18:41 +00:00
This PR introduces a new fluxcd-kustomize.sh script that can be used as post-processor for helm for adding a common fluxcd labels. This is very useful for `make diff`, so it will not include diff between these labels anymore Also for debugging specific kustomize cases, eg: - https://github.com/fluxcd/helm-controller/issues/283 - https://github.com/fluxcd/flux2/issues/4368 Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
38 lines
825 B
Bash
Executable File
38 lines
825 B
Bash
Executable File
#!/bin/sh
|
|
# This scripts adds common fluxcd labels to all objects
|
|
|
|
if [ -z "$NAME" ]; then
|
|
echo 'Variable $NAME is not set!' >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$NAMESPACE" ]; then
|
|
echo 'Variable $NAMESPACE is not set!' >&2
|
|
exit 1
|
|
fi
|
|
|
|
TMP_DIR=$(mktemp -d)
|
|
cat - > "${TMP_DIR}/helm-generated-output.yaml"
|
|
cat > "${TMP_DIR}/global-labels.yaml" <<EOT
|
|
apiVersion: builtin
|
|
kind: LabelTransformer
|
|
metadata:
|
|
name: global-labels
|
|
labels:
|
|
helm.toolkit.fluxcd.io/name: ${NAME}
|
|
helm.toolkit.fluxcd.io/namespace: ${NAMESPACE:-$HELM_NAMESPACE}
|
|
fieldSpecs:
|
|
- path: metadata/labels
|
|
create: true
|
|
EOT
|
|
cat > "${TMP_DIR}/kustomization.yaml" <<EOT
|
|
resources:
|
|
- helm-generated-output.yaml
|
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
kind: Kustomization
|
|
transformers:
|
|
- global-labels.yaml
|
|
EOT
|
|
kubectl kustomize "${TMP_DIR}"
|
|
rm -rf "${TMP_DIR}"
|