|
7 | 7 |
|
8 | 8 | -export([fetch/1]). |
9 | 9 |
|
10 | | --spec fetch(any()) -> |
11 | | - {ok, aws_credentials:credentials(), aws_credentials_provider:expiration()} | |
12 | | - {error, any()}. |
| 10 | +-spec fetch(aws_credentials_provider:options()) -> |
| 11 | + {error, _} |
| 12 | + | {ok, aws_credentials:credentials(), aws_credentials_provider:expiration()}. |
13 | 13 | fetch(_Options) -> |
14 | 14 | FullUri = os:getenv("AWS_CONTAINER_CREDENTIALS_FULL_URI"), |
15 | 15 | TokenFile = os:getenv("AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE"), |
16 | 16 | AuthToken = read_token(TokenFile), |
17 | 17 | Response = fetch_session_token(FullUri, AuthToken), |
18 | 18 | make_map(Response). |
19 | 19 |
|
20 | | --spec read_token(false | string()) -> {ok, string()} | {error, any()}. |
| 20 | +-spec read_token(false | string()) -> {error, _} | {ok, binary()}. |
21 | 21 | read_token(false) -> {error, no_credentials}; |
22 | 22 | read_token(Path) -> file:read_file(Path). |
23 | 23 |
|
24 | | --spec fetch_session_token(false | string(), {error, any()} | {ok, string()}) -> |
25 | | - {error, any()} | {ok, aws_credentials_httpc:status_code(), |
26 | | - aws_credentials_httpc:body(), |
27 | | - aws_credentials_httpc:headers()}. |
| 24 | +-spec fetch_session_token(false | string(), {error, _} | {ok, string()}) -> |
| 25 | + {error, _} |
| 26 | + | {ok, aws_credentials_httpc:status_code(), |
| 27 | + aws_credentials_httpc:body(), |
| 28 | + aws_credentials_httpc:headers()}. |
28 | 29 | fetch_session_token(false, _AuthToken) -> {error, no_credentials}; |
29 | 30 | fetch_session_token(_FullUri, {error, _Error} = Error) -> Error; |
30 | 31 | fetch_session_token(FullUri, {ok, AuthToken}) -> |
31 | 32 | aws_credentials_httpc:request(get, FullUri, [{?AUTHORIZATION_HEADER, AuthToken}]). |
32 | 33 |
|
33 | 34 |
|
34 | | --spec make_map({error, any()} | {ok, aws_credentials_httpc:status_code(), |
35 | | - aws_credentials_httpc:body(), |
36 | | - aws_credentials_httpc:headers()}) -> |
37 | | - {error, any()} | {ok, aws_credentials:credentials(), aws_credentials_provider:expiration()}. |
| 35 | +-spec make_map({error, _} |
| 36 | + | {ok, aws_credentials_httpc:status_code(), |
| 37 | + aws_credentials_httpc:body(), |
| 38 | + aws_credentials_httpc:headers()}) -> |
| 39 | + {error, _} |
| 40 | + | {ok, aws_credentials:credentials(), aws_credentials_provider:expiration()}. |
38 | 41 | make_map({error, _Error} = Error) -> Error; |
39 | 42 | make_map({ok, _Status, Body, _Headers}) -> |
40 | 43 | #{ <<"AccessKeyId">> := AccessKeyId |
|
0 commit comments