Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misuse or incorrect type for aws_credentials_provider:options() #70

Open
dw-kihara opened this issue May 21, 2024 · 0 comments
Open

Misuse or incorrect type for aws_credentials_provider:options() #70

dw-kihara opened this issue May 21, 2024 · 0 comments

Comments

@dw-kihara
Copy link
Contributor

Hello,

I am trying to use this library and I found a problem with aws_credentials_provider:options().

According to the type declaration this type appear to be a nested map as shown below:

%% type declaration in aws_credentials_provider
%% -type options() :: #{provider() => map()}.

%% maybe like this
Options = #{
    aws_credentials_file => #{
        credential_path => "/path/to/aws/",
        profile => "my_profile"
    }
}.

However, in practice, the variable needs to be a flat map without a provider name, as shown in this example:

%% code in aws_credentials_file
-spec get_file_path(aws_credentials_provider:options()) -> {error, any()} | string().
get_file_path(Options) ->
  case maps:get(credential_path, Options, undefined) of
    undefined -> maybe_add_home("/.aws/");
    Path -> Path
  end.

Possible fixes:

  1. Keep the current code and modify aws_credentials_provider:options() type to be a flat map to match current usage.
  2. Change option values and usage to match the type declaration.

Method 1 is easier but makes it much harder to have different options for different providers in the future.
Method 2 is cleaner but breaks current library users, though some compatibility compromises could be made.

If I could choose, I would take method 2 with special credentials_path and profile options to maintain compatibility for current aws_credentials_file users.
(Luckily, there are no other usage except for those two options in aws_credentials_file.)

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant