d89bc60b by Adam Heath

Added task-postgresql-transformer.

1 parent 6f5644e6
......@@ -6,6 +6,7 @@ resources:
- ./task-postgresql-pod.yaml
- ./task-postgresql-create-databases-users.yaml
- ./task-postgresql-import.yaml
- ./task-postgresql-transformer.yaml
- ./task-postgresql-export.yaml
configMapGenerator:
......@@ -24,6 +25,7 @@ configMapGenerator:
- scripts/create-databases-users.sh
- scripts/export-dumps.sh
- scripts/import-dumps.sh
- scripts/transformations.sh
- scripts/wait-for-postgresql.sh
---
......
#!/bin/bash
set -ex
touch /tmp/pgpass
chmod 0600 /tmp/pgpass
echo "*:*:*:*:CHANGEME" > /tmp/pgpass
export PGPASSFILE=/tmp/pgpass
_import() {
psql -w -h ${POSTGRESQL_HOST} -U postgres "$1"
}
ls -alR /workspace
for file in /workspace/transformations/*; do
[[ -e $file ]] || continue
case "$file" in
(*.sql.gz)
database="$(basename "$file" .sql.gz)"
zcat "$file" | _import "$database"
;;
(*.sql)
database="$(basename "$file" .sql)"
cat "$file" | _import "$database"
;;
(*.sh)
"$file"
;;
(*)
echo "Ignoring file: $file"
;;
esac
done
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: task-postgresql-transformer
spec:
params:
- name: POSTGRESQL_HOST
type: string
- name: postgresql-image
type: string
default: bitnami/postgresql:14.1.0-debian-10-r66
workspaces:
- name: transformations
description: Place any transformation scripts here.
volumes:
- name: task-postgresql-scripts
configMap:
name: task-postgresql-scripts
defaultMode: 0755
steps:
- name: wait-for-start
image: $(params.postgresql-image)
command: ["/scripts/wait-for-postgresql.sh"]
env:
- name: POSTGRESQL_HOST
value: $(params.POSTGRESQL_HOST)
volumeMounts:
- name: task-postgresql-scripts
mountPath: /scripts
- name: transformations
image: $(params.postgresql-image)
command: ["/scripts/transformations.sh"]
env:
- name: POSTGRESQL_HOST
value: $(params.POSTGRESQL_HOST)
volumeMounts:
- name: task-postgresql-scripts
mountPath: /scripts
---