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

Fix link and add env var naming example #1763

Merged
merged 1 commit into from
Sep 10, 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
66 changes: 61 additions & 5 deletions docs/website/docs/general-usage/credentials/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ keywords: [credentials, secrets.toml, secrets, config, configuration, environmen
variables, provider]
---

`dlt` automatically extracts configuration settings and secrets based on flexible [naming conventions](setup/#naming-convention).
`dlt` automatically extracts configuration settings and secrets based on flexible [naming conventions](#naming-convention).

It then [injects](advanced/#injection-mechanism) these values where needed in functions decorated with `@dlt.source`, `@dlt.resource`, or `@dlt.destination`.

Expand Down Expand Up @@ -39,15 +39,71 @@ Please make sure your pipeline name contains no whitespace or any other punctuat

To keep the naming convention flexible, `dlt` looks for a lot of possible combinations of key names, starting from the most specific possible path. Then, if the value is not found, it removes the right-most section and tries again.

* The most specific possible path for **sources** looks like:
The most specific possible path for **sources** looks like:

<Tabs
groupId="config-provider-type"
defaultValue="toml"
values={[
{"label": "Toml config provider", "value": "toml"},
{"label": "ENV variables", "value": "env"},
{"label": "In the code", "value": "code"},
]}>
<TabItem value="toml">

```sh
[<pipeline_name>.sources.<source_module_name>.<source_function_name>]
<argument_name>="some_value"
```
</TabItem>
<TabItem value="env">

```sh
export PIPELINE_NAME__SOURCES__SOURCE_MODULE_NAME__SOURCE_FUNCTION_NAME__ARGUMENT_NAME="some_value"
```
</TabItem>
<TabItem value="code">

```py
import os

os.environ["PIPELINE_NAME__SOURCES__SOURCE_MODULE_NAME__SOURCE_FUNCTION_NAME__ARGUMENT_NAME"] = "some_value"
```
</TabItem>
</Tabs>

The most specific possible path for **destinations** looks like:

<Tabs
groupId="config-provider-type"
defaultValue="toml"
values={[
{"label": "Toml config provider", "value": "toml"},
{"label": "ENV variables", "value": "env"},
{"label": "In the code", "value": "code"},
]}>
<TabItem value="toml">

```sh
<pipeline_name>.sources.<source_module_name>.<source_function_name>.<argument_name>
[<pipeline_name>.destination.<destination name>.credentials]
<credential_option>="some_value"
```
</TabItem>
<TabItem value="env">

* The most specific possible path for **destinations** looks like:
```sh
<pipeline_name>.destination.<destination name>.credentials.<credential_option>
export PIPELINE_NAME__DESTINATION__DESTINATION_NAME__CREDENTIALS__CREDENTIAL_VALUE="some_value"
```
</TabItem>
<TabItem value="code">

```py
import os

os.environ["PIPELINE_NAME__DESTINATION__DESTINATION_NAME__CREDENTIALS__CREDENTIAL_VALUE"] = "some_value"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would mention in code:

import dlt 

dlt.secrets["<pipeline_name>.destination.<destination name>.credentials"] = "some_value"

```
</TabItem>
</Tabs>

### Example

Expand Down
Loading