feat: APPS_DIR environment layer (Plan 14 step 2)
new-service/delete-service read and write $GITOPS_DIR/$APPS_DIR (default apps-homelab) instead of the literal apps/; FORGEJO_URL moves to git.holtlabs.xyz. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5b4987a371
commit
11c68770e1
5 changed files with 23 additions and 19 deletions
|
|
@ -45,7 +45,7 @@ OWN_NS=0
|
|||
|
||||
# Refuse to pull a namespace out from under a frontend co-located with us.
|
||||
dependents=()
|
||||
for f in "$GITOPS_DIR"/apps/*.yaml; do
|
||||
for f in "$GITOPS_DIR/$APPS_DIR"/*.yaml; do
|
||||
other=$(basename "$f" .yaml)
|
||||
[[ $other != "$NAME" && $(app_namespace "$other") == "$NAME" ]] && dependents+=("$other")
|
||||
done
|
||||
|
|
@ -54,7 +54,7 @@ done
|
|||
APP_DIR=$CODE_DIR/$NAME
|
||||
cat >&2 <<EOF
|
||||
This permanently deletes, for service '$NAME':
|
||||
- gitops apps/$NAME.yaml and manifests/$NAME/ (ArgoCD prunes the workloads)
|
||||
- gitops $APPS_DIR/$NAME.yaml and manifests/$NAME/ (ArgoCD prunes the workloads)
|
||||
- $([[ $OWN_NS == 1 ]] && echo "namespace $NAME, including its Postgres data (PVCs)" || echo "nothing else in shared namespace $NS (left in place)")
|
||||
- Forgejo repo $FORGEJO_OWNER/$NAME and its container package versions
|
||||
- local clone $APP_DIR
|
||||
|
|
@ -72,7 +72,7 @@ if kubectl get application -n argocd "$NAME" >/dev/null 2>&1; then
|
|||
-p '{"metadata":{"finalizers":["resources-finalizer.argocd.argoproj.io"]}}' >/dev/null
|
||||
fi
|
||||
paths=()
|
||||
[[ -f $GITOPS_DIR/apps/$NAME.yaml ]] && paths+=("apps/$NAME.yaml")
|
||||
[[ -f $GITOPS_DIR/$APPS_DIR/$NAME.yaml ]] && paths+=("$APPS_DIR/$NAME.yaml")
|
||||
[[ -d $GITOPS_DIR/manifests/$NAME ]] && paths+=("manifests/$NAME")
|
||||
if ((${#paths[@]})); then
|
||||
if is_dry; then
|
||||
|
|
|
|||
|
|
@ -88,13 +88,13 @@ gitops_sync
|
|||
((!PUBLIC)) || cf_require
|
||||
|
||||
if [[ -n $API_APP ]]; then
|
||||
[[ -f $GITOPS_DIR/apps/$API_APP.yaml && -d $GITOPS_DIR/manifests/$API_APP ]] ||
|
||||
[[ -f $GITOPS_DIR/$APPS_DIR/$API_APP.yaml && -d $GITOPS_DIR/manifests/$API_APP ]] ||
|
||||
die "--api $API_APP: no such service in gitops (create it first)"
|
||||
[[ $(app_namespace "$API_APP") == "$API_APP" ]] ||
|
||||
die "--api $API_APP: not a backend (its namespace is '$(app_namespace "$API_APP")')"
|
||||
fi
|
||||
if [[ -f $GITOPS_DIR/apps/$NAME.yaml && $(app_namespace "$NAME") != "$NS" ]]; then
|
||||
die "gitops apps/$NAME.yaml exists with namespace '$(app_namespace "$NAME")', expected '$NS'"
|
||||
if [[ -f $GITOPS_DIR/$APPS_DIR/$NAME.yaml && $(app_namespace "$NAME") != "$NS" ]]; then
|
||||
die "gitops $APPS_DIR/$NAME.yaml exists with namespace '$(app_namespace "$NAME")', expected '$NS'"
|
||||
fi
|
||||
ok "validated $NAME (kind=$KIND ns=$NS postgres=$WITH_PG redis=$WITH_REDIS api=${API_APP:--})"
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ else
|
|||
fi
|
||||
|
||||
# ------------------------------------------------------------ 5. gitops manifests
|
||||
# apps/<name>.yaml is written only after CI's first image exists (step 7), so
|
||||
# $APPS_DIR/<name>.yaml is written only after CI's first image exists (step 7), so
|
||||
# ArgoCD never syncs `newTag: latest` before there is an image to pull (the
|
||||
# migrate-Job ImagePullBackOff caveat from Plan 04).
|
||||
# public_block DIR: keep (markers only) or strip the `# __PUBLIC_BEGIN__..END__` host rule.
|
||||
|
|
@ -281,17 +281,17 @@ else
|
|||
fi
|
||||
|
||||
# ------------------------------------------------------------ 8. register with ArgoCD
|
||||
if [[ -f $GITOPS_DIR/apps/$NAME.yaml ]]; then
|
||||
ok "gitops apps/$NAME.yaml exists"
|
||||
if [[ -f $GITOPS_DIR/$APPS_DIR/$NAME.yaml ]]; then
|
||||
ok "gitops $APPS_DIR/$NAME.yaml exists"
|
||||
else
|
||||
is_dry || git_auth -C "$GITOPS_DIR" pull -q --ff-only origin main
|
||||
if is_dry; then
|
||||
dry "write $GITOPS_DIR/apps/$NAME.yaml (namespace $NS)"
|
||||
dry "write $GITOPS_DIR/$APPS_DIR/$NAME.yaml (namespace $NS)"
|
||||
else
|
||||
sed "s/__APP__/$NAME/g; s/__NS__/$NS/g" "$GITOPS_DIR/templates/$KIND/application.yaml.tmpl" \
|
||||
>"$GITOPS_DIR/apps/$NAME.yaml"
|
||||
>"$GITOPS_DIR/$APPS_DIR/$NAME.yaml"
|
||||
fi
|
||||
gitops_commit_push "feat($NAME): register ArgoCD application" "apps/$NAME.yaml"
|
||||
gitops_commit_push "feat($NAME): register ArgoCD application" "$APPS_DIR/$NAME.yaml"
|
||||
fi
|
||||
# Don't wait for ArgoCD's 3-min poll.
|
||||
argocd_refresh root
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue