14
14
#
15
15
# Options that require values:
16
16
# --auth-type (token|oauth2_code_grant_pkce|oauth2_implicit) Auth type for build cluster auth.
17
- # (default: "token")
17
+ # Disables client auth if omitted (not recommended).
18
18
# --auth-token <token> Token used to authenticate with the build cluster when `--auth-type=token`.
19
- # --client-id <id> Client ID used to authenticate with the build cluster when `--auth-type=oauth2_code_grant_pkce|oauth2_implicit`.
20
- # --auth-url <url> Auth URL used to authenticate with the build cluster when `--auth-type=oauth2_code_grant_pkce|oauth2_implicit`.
19
+ # --client-id <id> Client ID used to authenticate with the build cluster when `--auth-type=( oauth2_code_grant_pkce|oauth2_implicit) `.
20
+ # --auth-url <url> Auth URL used to authenticate with the build cluster when `--auth-type=( oauth2_code_grant_pkce|oauth2_implicit) `.
21
21
# --token-url <url> Token URL used to authenticate with the build cluster when `--auth-type=oauth2_code_grant_pkce`.
22
22
# --connect-timeout <num> The sccache client HTTP connection timeout.
23
23
# (default: 30)
@@ -40,28 +40,24 @@ _configure_sccache_dist() {
40
40
. devcontainer-utils-debug-output ' devcontainer_utils_debug' ' sccache configure-sccache-dist' ;
41
41
42
42
auth_type=" ${auth_type-} " ;
43
- auth_token=" ${auth_token-} " ;
44
- max_retries=" ${max_retries:- ${SCCACHE_DIST_MAX_RETRIES:- 0} } " ;
45
- scheduler_url=" ${scheduler_url:- ${SCCACHE_DIST_SCHEDULER_URL:- } } " ;
46
- connect_timeout=" ${connect_timeout:- ${SCCACHE_DIST_CONNECT_TIMEOUT:- 30} } " ;
47
- request_timeout=" ${request_timeout:- ${SCCACHE_DIST_REQUEST_TIMEOUT:- 1800} } " ;
43
+ max_retries=" ${max_retries:- ${SCCACHE_DIST_MAX_RETRIES-} } " ;
44
+ scheduler_url=" ${scheduler_url:- ${SCCACHE_DIST_SCHEDULER_URL-} } " ;
45
+ connect_timeout=" ${connect_timeout:- ${SCCACHE_DIST_CONNECT_TIMEOUT-} } " ;
46
+ request_timeout=" ${request_timeout:- ${SCCACHE_DIST_REQUEST_TIMEOUT-} } " ;
48
47
49
- # local os="$(uname -s)";
50
- # local arch="$(dpkg --print-architecture)";
51
-
52
- local connection_pool=" false" ;
48
+ local connection_pool=" ${SCCACHE_DIST_CONNECTION_POOL-} " ;
53
49
54
50
if test -n " ${use_connection_pool+x} " ; then
55
51
connection_pool=" true" ;
56
52
fi
57
53
58
- local fallback_to_local_compile=" true " ;
54
+ local fallback_to_local_compile=" ${SCCACHE_DIST_FALLBACK_TO_LOCAL_COMPILE-} " ;
59
55
60
56
if test -n " ${no_local_compile_fallback+x} " ; then
61
57
fallback_to_local_compile=" false" ;
62
58
fi
63
59
64
- local sccache_conf=" $HOME /.config/sccache/config" ;
60
+ local sccache_conf=" ${SCCACHE_CONF :- " $ HOME /.config/sccache/config" } " ;
65
61
66
62
mkdir -p " $( dirname " $sccache_conf " ) " ;
67
63
touch " $sccache_conf " ;
@@ -94,54 +90,52 @@ _configure_sccache_dist() {
94
90
sed -r ' /^(\[dist.*\]|dist\.)/,/^$/d' " ${sccache_conf} " > " ${sccache_conf} .new" ;
95
91
96
92
# Write our new values
97
- cat << EOF >> "${sccache_conf} .new"
98
- [dist]
99
- max_retries = ${max_retries}
100
- fallback_to_local_compile = ${fallback_to_local_compile}
101
- scheduler_url = "${scheduler_url} "
102
-
103
- EOF
104
-
105
- cat << EOF >> "${sccache_conf} .new"
106
- [dist.net]
107
- connection_pool = ${connection_pool}
108
- connect_timeout = ${connect_timeout}
109
- request_timeout = ${request_timeout}
110
-
111
- EOF
112
-
113
- if test " ${auth_type} " = token; then
114
- if ! grep -qE " ^$" <<< " ${auth_token-}" ; then
115
- cat << EOF >> "${sccache_conf} .new"
116
- [dist.auth]
117
- type = "${auth_type} "
118
- token = "${auth_token} "
119
-
120
- EOF
93
+ if ! grep -qE " ^$" <<< " ${scheduler_url}" ; then
94
+ cat <<< " " >> " ${sccache_conf} .new" ;
95
+ cat <<< " [dist]" >> " ${sccache_conf} .new" ;
96
+ cat <<< " scheduler_url = \" ${scheduler_url} \" " >> " ${sccache_conf} .new" ;
97
+ if ! grep -qE " ^$" <<< " ${max_retries} " ; then
98
+ cat <<< " max_retries = ${max_retries} " >> " ${sccache_conf} .new" ;
99
+ fi
100
+ if ! grep -qE " ^$" <<< " ${fallback_to_local_compile} " ; then
101
+ cat <<< " fallback_to_local_compile = ${fallback_to_local_compile} " >> " ${sccache_conf} .new" ;
102
+ fi
103
+
104
+ cat <<< " [dist.net]" >> " ${sccache_conf} .new" ;
105
+ if ! grep -qE " ^$" <<< " ${connection_pool} " ; then
106
+ cat <<< " connection_pool = ${connection_pool} " >> " ${sccache_conf} .new" ;
107
+ fi
108
+ if ! grep -qE " ^$" <<< " ${connect_timeout} " ; then
109
+ cat <<< " connect_timeout = " ${connect_timeout} " " >> " ${sccache_conf} .new" ;
121
110
fi
122
- elif test " ${auth_type} " = oauth2_implicit; then
123
- if ! grep -qE " ^$" <<< " ${auth_url-}" \
124
- && ! grep -qE " ^$" <<< " ${client_id-}" ; then
125
- cat << EOF >> "${sccache_conf} .new"
126
- [dist.auth]
127
- type = "${auth_type} "
128
- auth_url = "${auth_url} "
129
- client_id = "${client_id} "
130
-
131
- EOF
111
+ if ! grep -qE " ^$" <<< " ${request_timeout} " ; then
112
+ cat <<< " request_timeout = " ${request_timeout} " " >> " ${sccache_conf} .new" ;
132
113
fi
133
- elif test " ${auth_type} " = oauth2_code_grant_pkce; then
134
- if ! grep -qE " ^$" <<< " ${auth_url-}" \
135
- && ! grep -qE " ^$" <<< " ${client_id-}" \
136
- && ! grep -qE " ^$" <<< " ${token_url-}" ; then
137
- cat << EOF >> "${sccache_conf} .new"
138
- [dist.auth]
139
- type = "${auth_type} "
140
- auth_url = "${auth_url} "
141
- client_id = "${client_id} "
142
- token_url = "${token_url} "
143
-
144
- EOF
114
+
115
+ if test " ${auth_type} " = token; then
116
+ if ! grep -qE " ^$" <<< " ${auth_token-} " ; then
117
+ cat <<< " [dist.auth]" >> " ${sccache_conf} .new" ;
118
+ cat <<< " type = \" ${auth_type} \" " >> " ${sccache_conf} .new" ;
119
+ cat <<< " token = \" ${auth_token} \" " >> " ${sccache_conf} .new" ;
120
+ fi
121
+ elif test " ${auth_type} " = oauth2_implicit; then
122
+ if ! grep -qE " ^$" <<< " ${auth_url-} " \
123
+ && ! grep -qE " ^$" <<< " ${client_id-} " ; then
124
+ cat <<< " [dist.auth]" >> " ${sccache_conf} .new" ;
125
+ cat <<< " type = \" ${auth_type} \" " >> " ${sccache_conf} .new" ;
126
+ cat <<< " auth_url = \" ${auth_url} \" " >> " ${sccache_conf} .new" ;
127
+ cat <<< " client_id = \" ${client_id} \" " >> " ${sccache_conf} .new" ;
128
+ fi
129
+ elif test " ${auth_type} " = oauth2_code_grant_pkce; then
130
+ if ! grep -qE " ^$" <<< " ${auth_url-} " \
131
+ && ! grep -qE " ^$" <<< " ${client_id-} " \
132
+ && ! grep -qE " ^$" <<< " ${token_url-} " ; then
133
+ cat <<< " [dist.auth]" >> " ${sccache_conf} .new" ;
134
+ cat <<< " type = \" ${auth_type} \" " >> " ${sccache_conf} .new" ;
135
+ cat <<< " auth_url = \" ${auth_url} \" " >> " ${sccache_conf} .new" ;
136
+ cat <<< " client_id = \" ${client_id} \" " >> " ${sccache_conf} .new" ;
137
+ cat <<< " token_url = \" ${token_url} \" " >> " ${sccache_conf} .new" ;
138
+ fi
145
139
fi
146
140
fi
147
141
0 commit comments