Skip to content

Commit 525e940

Browse files
committed
gaarf-wf: introduced --disable-grants args for set_iam_permissions target
create-gaarf-wf@1.12.2: introduced disable_grants parameters in answers file to disable IAM grants (via putting --disable-grants into deploy-wf.sh) Change-Id: I37e848c40bd77a31dd3d3ab3ebac97662098ca79
1 parent 497f677 commit 525e940

File tree

6 files changed

+35
-10
lines changed

6 files changed

+35
-10
lines changed

gcp/create-gaarf-wf/build/index.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gcp/create-gaarf-wf/build/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gcp/create-gaarf-wf/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gcp/create-gaarf-wf/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-gaarf-wf",
3-
"version": "1.12.1",
3+
"version": "1.12.2",
44
"description": "Interactive generator for Gaarf (Google Ads API Report Fetcher) Workflow",
55
"type": "module",
66
"bin": {

gcp/create-gaarf-wf/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,14 +1114,19 @@ fi
11141114
// not using google-ads.yaml means using Secret Manager
11151115
settings['functions']['use-secret-manager'] = true;
11161116
}
1117+
let aux_args = '';
1118+
if (answers.disable_grants) {
1119+
aux_args = '--disable-grants'
1120+
}
1121+
11171122
deployShellScript(
11181123
'deploy-wf.sh',
11191124
`# Deploy Cloud Functions and Cloud Workflows
11201125
set -e
11211126
cd ./${gaarf_folder}
11221127
git pull --ff
11231128
cd ..
1124-
./${gaarf_folder}/gcp/setup.sh deploy_all --settings $(readlink -f "./${settings_file}")
1129+
./${gaarf_folder}/gcp/setup.sh deploy_all --settings $(readlink -f "./${settings_file}") ${aux_args}
11251130
`
11261131
);
11271132

gcp/setup.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pushd $SCRIPT_PATH > /dev/null
2828

2929
args=()
3030
started=0
31+
# pack all arguments into args array (except --settings)
3132
for ((i=1; i<=$#; i++)); do
3233
if [[ ${!i} == --* ]]; then started=1; fi
3334
if [ ${!i} = "--settings" ]; then
@@ -106,6 +107,13 @@ check_service_account() {
106107
}
107108

108109
set_iam_permissions() {
110+
local disable_grants
111+
disable_grants=$(_get_arg_value "--disable-grants" "$@")
112+
if [[ "$disable_grants" == "true" ]]; then
113+
echo -e "${CYAN}Skipping setting up IAM permissions...${NC}"
114+
return
115+
fi
116+
109117
echo -e "${CYAN}Setting up IAM permissions...${NC}"
110118
declare -ar ROLES=(
111119
# Permissions for Workflow:
@@ -217,9 +225,17 @@ _get_arg_value() {
217225
shift
218226
for ((i=1; i<=$#; i++)); do
219227
if [ ${!i} = "$arg_name" ]; then
220-
((i++))
221-
echo ${!i}
222-
return 0
228+
# Check if this is the last argument or if next argument starts with - or --
229+
((next=i+1))
230+
if [ $next -gt $# ] || [[ "${!next}" == -* ]]; then
231+
# This is a flag without value
232+
echo "true"
233+
return 0
234+
else
235+
# This is a value argument
236+
echo ${!next}
237+
return 0
238+
fi
223239
fi
224240
done
225241
return 1
@@ -292,7 +308,7 @@ delete_all() {
292308

293309
deploy_all() {
294310
enable_apis || return $?
295-
set_iam_permissions || return $?
311+
set_iam_permissions $@ || return $?
296312
deploy_functions || return $?
297313
create_wf_completion_topic || return $?
298314
deploy_wf || return $?

0 commit comments

Comments
 (0)