forked from kubernetes-sigs/kwok
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-helm-charts.sh
executable file
·84 lines (68 loc) · 2.81 KB
/
update-helm-charts.sh
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# Copyright 2024 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
DIR="$(dirname "${BASH_SOURCE[0]}")"
ROOT_DIR="$(realpath "${DIR}/..")"
function sync_object_to_chart() {
local src=$1
local dest=$2
sed \
-e ':a;N;$!ba;s#metadata:\n name: kwok-controller\n#metadata:\n name: {{ include "kwok.fullname" . }}\n labels:\n {{- include "kwok.labels" . | nindent 4 }}\n#g' \
-e 's#kwok-controller#{{ include "kwok.fullname" . }}#g' \
-e 's#kube-system#{{ .Release.Namespace }}#g' \
<"${src}" \
>"${dest}"
}
function sync_stage_to_chart() {
local src=$1
local dest=$2
sed \
-e 's#{{#{{ `{{#g' \
-e 's#}}#}}` }}#g' \
-e "s#\`\"\"\`#\"\\\\\"\\\\\"\"#g" \
<"${src}" \
>"${dest}"
}
function sync_to_chart() {
local src=$1
local dest=$2
cp "${src}" "${dest}"
}
function update_readme() {
local chart=$1
go run github.com/norwoodj/helm-docs/cmd/[email protected] \
-c charts/ \
-t ./_templates.gotmpl \
-t README.md.gotmpl \
-g "charts/${chart}"
}
function sync() {
sync_object_to_chart kustomize/rbac/role.yaml charts/kwok/templates/role.yaml
sync_object_to_chart kustomize/rbac/role_binding.yaml charts/kwok/templates/role_binding.yaml
sync_object_to_chart kustomize/rbac/service_account.yaml charts/kwok/templates/service_account.yaml
sync_stage_to_chart kustomize/stage/pod/fast/pod-ready.yaml charts/stage-fast/templates/pod-ready.yaml
sync_stage_to_chart kustomize/stage/pod/fast/pod-complete.yaml charts/stage-fast/templates/pod-complete.yaml
sync_stage_to_chart kustomize/stage/pod/fast/pod-delete.yaml charts/stage-fast/templates/pod-delete.yaml
sync_stage_to_chart kustomize/stage/node/fast/node-initialize.yaml charts/stage-fast/templates/node-initialize.yaml
sync_stage_to_chart kustomize/stage/node/heartbeat-with-lease/node-heartbeat-with-lease.yaml charts/stage-fast/templates/node-heartbeat-with-lease.yaml
sync_stage_to_chart kustomize/metrics/resource/metrics-resource.yaml charts/metrics-usage/templates/metrics-resource.yaml
sync_stage_to_chart kustomize/metrics/usage/usage-from-annotation.yaml charts/metrics-usage/templates/usage-from-annotation.yaml
update_readme kwok
update_readme stage-fast
update_readme metrics-usage
}
cd "${ROOT_DIR}" && sync