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

ft: helper function for accessing credentials directory #42

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/systemd.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
store_fds/1,
clear_fds/1,
booted/0,
is_journal/1
is_journal/1,
credentials/1
]).

-export([notify_spawn/2]).
Expand Down Expand Up @@ -403,6 +404,25 @@

%% ----------------------------------------------------------------------------

%% @doc
%% Returns path for credentials file.
%%
%% Returns `error' when there is no `$CREDENTIALS_DIRECTORY' environment
%% variable, `{ok, Path}' otherwise.
%%
%% For details see [https://systemd.io/CREDENTIALS/]
%%
%% @since 0.7.0
%% @end
credentials(Name) ->
case os:getenv("CREDENTIALS_DIRECTORY") of
false -> error;

Check warning on line 419 in src/systemd.erl

View check run for this annotation

Codecov / codecov/patch

src/systemd.erl#L418-L419

Added lines #L418 - L419 were not covered by tests
Dir ->
{ok, filename:join(Dir, Name)}

Check warning on line 421 in src/systemd.erl

View check run for this annotation

Codecov / codecov/patch

src/systemd.erl#L421

Added line #L421 was not covered by tests
end.

%% ----------------------------------------------------------------------------

%% @doc
%% Returns list of file descriptors passed to the application by systemd.
%%
Expand Down
Loading