Skip to content

Commit

Permalink
Merge pull request #84 from rackerlabs/scripts
Browse files Browse the repository at this point in the history
fix: ensure UC_REPO/UC_DEPLOY are set correctly
  • Loading branch information
cardoe authored May 7, 2024
2 parents 44d9317 + bbf4e39 commit 5652c4a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/gitops-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To avoid defining many environment variables we'll simplify by creating an
place it where we've cloned understack. A complete file would like like

```bash title="/path/to/uc-deploy/my-k3s.env"
UC_DEPLOY="$(pwd)/$(dirname ${BASH_SOURCE[0]})"
UC_DEPLOY="$(cd "$(dirname ${BASH_SOURCE[0]})" && git rev-parse --show-toplevel)"
DEPLOY_NAME="my-k3s"
[email protected]:myorg/uc-deploy.git
UC_DEPLOY_SSH_FILE="$HOME/devel/uc-deploy-key"
Expand Down
9 changes: 8 additions & 1 deletion scripts/gitops-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ if [ $# -ne 1 ]; then
usage
fi

SCRIPTS_DIR=$(dirname "$0")

if [ ! -f "$1" ]; then
echo "Did not get a file with environment variables." >&2
usage
fi

# set temp path so we can reset it after import
UC_REPO_PATH="$(cd "${SCRIPTS_DIR}" && git rev-parse --show-toplevel)"
export UC_REPO="${UC_REPO_PATH}"

. "$1"

export UC_REPO="$(git rev-parse --show-toplevel)"
# set the value again after import
export UC_REPO="${UC_REPO_PATH}"

if [ ! -d "${UC_REPO}" ]; then
echo "UC_REPO not set to a path." >&2
Expand Down
7 changes: 6 additions & 1 deletion scripts/gitops-secrets-gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ if [ ! -f "$1" ]; then
usage
fi

# set temp path so we can reset it after import
UC_REPO_PATH="$(cd "${SCRIPTS_DIR}" && git rev-parse --show-toplevel)"
export UC_REPO="${UC_REPO_PATH}"

. "$1"

export UC_REPO="$(git rev-parse --show-toplevel)"
# set the value again after import
export UC_REPO="${UC_REPO_PATH}"

if [ ! -d "${UC_DEPLOY}" ]; then
echo "UC_DEPLOY not set to a path." >&2
Expand Down

0 comments on commit 5652c4a

Please sign in to comment.