@@ -12,62 +12,62 @@ GetHostAndToken
1212Function for getting the *final* API server hostname and token from a
1313combination of environment variables, flags, config files and/or user input.
1414
15- - 'cfg' is a 'config.Config' object that has already been loaded either based
16- on the default configuration paths or ones that have been supplied by the
17- user.
15+ - 'cfg' is a 'config.Config' object that has already been loaded either based
16+ on the default configuration paths or ones that have been supplied by the
17+ user.
1818
19- - 'hostname' is an override for the hostname to used that the user has maybe
20- provided either as a flag or an environment variable.
19+ - 'hostname' is an override for the hostname to used that the user has maybe
20+ provided either as a flag or an environment variable.
2121
22- - 'token' is an override for the API token to be used that the user has maybe
23- provided either as a flag or an environment variable.
22+ - 'token' is an override for the API token to be used that the user has maybe
23+ provided either as a flag or an environment variable.
2424
2525The logic for retrieving the final hostname and token is:
2626
27- 1. If the hostname flag/env variable is provided, use it as a section *key* in
28- the root configuration file. For example, if the user provides 'aaa' and the
29- root configuration file looks like this:
27+ 1. If the hostname flag/env variable is provided, use it as a section *key* in
28+ the root configuration file. For example, if the user provides 'aaa' and the
29+ root configuration file looks like this:
3030
31- [aaa]
32- rest_hostname = bbb
31+ [aaa]
32+ rest_hostname = bbb
3333
34- Then, the returned hostname will be 'bbb'.
34+ Then, the returned hostname will be 'bbb'.
3535
36- If a matching host isn't found, then the returned hostname will be the
37- provided value.
36+ If a matching host isn't found, then the returned hostname will be the
37+ provided value.
3838
39- 2. If the user didn't provide a hostname, try to find the "active host" based
40- on both the local and root configuration. For example, if the local
41- configuration looks like this:
39+ 2. If the user didn't provide a hostname, try to find the "active host" based
40+ on both the local and root configuration. For example, if the local
41+ configuration looks like this:
4242
43- [main]
44- host = ccc
43+ [main]
44+ host = ccc
4545
46- And the root configuration looks like this:
46+ And the root configuration looks like this:
4747
48- [aaa]
49- rest_hostname = bbb
48+ [aaa]
49+ rest_hostname = bbb
5050
51- [ccc]
52- rest_hostname = ddd
51+ [ccc]
52+ rest_hostname = ddd
5353
54- [eee]
55- rest_hostname = fff
54+ [eee]
55+ rest_hostname = fff
5656
57- Then the "active host" will be the second one and the returned hostname will
58- be 'ddd'.
57+ Then the "active host" will be the second one and the returned hostname will
58+ be 'ddd'.
5959
60- If an active host cannot be found, then 'https://rest.api.transifex.com'
61- will be returned.
60+ If an active host cannot be found, then 'https://rest.api.transifex.com'
61+ will be returned.
6262
63633. If a token was provided by the user, simply return it.
6464
65- 4. If a token wasn't provided, retrieve the token from either the "matching
66- host" (see step 1) or the "active host" (see step 2). If a "matching" or
67- "active" host wasn't found during the resolution of the hostname, the
68- program will ask the user to provide a token. After the token is provided,
69- it will be saved in the root configuration using the appropriate section key
70- and hostname that were already retrieved.
65+ 4. If a token wasn't provided, retrieve the token from either the "matching
66+ host" (see step 1) or the "active host" (see step 2). If a "matching" or
67+ "active" host wasn't found during the resolution of the hostname, the
68+ program will ask the user to provide a token. After the token is provided,
69+ it will be saved in the root configuration using the appropriate section key
70+ and hostname that were already retrieved.
7171*/
7272func GetHostAndToken (
7373 cfg * config.Config , hostname , token string ,
0 commit comments