Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make script paths relative #79

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/gitops-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +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_REPO="$HOME/devel/understack"
UC_DEPLOY="$HOME/devel/uc-deploy"
UC_DEPLOY="$(pwd)/$(dirname ${BASH_SOURCE[0]})"
DEPLOY_NAME="my-k3s"
[email protected]:myorg/uc-deploy.git
UC_DEPLOY_SSH_FILE="$HOME/devel/uc-deploy-key"
Expand Down
2 changes: 2 additions & 0 deletions scripts/gitops-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ fi

. "$1"

export UC_REPO="$(git rev-parse --show-toplevel)"

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

source "$1"
. "$1"

export UC_REPO="$(git rev-parse --show-toplevel)"

if [ ! -d "${UC_DEPLOY}" ]; then
echo "UC_DEPLOY not set to a path." >&2
Expand All @@ -30,19 +32,21 @@ if [ "x${DEPLOY_NAME}" = "x" ]; then
usage
fi

if [ "x${UC_DEPLOY_GIT_URL}" = "x" ]; then
echo "UC_DEPLOY_GIT_URL is not set." >&2
usage
fi

if [ "x${UC_DEPLOY_SSH_FILE}" = "x" ]; then
echo "UC_DEPLOY_SSH_FILE is not set." >&2
usage
fi

if [ ! -f "${UC_DEPLOY_SSH_FILE}" ]; then
echo "UC_DEPLOY_SSH_FILE is not a file." >&2
usage
if [ -f "${UC_DEPLOY}/secrets/${DEPLOY_NAME}/argocd/secret-deploy-repo.yaml" ]; then
NO_SECRET_DEPLOY=1
else
if [ "x${UC_DEPLOY_GIT_URL}" = "x" ]; then
echo "UC_DEPLOY_GIT_URL is not set." >&2
usage
fi
if [ "x${UC_DEPLOY_SSH_FILE}" = "x" ]; then
echo "UC_DEPLOY_SSH_FILE is not set." >&2
usage
fi
if [ ! -f "${UC_DEPLOY_SSH_FILE}" ]; then
echo "UC_DEPLOY_SSH_FILE at ${UC_DEPLOY_SSH_FILE} does not exist." >&2
usage
fi
fi

if [ "x${DNS_ZONE}" = "x" ]; then
Expand All @@ -62,9 +66,10 @@ export DO_TMPL_VALUES=y
mkdir -p "${UC_DEPLOY}/secrets/${DEPLOY_NAME}"
"${SCRIPTS_DIR}/easy-secrets-gen.sh" "${UC_DEPLOY}/secrets/${DEPLOY_NAME}"

echo "Creating ArgoCD config"
mkdir -p "${UC_DEPLOY}/secrets/${DEPLOY_NAME}/argocd"
cat << EOF > "${UC_DEPLOY}/secrets/${DEPLOY_NAME}/argocd/secret-deploy-repo.yaml"
if [ "x${NO_SECRET_DEPLOY}" = "x" ]; then
echo "Creating ArgoCD config"
mkdir -p "${UC_DEPLOY}/secrets/${DEPLOY_NAME}/argocd"
cat << EOF > "${UC_DEPLOY}/secrets/${DEPLOY_NAME}/argocd/secret-deploy-repo.yaml"
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -76,6 +81,7 @@ data:
type: $(printf "git" | base64)
url: $(printf "${UC_DEPLOY_GIT_URL}" | base64)
EOF
fi

echo "Creating Cert Manager Cluster Issuer"
cat << EOF > "${UC_DEPLOY}/secrets/${DEPLOY_NAME}/cluster-issuer.yaml"
Expand Down
Loading