forked from GoogleCloudPlatform/cortex-dag-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.cdc.yaml
108 lines (97 loc) · 3.77 KB
/
cloudbuild.cdc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
steps:
# Run CDC DAG generation
- name: 'gcr.io/kittycorn-public/deploy-kittycorn:v2.0'
id: config_reader
waitFor: ['-']
script: |
#!/bin/bash
echo "Configuration (${_CONFIG_FILE}):"
cat ${_CONFIG_FILE}
_PJID_SRC_=$(jq -r ."projectIdSource" ${_CONFIG_FILE})
_DEPLOY_CDC_=$(jq -r ."SAP.deployCDC" ${_CONFIG_FILE})
_DS_RAW_=$(jq -r ."SAP.datasets.raw" ${_CONFIG_FILE})
_DS_CDC_=$(jq -r ."SAP.datasets.cdc" ${_CONFIG_FILE})
_TEST_DATA_=$(jq -r ."testData" ${_CONFIG_FILE})
_SQL_FLAVOUR_=$(jq -r ."SAP.SQLFlavor" ${_CONFIG_FILE})
if [[ ${_DEPLOY_CDC_} == "true" ]] ; then
echo "Running config_reader"
cd ./src/ && python config_reader.py ${_PJID_SRC_} ${_DS_RAW_} ${_DS_CDC_} ${_TEST_DATA_} ${_SQL_FLAVOUR_}
fi
- name: 'gcr.io/kittycorn-public/deploy-kittycorn:v2.0'
id: copy_dag_py_files_to_gcs
waitFor: ['config_reader']
script: |
#!/bin/bash
if [[ ${_TGT_BUCKET} != "" ]]
then
_TGT_BUCKET_=${_TGT_BUCKET}
else
_TGT_BUCKET_=$(jq -r ."targetBucket" ${_CONFIG_FILE})
fi
echo "Running copy_dag_py_files_to_gcs"
generated_files=$(shopt -s nullglob dotglob; echo ./generated_dag/*.py)
if (( ${#generated_files} ))
then
gsutil -m cp -r './generated_dag/*.py' gs://${_TGT_BUCKET_}/dags/
else
echo "🔪🔪🔪No Python files found under generated_dag folder or the folder does not exist. Skipping copy.🔪🔪🔪"
fi
- name: 'gcr.io/kittycorn-public/deploy-kittycorn:v2.0'
id: copy_dag_sql_files_to_gcs
waitFor: ['config_reader']
script: |
#!/bin/bash
if [[ ${_TGT_BUCKET} != "" ]]
then
_TGT_BUCKET_=${_TGT_BUCKET}
else
_TGT_BUCKET_=$(jq -r ."targetBucket" ${_CONFIG_FILE})
fi
echo "Copying DAG SQL files to GCS..."
generated_files=$(shopt -s nullglob dotglob; echo ./generated_sql/*.sql)
if (( ${#generated_files} ))
then
gsutil -m cp -r './generated_sql/*.sql' gs://${_TGT_BUCKET_}/data/bq_data_replication/
else
echo "🔪No SQL files found under generated_sql folder or the folder does not exist. Skipping copy.🔪"
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'datamesh'
waitFor: ['config_reader']
script: |
#!/bin/bash
set -e
_DEPLOY_DATA_MESH_=$(jq -r ."deployDataMesh" ${_CONFIG_FILE})
if [[ ${_DEPLOY_DATA_MESH_} == "true" ]]; then
_SQL_FLAVOR_=$(jq -r ."SAP.SQLFlavor" ${_CONFIG_FILE})
python3 common/data_mesh/deploy_data_mesh.py \
--config-file ${_CONFIG_FILE} \
--tag-template-directories config/${_SQL_FLAVOR_}/tag_templates \
--policy-directories config/${_SQL_FLAVOR_}/policy_taxonomies \
--lake-directories config/${_SQL_FLAVOR_}/lakes \
--annotation-directories \
config/${_SQL_FLAVOR_}/annotations/raw \
config/${_SQL_FLAVOR_}/annotations/cdc
else
echo "==Skipping Data Mesh=="
fi
logsBucket: "gs://${_GCS_BUCKET}"
timeout: 7200s
substitutions:
_CONFIG_FILE: "config/config.json"
options:
substitution_option: "ALLOW_LOOSE"
automapSubstitutions: true