Ptolemy v0.2.0 Ptolemy.Providers.Vault behaviour View Source

Ptolemy.Providers.Vault provides from Vault secrets.

Example

Add to your configuration:

alias Ptolemy.Providers.Vault
config :ptolemy, loader: [
  env: [
    {{:app_name, :config_key}, {Vault, [:engine1, [:secret1], ["key1", "key2"]]}}
  ]
]

The :app_name and :config_key are added to reference the application environment key that will be set. The value can be accessed at any time with Application.get_env/2.

Vault is the module name of this provider is calling

The second element of the tuple is a list of arguments

  1. The name of engine which this secret belongs to
  2. This is another list which consists of the arguments required to call this engine's read function. More details can be found in ptolemy.ex
  3. This let you specify which part of the returned result should be stored in the application environment keys. This support nested strcutures.

Required Environment Variables

None

Link to this section Summary

Functions

Invoked to setup a provider. This callback is only called once per provider, and is called lazily

Invoked when querying the provider for a value

Callbacks

Starts Ptolemy servers are supervised processes under current running process

Reads in the data from Ptolemy's vault interface and check if the secret will expire

Link to this section Functions

Invoked to setup a provider. This callback is only called once per provider, and is called lazily.

Callback implementation for Ptolemy.Provider.init/1.

Link to this function

load(loader_pid, var_args) View Source

Invoked when querying the provider for a value.

Callback implementation for Ptolemy.Provider.load/2.

Link to this section Callbacks

Link to this callback

init(pid) View Source
init(pid()) :: :ok | {:error, String.t()}

Starts Ptolemy servers are supervised processes under current running process.

It tries to start all the servers configured in config.exs. If all the servers are started successfully, it return :ok back. Else, it returns {:error, res} with res being a list of failed servers.

Link to this callback

load(pid, list) View Source
load(pid(), [pid() | atom() | [any()]]) :: :ok | {:error, String.t()}

Reads in the data from Ptolemy's vault interface and check if the secret will expire.

If it does, it would register the secret's ttl with the loader, so the loader can load the secret again later. If the ttl doesn't exist, it will skip and return the data.

var_args is a 4-element list

  1. pid pid denotes the server that holds the state of vault server
  2. engine_name engine_name helps Ptolemy to find the correct engine configuration
  3. opts opts is another list, the content depends on engine type. See ptolemy.ex docs for more.
  4. access_keys access keys is a list of keys to access a specific element within the returned nested data structure