@google-cloud/nodejs-common 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/install_functions.sh +56 -21
- package/package.json +1 -1
package/bin/install_functions.sh
CHANGED
|
@@ -443,7 +443,7 @@ select_functions_location() {
|
|
|
443
443
|
"name~${PROJECT_NAMESPACE}" --format="csv[no-heading](name,REGION)"))
|
|
444
444
|
if [[ ${#exist_functions[@]} -gt 0 ]]; then
|
|
445
445
|
local exist_region
|
|
446
|
-
exist_region=$(printf "${exist_functions[0]}" | cut -d
|
|
446
|
+
exist_region=$(printf "${exist_functions[0]}" | cut -d\, -f2 | uniq)
|
|
447
447
|
printf '%s\n' "Current application has already been installed in region: \
|
|
448
448
|
${exist_region}."
|
|
449
449
|
local i
|
|
@@ -466,9 +466,9 @@ Functions for that region. Do you want to continue? [N/y]: "
|
|
|
466
466
|
if [[ ${confirm_delete} == "Y" || ${confirm_delete} == "y" ]]; then
|
|
467
467
|
for i in "${!exist_functions[@]}"; do
|
|
468
468
|
local exist_function
|
|
469
|
-
exist_function=$(printf "${exist_functions[$i]}" | cut -d
|
|
469
|
+
exist_function=$(printf "${exist_functions[$i]}" | cut -d\, -f1)
|
|
470
470
|
local function_region
|
|
471
|
-
function_region=$(printf "${exist_functions[$i]}" | cut -d
|
|
471
|
+
function_region=$(printf "${exist_functions[$i]}" | cut -d\, -f2)
|
|
472
472
|
gcloud functions delete --region="${function_region}" \
|
|
473
473
|
"${exist_function}"
|
|
474
474
|
done
|
|
@@ -1818,31 +1818,66 @@ get_cloud_functions_service_account() {
|
|
|
1818
1818
|
}
|
|
1819
1819
|
|
|
1820
1820
|
#######################################
|
|
1821
|
-
# Make sure Firestore
|
|
1822
|
-
#
|
|
1823
|
-
#
|
|
1824
|
-
# datastore.locations.list - sample role: Cloud Datastore Owner
|
|
1825
|
-
# servicemanagement.services.bind - sample role: Editor
|
|
1821
|
+
# Make sure the Firestore database is in the current project. If there is no
|
|
1822
|
+
# Firestore datastore, it will help to create one.
|
|
1823
|
+
# To create the Firestore, the operator need to be the Owner.
|
|
1826
1824
|
# Globals:
|
|
1827
1825
|
# GCP_PROJECT
|
|
1828
1826
|
# Arguments:
|
|
1829
|
-
#
|
|
1827
|
+
# Firestore mode, 'native' or 'datastore'.
|
|
1828
|
+
# Firestore region, it's not the same list as Cloud Functions regions and it
|
|
1829
|
+
# will be bonded to this Cloud project after created.
|
|
1830
1830
|
#######################################
|
|
1831
1831
|
check_firestore_existence() {
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1832
|
+
local firestore mode appRegion
|
|
1833
|
+
mode="${1}"
|
|
1834
|
+
appRegion="${2}"
|
|
1835
|
+
firestore=$(gcloud app describe --format="csv[no-heading](databaseType)")
|
|
1836
|
+
if [[ -z "${firestore}" ]]; then
|
|
1837
|
+
printf '%s\n' "Firestore is not ready. Creating a new Firestore database\
|
|
1838
|
+
is an irreversible operation, so read carefully before continue:"
|
|
1839
|
+
printf '%s\n' " 1. You need to be the owner of ${GCP_PROJECT} to continue."
|
|
1840
|
+
printf '%s\n' " 2. Once you select the region and mode, you cannot change it."
|
|
1841
|
+
printf '%s\n' "Press any key to continue..."
|
|
1841
1842
|
local any
|
|
1842
1843
|
read -n1 -s any
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1844
|
+
if [[ -z "${mode}" ]]; then
|
|
1845
|
+
printf '%s\n' " For more information about mode, see \
|
|
1846
|
+
https://cloud.google.com/firestore/docs/firestore-or-datastore#choosing_a_database_mode"
|
|
1847
|
+
fi
|
|
1848
|
+
while [[ -z "${mode}" ]]; do
|
|
1849
|
+
printf '%s' " Enter the mode of your dataset [Native]: "
|
|
1850
|
+
local selectMode
|
|
1851
|
+
read -r selectMode
|
|
1852
|
+
selectMode=$(printf '%s' "${selectMode:-"Native"}" | \
|
|
1853
|
+
tr '[:upper:]' '[:lower:]')
|
|
1854
|
+
if [[ ${selectMode} == 'native' || ${selectMode} == 'datastore' ]]; then
|
|
1855
|
+
mode=${selectMode}
|
|
1856
|
+
fi
|
|
1857
|
+
done
|
|
1858
|
+
printf '%s\n' "Creating Firestore database in ${mode} mode..."
|
|
1859
|
+
gcloud app create --region=${appRegion}
|
|
1860
|
+
if [[ $? -eq 0 ]]; then
|
|
1861
|
+
if [[ "${mode}" == "native" ]]; then
|
|
1862
|
+
appRegion=$(gcloud app describe --format="csv[no-heading](locationId)")
|
|
1863
|
+
gcloud firestore databases create --region="${appRegion}"
|
|
1864
|
+
fi
|
|
1865
|
+
else
|
|
1866
|
+
return 1
|
|
1867
|
+
fi
|
|
1868
|
+
else
|
|
1869
|
+
printf '%s\n' "OK. Firestore is ready in mode ${firestore}."
|
|
1870
|
+
fi
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
#######################################
|
|
1874
|
+
# Installation step for confirming Firestore is ready.
|
|
1875
|
+
# See function check_firestore_existence.
|
|
1876
|
+
#######################################
|
|
1877
|
+
confirm_firestore() {
|
|
1878
|
+
(( STEP += 1 ))
|
|
1879
|
+
printf '%s\n' "Step ${STEP}: Checking the status of Firestore..."
|
|
1880
|
+
check_firestore_existence
|
|
1846
1881
|
}
|
|
1847
1882
|
|
|
1848
1883
|
#######################################
|