|
3 | 3 | # Cluster Stack Creation automation
|
4 | 4 | #
|
5 | 5 |
|
6 |
| -set export |
| 6 | +set export := true |
7 | 7 | set dotenv-filename := "just.env"
|
8 |
| -set dotenv-load |
| 8 | +set dotenv-load := true |
9 | 9 |
|
10 | 10 | path := env_var('PATH') + ":" + justfile_directory() + "/bin"
|
| 11 | +repo := "https://github.com/SovereignCloudStack/cluster-stacks" |
| 12 | +mainBranch := "main" |
| 13 | +workingBranchPrefix := "chore/update-" |
| 14 | +targetBranchPrefix := "release-" |
11 | 15 |
|
| 16 | +# Show available commands |
12 | 17 | default:
|
13 |
| - @just --list --justfile {{justfile()}} |
| 18 | + @just --list --justfile {{ justfile() }} |
| 19 | + |
| 20 | +# Show available commands |
| 21 | +help: default |
14 | 22 |
|
15 | 23 | # Check if csctl and clusterstack-provider-openstack are available and build them if neccessary
|
16 | 24 | [no-cd]
|
17 | 25 | ensure-dependencies:
|
18 |
| - #!/usr/bin/env bash |
19 |
| - export PATH=${path} |
20 |
| - if ! which csctl >/dev/null 2>&1;then |
21 |
| - echo "csctl not found, building it from source." |
22 |
| - mkdir -p bin |
23 |
| - pushd bin |
24 |
| - git clone https://github.com/SovereignCloudStack/csctl csctl-git |
25 |
| - pushd csctl-git |
26 |
| - make build |
27 |
| - mv csctl ../csctl |
28 |
| - popd |
29 |
| - rm -rf csctl-git |
30 |
| - popd |
31 |
| - fi |
32 |
| - |
33 |
| - if ! which csctl-openstack >/dev/null 2>&1; then |
34 |
| - echo "csctl-plugin-openstack not found, building it from source." |
35 |
| - mkdir -p bin |
36 |
| - pushd bin |
37 |
| - git clone https://github.com/SovereignCloudStack/csctl-plugin-openstack |
38 |
| - pushd csctl-plugin-openstack |
39 |
| - make build |
40 |
| - mv csctl-openstack ../csctl-openstack |
41 |
| - popd |
42 |
| - rm -rf csctl-plugin-openstack |
43 |
| - popd |
44 |
| - fi |
45 |
| - |
46 |
| - if [[ -d bin ]]; then |
47 |
| - export PATH="${PATH}:$(pwd)/bin" |
48 |
| - fi |
| 26 | + #!/usr/bin/env bash |
| 27 | + set -euxo pipefail |
| 28 | + export PATH=${path} |
| 29 | + if ! which csctl >/dev/null 2>&1;then |
| 30 | + echo "csctl not found, building it from source." |
| 31 | + mkdir -p bin |
| 32 | + pushd bin |
| 33 | + git clone https://github.com/SovereignCloudStack/csctl csctl-git |
| 34 | + pushd csctl-git |
| 35 | + make build |
| 36 | + mv csctl ../csctl |
| 37 | + popd |
| 38 | + rm -rf csctl-git |
| 39 | + popd |
| 40 | + fi |
| 41 | + |
| 42 | + if ! which csctl-openstack >/dev/null 2>&1; then |
| 43 | + echo "csctl-plugin-openstack not found, building it from source." |
| 44 | + mkdir -p bin |
| 45 | + pushd bin |
| 46 | + git clone https://github.com/SovereignCloudStack/csctl-plugin-openstack |
| 47 | + pushd csctl-plugin-openstack |
| 48 | + make build |
| 49 | + mv csctl-openstack ../csctl-openstack |
| 50 | + popd |
| 51 | + rm -rf csctl-plugin-openstack |
| 52 | + popd |
| 53 | + fi |
| 54 | + |
| 55 | + if ! which yq; then |
| 56 | + mkdir -p bin |
| 57 | + wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O bin/yq &&\ |
| 58 | + chmod +x bin/yq |
| 59 | + fi |
49 | 60 |
|
50 | 61 | # Clean temporary files and binaries
|
| 62 | +[no-cd] |
51 | 63 | clean:
|
52 |
| - #!/usr/bin/env bash |
53 |
| - rm -rf bin |
| 64 | + rm -rf bin |
| 65 | + |
| 66 | +# Build Clusterstacks version directories according to changes in versions.yaml. Builds out directoy |
| 67 | +[no-cd] |
| 68 | +build-versions: ensure-dependencies |
| 69 | + #!/usr/bin/env bash |
| 70 | + changedVersions=$(just diff) |
| 71 | + for version in ${changedVersions[@]}; do |
| 72 | + ./hack/generate_version.py --target-version ${version} |
| 73 | + done |
| 74 | + |
| 75 | +# Generate manifest for all Kubernetes Version regardless of changes to versions. |
| 76 | +[no-cd] |
| 77 | +build-versions-all: ensure-dependencies |
| 78 | + ./hack/generate_version.py --build |
54 | 79 |
|
55 |
| -# Build Clusterstacks version |
56 |
| -build: ensure-dependencies |
57 |
| - ./hack/generate_version.py --build |
| 80 | +# Generate Manifest for a specific Kubernetes version. Builds out directory |
| 81 | +[no-cd] |
| 82 | +build-version VERSION: |
| 83 | + ./hack/generate_version.py --target-version {{VERSION}} |
| 84 | + |
| 85 | +# Build assets for a certain Kubernetes Version. Out directory needs to be present. |
| 86 | +[no-cd] |
| 87 | +build-assets-local-for VERSION: ensure-dependencies |
| 88 | + csctl create -m hash providers/openstack/out/{{replace(VERSION, ".", "-")}}/ |
| 89 | + |
| 90 | +# Build assets for a certain Kubernetes Version. Out directory needs to be present. |
| 91 | +[no-cd] |
| 92 | +build-assets-local: ensure-dependencies |
| 93 | + #!/usr/bin/env bash |
| 94 | + export PATH=${path} |
| 95 | + changedVersions=$(just diff) |
| 96 | + for version in ${changedVersions[@]}; do |
| 97 | + csctl create -m hash providers/openstack/out/${version//./-}/ |
| 98 | + done |
| 99 | + |
| 100 | +# Calculate the diff in the versions.yaml files to get relevant versions |
| 101 | +[no-cd] |
| 102 | +diff: |
| 103 | + #!/usr/bin/env bash |
| 104 | + set -euo pipefail |
| 105 | + versionsPath="providers/openstack/scs/versions.yaml" |
| 106 | + currentVersions=$(cat ${versionsPath}) |
| 107 | + mainVersions=$(git show ${mainBranch}:${versionsPath}) |
| 108 | + kubernetesVersions=$(yq -r '.[].kubernetes' ${versionsPath} | grep -Po "1\.\d+") |
| 109 | + toTest=() |
| 110 | + for version in ${kubernetesVersions}; do |
| 111 | + currentManifest=$(echo "${currentVersions}" | yq --sort-keys ".[] | select(.kubernetes | test(\"${version}\"))") |
| 112 | + mainManifest=$(echo "${mainVersions}" | yq --sort-keys ".[] | select(.kubernetes | test(\"${version}\"))") |
| 113 | + if ! diff -q <(echo "$currentManifest") <(echo "$mainManifest") >/dev/null; then |
| 114 | + toTest=("${toTest[@]}" "${version}") |
| 115 | + fi |
| 116 | + done |
| 117 | + echo "${toTest[@]}" |
0 commit comments