forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-manifests.sh
More file actions
executable file
·67 lines (52 loc) · 2.17 KB
/
generate-manifests.sh
File metadata and controls
executable file
·67 lines (52 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Credit: https://github.com/DataDog/datadog-agent/blob/7.32.4/Dockerfiles/manifests/generate.sh
set -euo pipefail
IFS=$'\n\t'
if sed --version 2>/dev/null | grep -q "GNU sed"; then
SED="sed"
elif gsed --version 2>/dev/null | grep -q "GNU sed"; then
SED="gsed"
fi
cd "$(dirname "${BASH_SOURCE[0]}")/.."
helm repo add vector https://helm.vector.dev
helm repo update
TMPDIR=$(mktemp -d)
trap 'rm -r $TMPDIR' EXIT
cat > "$TMPDIR/values-vector-agent.yaml" <<EOF
role: Agent
service:
enabled: false
EOF
cat > "$TMPDIR/values-vector-aggregator.yaml" <<EOF
EOF
cat > "$TMPDIR/values-vector-stateless-aggregator.yaml" <<EOF
role: Stateless-Aggregator
EOF
CLEANUP_INSTRUCTIONS='del(.metadata.labels."helm.sh/chart") | del(.metadata.labels."app.kubernetes.io/managed-by") | del(.metadata.annotations.checksum/*) | del(.spec.template.metadata.annotations.checksum/*)'
for values in "$TMPDIR"/values-*.yaml; do
type=${values##*values-}
type=${type%.yaml}
rm -rf "${type:?}"
mkdir "${type:?}"
helm template --namespace default vector vector/vector --values "$values" --output-dir "$TMPDIR/generated_$type"
for file in "$TMPDIR/generated_$type"/vector/templates/*.yaml; do
# Skip files containing only comments
if [[ "$(yq eval '. | length' "$file")" == 0 ]]; then
rm "$file"
continue
fi
# We want this to output without expansion
# shellcheck disable=SC2016
${SED:-sed} -E -i 's/^# Source: (.*)/# This file has been generated by `helm template vector vector\/vector` from \1. Please re-run `make generate-kubernetes-manifests` rather than modifying this file manually./' "$file"
yq eval "$CLEANUP_INSTRUCTIONS" "$file" > "distribution/kubernetes/$type/$(basename "$file")"
done
cat > "distribution/kubernetes/$type/README.md" <<EOF
The kubernetes manifests found in this directory have been automatically generated
from the [helm chart \`vector/vector\`](https://github.com/vectordotdev/helm-charts/tree/master/charts/vector)
version $(helm show chart vector/vector | yq e '.version' -) with the following \`values.yaml\`:
\`\`\`yaml
$(<"$values")
\`\`\`
EOF
rm -rf "${type:?}"
done