Plato.Storage.Config (plato v0.0.24)

Copy Markdown View Source

Helper functions for retrieving storage configuration.

Examples

Check if storage is configured:

iex> Application.put_env(:example_app, :plato, storage: [
...>   adapter: Plato.Storage.S3Adapter,
...>   bucket: "test-bucket",
...>   access_key_id: "key",
...>   secret_access_key: "secret"
...> ])
iex> Plato.Storage.Config.configured?(:example_app)
true
iex> Application.delete_env(:example_app, :plato)
:ok

iex> Plato.Storage.Config.configured?(:unconfigured_app)
false

Summary

Functions

Get the storage adapter module for an otp_app.

Check if storage is properly configured for an otp_app.

Get storage configuration for an otp_app.

Functions

adapter(otp_app)

Get the storage adapter module for an otp_app.

Returns the adapter module or nil if not configured.

configured?(otp_app)

Check if storage is properly configured for an otp_app.

Returns true if adapter, bucket, and credentials are configured. For S3, requires access_key_id and secret_access_key.

get(otp_app)

Get storage configuration for an otp_app.

Returns the storage keyword list from the app's Plato configuration.

Examples

iex> Application.put_env(:my_app, :plato, storage: [bucket: "my-bucket"])
iex> Plato.Storage.Config.get(:my_app)
[bucket: "my-bucket"]

iex> Plato.Storage.Config.get(:nonexistent_app)
[]