-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-repo.sh
executable file
·63 lines (50 loc) · 1.98 KB
/
setup-repo.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
#!/usr/bin/env bash
##
set -o errexit -o nounset -o pipefail
#set -o xtrace
function usage() {
echo "Create Tanzu Sync-managed cluster configuration directory tree"
echo ""
echo " $0 (cluster-name) (secrets-manager)"
echo ""
echo "where:"
echo "- cluster-name :: name of directory under ./clusters to place cluster configuration."
echo "- secrets-manager = {aws-secrets-manager,vault,sops} :: which secrets management system secrets are stored in."
echo ""
}
if [[ ! $# -eq 2 ]]; then
usage
exit 1
fi
cluster_name="$1"
secrets_manager="$2"
catalog_dir=".catalog"
tanzu_sync_version="${TS_VERSION:-0.5.0}"
tap_version="1.9.0"
if [[ ! ",aws-secrets-manager,vault,sops," =~ (,${secrets_manager},) ]]; then
usage
echo "Error: (secrets-manager); wanted: one of [\"aws-secrets-manager\", "\vault", \"sops\"]; got: \"${secrets_manager}\"."
exit 2
fi
# remove old tanzu managed directories
if [[ -d "clusters/${cluster_name}/tanzu-sync/app/config/.tanzu-managed" ]]; then
rm -r clusters/"${cluster_name}"/tanzu-sync/app/config/.tanzu-managed/*
fi
if [[ -d "clusters/${cluster_name}/cluster-config/config/tap-install/.tanzu-managed" ]]; then
rm -r clusters/"${cluster_name}"/cluster-config/config/tap-install/.tanzu-managed/*
fi
mkdir -p clusters/"${cluster_name}"
# Setup tanzu-sync directory
cp -R ${catalog_dir}/tanzu-sync/${tanzu_sync_version}/${secrets_manager}/ clusters/"${cluster_name}"/tanzu-sync/
# Setup cluster-config directory
mkdir -p clusters/"${cluster_name}"/cluster-config/{config,values}
mkdir -p clusters/"${cluster_name}"/cluster-config/config/tap-install/.tanzu-managed
cp -R ${catalog_dir}/tap-install/${tap_version}/${secrets_manager}/config/.tanzu-managed clusters/"${cluster_name}"/cluster-config/config/tap-install
echo "Created cluster configuration in ./clusters/${cluster_name}."
echo ""
echo "Next steps:"
echo "$ git add . && git commit -m \"Add ${cluster_name}\""
echo "$ git push -u origin"
echo "$ cd clusters/${cluster_name}"
echo "$ less README.md"
# vim:ft=sh