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
- The name of engine which this secret belongs to
- This is another list which consists of the arguments required to call this engine's
read
function. More details can be found inptolemy.ex
- 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
init(loader_pid) View Source
Invoked to setup a provider. This callback is only called once per provider, and is called lazily.
Callback implementation for Ptolemy.Provider.init/1
.
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
init(pid) View Source
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.
load(pid, list) View Source
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
- pid pid denotes the server that holds the state of vault server
- engine_name engine_name helps Ptolemy to find the correct engine configuration
- opts
opts is another list, the content depends on engine type. See
ptolemy.ex
docs for more. - access_keys access keys is a list of keys to access a specific element within the returned nested data structure