9125404c by Adam Heath

Merge remote-tracking branch 'origin/add-transformer-step'

2 parents 6f5644e6 fa20c6e6
...@@ -6,6 +6,7 @@ resources: ...@@ -6,6 +6,7 @@ resources:
6 - ./task-postgresql-pod.yaml 6 - ./task-postgresql-pod.yaml
7 - ./task-postgresql-create-databases-users.yaml 7 - ./task-postgresql-create-databases-users.yaml
8 - ./task-postgresql-import.yaml 8 - ./task-postgresql-import.yaml
9 - ./task-postgresql-transformer.yaml
9 - ./task-postgresql-export.yaml 10 - ./task-postgresql-export.yaml
10 11
11 configMapGenerator: 12 configMapGenerator:
...@@ -24,6 +25,7 @@ configMapGenerator: ...@@ -24,6 +25,7 @@ configMapGenerator:
24 - scripts/create-databases-users.sh 25 - scripts/create-databases-users.sh
25 - scripts/export-dumps.sh 26 - scripts/export-dumps.sh
26 - scripts/import-dumps.sh 27 - scripts/import-dumps.sh
28 - scripts/transformations.sh
27 - scripts/wait-for-postgresql.sh 29 - scripts/wait-for-postgresql.sh
28 30
29 --- 31 ---
......
1 #!/bin/bash
2
3 set -ex
4
5 touch /tmp/pgpass
6 chmod 0600 /tmp/pgpass
7 echo "*:*:*:*:CHANGEME" > /tmp/pgpass
8 export PGPASSFILE=/tmp/pgpass
9
10 _import() {
11 psql -w -h ${POSTGRESQL_HOST} -U postgres "$1"
12 }
13
14 ls -alR /workspace
15 for file in /workspace/transformations/*; do
16 [[ -e $file ]] || continue
17 case "$file" in
18 (*.sql.gz)
19 zcat "$file" | _import postgres
20 ;;
21 (*.sql)
22 cat "$file" | _import postgres
23 ;;
24 (*.sh)
25 "$file"
26 ;;
27 (*)
28 echo "Ignoring file: $file"
29 ;;
30 esac
31 done
32
1 ---
2 apiVersion: tekton.dev/v1beta1
3 kind: Task
4 metadata:
5 name: task-postgresql-transformer
6 spec:
7 params:
8 - name: POSTGRESQL_HOST
9 type: string
10 - name: postgresql-image
11 type: string
12 default: bitnami/postgresql:14.1.0-debian-10-r66
13 workspaces:
14 - name: transformations
15 description: Place any transformation scripts here.
16 volumes:
17 - name: task-postgresql-scripts
18 configMap:
19 name: task-postgresql-scripts
20 defaultMode: 0755
21 steps:
22 - name: wait-for-start
23 image: $(params.postgresql-image)
24 command: ["/scripts/wait-for-postgresql.sh"]
25 env:
26 - name: POSTGRESQL_HOST
27 value: $(params.POSTGRESQL_HOST)
28 volumeMounts:
29 - name: task-postgresql-scripts
30 mountPath: /scripts
31 - name: transformations
32 image: $(params.postgresql-image)
33 command: ["/scripts/transformations.sh"]
34 env:
35 - name: POSTGRESQL_HOST
36 value: $(params.POSTGRESQL_HOST)
37 volumeMounts:
38 - name: task-postgresql-scripts
39 mountPath: /scripts
40 ---