pipeline-postgresql-transformer.yaml 3.23 KB
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: pipeline-postgresql-transformer
spec:
  params:
    - name: databases
      type: array
    - name: users
      type: array
    - name: exports
      type: array
    - name: auth-config-map
      type: string
      default: ""
    - name: auth-secret
      type: string
      default: ""
    - name: s3-items
      type: array
      default: []
    - name: postgresql-image
      type: string
      default: bitnami/postgresql:14.1.0-debian-10-r66

  workspaces:
    - name: imports
      description: Place any input database dump files here
    - name: exports
      description: The database exports will be placed in this workspace.
    - name: transformations
      description: The location that transformation scripts are placed.

  tasks:
    - name: download-from-s3
      taskRef:
        name: task-s5cmd-download
      workspaces:
        - name: files
          workspace: imports
      params:
        - name: auth-config-map
          value: $(params.auth-config-map)
        - name: auth-secret
          value: $(params.auth-secret)
        - name: items
          value: ["$(params.s3-items[*])"]
    - name: postgresql-service
      taskRef:
        name: task-postgresql-service

    - name: create-databases-users
      taskRef:
        name: task-postgresql-create-databases-users
      params:
        - name: databases
          value: ["$(params.databases)"]
        - name: users
          value: ["$(params.users)"]
        - name: postgresql-image
          value: $(params.postgresql-image)
        - name: POSTGRESQL_HOST
          value: $(tasks.postgresql-service.results.service-name)
    - name: import
      runAfter:
        - create-databases-users
        - download-from-s3
      taskRef:
        name: task-postgresql-import
      params:
        - name: postgresql-image
          value: $(params.postgresql-image)
        - name: POSTGRESQL_HOST
          value: $(tasks.postgresql-service.results.service-name)
      workspaces:
        - name: imports
          workspace: imports

    - name: transform
      runAfter:
        - import
      taskRef:
        name: task-postgresql-transformer
      params:
        - name: postgresql-image
          value: $(params.postgresql-image)
        - name: POSTGRESQL_HOST
          value: $(tasks.postgresql-service.results.service-name)
      workspaces:
        - name: transformations
          workspace: transformations

    - name: export
      runAfter:
        - transform
      taskRef:
        name: task-postgresql-export
      params:
        - name: exports
          value: ["$(params.exports)"]
        - name: postgresql-image
          value: $(params.postgresql-image)
        - name: POSTGRESQL_HOST
          value: $(tasks.postgresql-service.results.service-name)
      workspaces:
        - name: exports
          workspace: exports

    - name: upload-to-s3
      runAfter:
        - export
      taskRef:
        name: task-s5cmd-upload
      workspaces:
        - name: files
          workspace: exports
      params:
        - name: auth-config-map
          value: $(params.auth-config-map)
        - name: auth-secret
          value: $(params.auth-secret)
        - name: items
          value: ["$(params.exports[*])"]