forked from baron/baron-sso
50 lines
1.3 KiB
Bash
50 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
create_manifest() {
|
|
local backup_dir="$1"
|
|
local mode="$2"
|
|
local services="$3"
|
|
local dataset="${4:-full}"
|
|
local repo_root
|
|
local created_at
|
|
local git_commit
|
|
local service
|
|
local first=1
|
|
local environment_scope="same-env-only"
|
|
|
|
if [[ "$dataset" == "personnel" ]]; then
|
|
environment_scope="staging-rehearsal"
|
|
fi
|
|
|
|
repo_root="$(backup_repo_root)"
|
|
created_at="$(backup_utc_now)"
|
|
git_commit="$(backup_git_commit "$repo_root")"
|
|
|
|
{
|
|
printf '{\n'
|
|
printf ' "format_version": "1",\n'
|
|
printf ' "created_at": "%s",\n' "$created_at"
|
|
printf ' "git_commit": "%s",\n' "$git_commit"
|
|
printf ' "mode": "%s",\n' "$mode"
|
|
printf ' "dataset": "%s",\n' "$dataset"
|
|
printf ' "environment_scope": "%s",\n' "$environment_scope"
|
|
printf ' "services": ['
|
|
for service in $services; do
|
|
if [[ "$first" -eq 1 ]]; then
|
|
first=0
|
|
else
|
|
printf ', '
|
|
fi
|
|
printf '"%s"' "$service"
|
|
done
|
|
printf '],\n'
|
|
printf ' "restore_policy": {\n'
|
|
printf ' "requires_empty_target": true,\n'
|
|
printf ' "requires_confirmation": "baron-sso",\n'
|
|
printf ' "auto_run_migrations": false,\n'
|
|
printf ' "works_relay_auto_resume": false\n'
|
|
printf ' }\n'
|
|
printf '}\n'
|
|
} >"$backup_dir/manifest.json"
|
|
}
|