Skip to content
Snippets Groups Projects
Unverified Commit 67acb93b authored by Timo Furrer's avatar Timo Furrer
Browse files

Check for dependencies when running gitlab-tofu

Changelog: feature
parent ee16f015
Branches master
No related tags found
No related merge requests found
#!/bin/sh -e
# ATTENTION: this script is yet JUST A COPY of https://gitlab.com/gitlab-org/terraform-images/-/blob/master/src/bin/gitlab-terraform.sh
# with some VERY MINIMAL MODIFICATIONS.
# It definitely needs cleanup in the future.
#!/usr/bin/env sh
# set some shell options
set -o errexit
if [ "${DEBUG_OUTPUT}" = "true" ]; then
set -x
set -o xtrace
fi
# Feature Flags
......@@ -37,6 +36,29 @@ else # All other shells: examine $0 for known shell binary filenames.
case ${0##*/} in sh|-sh|dash|-dash) sourced=1;; esac
fi
# Dependencies
# ============
# Defines all the external dependencies and checks if they exist, if not, abort with an error.
dependencies="dirname basename pwd sed idn2 jq tofu"
if [ -n "$ZSH_VERSION" ]; then
# ZSH is the only supported SHELL that does not split by word by default,
# so we set this option to actually do it.
setopt sh_word_split
fi
for dep in $dependencies; do
if ! command -v "$dep" >/dev/null 2>&1; then
echo "Error: gitlab-tofu is missing dependency: '$dep'" >&2
exit 1
fi
done
if [ -n "$ZSH_VERSION" ]; then
# see comment above when setting sh_word_split.
unsetopt sh_word_split
fi
JQ_PLAN='
(
[.resource_changes[]?.change.actions?] | flatten
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment