Skip to content
Snippets Groups Projects
Commit 12ef289a authored by Timo Furrer's avatar Timo Furrer
Browse files

Merge branch 'check-deps' into 'main'

Check for dependencies when running gitlab-tofu

See merge request components/opentofu!146
parents a5b1b23e 67acb93b
No related branches found
No related tags found
No related merge requests found
#!/bin/sh -e #!/usr/bin/env sh
# 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.
# set some shell options
set -o errexit
if [ "${DEBUG_OUTPUT}" = "true" ]; then if [ "${DEBUG_OUTPUT}" = "true" ]; then
set -x set -o xtrace
fi fi
# Feature Flags # Feature Flags
...@@ -37,6 +36,29 @@ else # All other shells: examine $0 for known shell binary filenames. ...@@ -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 case ${0##*/} in sh|-sh|dash|-dash) sourced=1;; esac
fi 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=' JQ_PLAN='
( (
[.resource_changes[]?.change.actions?] | flatten [.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