-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.functions
99 lines (79 loc) · 3.16 KB
/
configure.functions
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
# This file is part of shellfire heroku. It is subject to the licence terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/heroku/master/COPYRIGHT. No part of shellfire heroku, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
# Copyright © 2015 The developers of shellfire heroku. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/heroku/master/COPYRIGHT.
core_dependency_requires '*' heroku tail head cut
heroku_configure_initialise()
{
local TMP_FILE
core_temporaryFiles_newFileToRemoveOnExit
heroku_configure_regionsFilePath="$TMP_FILE"
if core_compatibility_whichNoOutput heroku; then
heroku regions | tail -n +2 | head -n +2 | cut -d' ' -f1 >"$heroku_configure_regionsFilePath"
else
core_message DEBUG "Validation of regions is not possible as the heroku toolbelt 'heroku' is missing"
fi
}
core_dependency_requires '*' grep
configure_validate_region()
{
local configurationSettingValue="$1"
if core_variable_isUnset heroku_configure_regionsFilePath; then
heroku_configure_initialise
fi
if grep -q '^'"$configurationSettingValue"'$' "$heroku_configure_regionsFilePath"; then
return 0
fi
core_message WARN "The configuration setting '$configurationSettingName' ('$configurationSettingValue') is not a valid 'region'."
}
configure_validate_stack()
{
local configurationSettingValue="$1"
case "$configurationSettingValue" in
cedar|cedar-14)
:
;;
*)
core_message WARN "The configuration setting '$configurationSettingName' ('$configurationSettingValue') is not a valid 'stack'."
;;
esac
}
heroku_configure_validateStack()
{
local configurationSettingValue="$1"
local configurationSettingName='(irrelevant)'
configure_validate_stack "$configurationSettingValue"
local warning="$(configure_validate_stack "$configurationSettingValue" 2>&1)"
if [ -n "$warning" ]; then
return 1
else
return 0
fi
}
core_usesIn configure
heroku_configure_register()
{
local potentialAppName="$(core_compatibility_basename "$heroku_repositoryPath")"
if [ -z "$potentialAppName" ]; then
configure_register Value NotEmpty heroku appName
else
configure_register Value NotEmpty heroku appName "$potentialAppName"
fi
configure_register Value region heroku region 'eu'
configure_register Value NotEmpty heroku remote 'heroku'
configure_register Value stack heroku stack 'cedar-14'
configure_register Value NotEmpty heroku refspec 'master'
configure_register Array NotEmpty heroku domains
configure_register Value Boolean heroku preboot no
}
core_usesIn configure
heroku_configure_load()
{
configure_reset heroku
configure_source "$heroku_configurationFolderPath" heroku
configure_validate heroku
heroku_appName="$(configure_getValue heroku appName)"
heroku_region="$(configure_getValue heroku region)"
heroku_remote="$(configure_getValue heroku remote)"
heroku_stack="$(configure_getValue heroku stack)"
heroku_refspec="$(configure_getValue heroku refspec)"
heroku_preboot="$(configure_getValue heroku preboot)"
}