erlang-systemd icon indicating copy to clipboard operation
erlang-systemd copied to clipboard

Support for loading credentials from $CREDENTIALS_DIRECTORY

Open Munksgaard opened this issue 9 months ago • 3 comments

This feature would make it easier to support the workflow around LoadCredentials and friends as described here: https://systemd.io/CREDENTIALS/

Munksgaard avatar May 03 '24 12:05 Munksgaard

That makes sense and it should be quite simple to add.

hauleth avatar May 03 '24 13:05 hauleth

For reference, I have something like the following in my utils file:

  defp path_from_credentials_dir(name) do
    if credentials_directory = System.get_env("CREDENTIALS_DIRECTORY") do
      path =
        Path.join(credentials_directory, name)

      if File.regular?(path) do
        path
      else
        nil
      end
    else
      nil
    end
  end

It's not much and it's not a big problem to have that in my own code, but this package seems like a natural place for it to live.

Munksgaard avatar May 03 '24 13:05 Munksgaard

It looks interesting, however I would remove the second check in the body. So it would return paths even to non-existent credentials.

hauleth avatar May 04 '24 00:05 hauleth