Skip to content

Commit bd77aed

Browse files
bin: set repo version in init script
Co-authored-by: Fredrik Liv <[email protected]>
1 parent a3451c7 commit bd77aed

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

bin/common.bash

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ check_tools() {
145145
fi
146146
}
147147

148+
# Retrieve version from git
149+
get_repo_version() {
150+
pushd "${root_path}" >/dev/null || exit 1
151+
git describe --exact-match --tags 2>/dev/null || git rev-parse HEAD
152+
popd >/dev/null || exit 1
153+
}
154+
148155
validate_sops_config() {
149156
if [ ! -f "${sops_config}" ]; then
150157
log_error "ERROR: SOPS config not found: ${sops_config}"

bin/init.bash

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ cp -r "${config_defaults_path}/common/group_vars" "${config_path}/"
6161

6262
cp -r --dereference "${config_defaults_path}/${flavor}/group_vars" "${config_path}/"
6363

64+
# Set ck8sKubesprayVersion to be the current repo version
65+
CK8S_KUBESPRAY_VERSION=$(get_repo_version)
66+
export CK8S_KUBESPRAY_VERSION
67+
yq -i ".ck8sKubesprayVersion = \"${CK8S_KUBESPRAY_VERSION}\"" "${CK8S_CONFIG_PATH}/${prefix}-config/group_vars/all/ck8s-kubespray-general.yaml"
68+
6469
# Copy inventory.ini
6570
if [[ ! -f "${config[inventory_file]}" ]]; then
6671
PREFIX=${prefix} envsubst >"${config[inventory_file]}" <"${config_defaults_path}/inventory.ini"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ck8sKubesprayVersion: v2.27.0-ck8s1
1+
ck8sKubesprayVersion: run-init-to-set
22
control_plane_label: node-role.kubernetes.io/control-plane
33
group_label_primary: elastisys.io/node-type
44
group_label_secondary: elastisys.io/ams-cluster-name

0 commit comments

Comments
 (0)