Skip to content

Commit

Permalink
chore: rename api_key setting
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers committed Aug 28, 2023
1 parent 7970318 commit 0a6cfaa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
12 changes: 10 additions & 2 deletions .devcontainer/destination-duckdb/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@
],
"settings": {
"extensions.ignoreRecommendations": true,
"git.openRepositoryInParentFolders": "always",
"python.defaultInterpreterPath": ".venv/bin/python",
"python.interpreter.infoVisibility": "always",
"git.openRepositoryInParentFolders": "always",
"python.terminal.activateEnvironment": true,
"python.testing.pytestEnabled": true,
"python.testing.cwd": "/workspaces/airbyte/airbyte-integrations/connectors/destination-duckdb",
"python.testing.pytestArgs": ["--rootdir=/workspaces/airbyte/airbyte-integrations/connectors/destination-duckdb", "."]
}
},
"codespaces": {
"repositories": {
"airbytehq/airbyte": {
"python.testing.pytestEnabled": true
}
}
}
},
"containerEnv": {
Expand All @@ -43,7 +51,7 @@
// 2. Map the devcontainer.json file to it.
// 3. Mark the root directory as 'safe' for git.
// 4. Install the Python/Poetry dependencies.
"postCreateCommand": "mkdir -p ./.symlinks && ln -sf /workspaces/airbyte/.devcontainer/destination-duckdb/devcontainer.json ./.symlinks/devcontainer.json && git config --add safe.directory /workspaces/airbyte && poetry install"
"postCreateCommand": "mkdir -p ./.symlinks && ln -sf /workspaces/airbyte/docs/destinations/duckdb/devcontainer.json ./.symlinks/devcontainer.json && ln -sf /workspaces/airbyte/docs/integrations/destinations/duckdb.md ./.symlinks/duckdb-docs.md && git config --add safe.directory /workspaces/airbyte && poetry install"

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def write(
path = self._get_destination_path(path)

# Get and register auth token if applicable
api_key = str(config.get("api_key"))
if api_key:
os.environ["motherduck_token"] = api_key
motherduck_api_key = str(config.get("motherduck_api_key"))
if motherduck_api_key:
os.environ["motherduck_token"] = motherduck_api_key

con = duckdb.connect(database=path, read_only=False)

Expand Down Expand Up @@ -157,14 +157,12 @@ def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConn
path = config.get("destination_path")
path = self._get_destination_path(path)

api_key = config.get("api_key")

if path.startswith("/local"):
logger.info(f"Using DuckDB file at {path}")
os.makedirs(os.path.dirname(path), exist_ok=True)

if "api_key" in config:
os.environ["motherduck_token"] = config["api_key"]
if "motherduck_api_key" in config:
os.environ["motherduck_token"] = config["motherduck_api_key"]

con = duckdb.connect(database=path, read_only=False)
con.execute("SELECT 1;")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"required": ["destination_path"],
"additionalProperties": true,
"properties": {
"api_key": {
"motherduck_api_key": {
"type": "string",
"description": "API key to use for authentication to a MotherDuck database.",
"writeOnly": true
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/destinations/duckdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To specify a MotherDuck-hosted database as your destination, simply provide your

### Authenticating to MotherDuck

For authentication, you can can provide your [MotherDuck Service Credential](https://motherduck.com/docs/authenticating-to-motherduck/#syntax) as the `api_key` configuration option.
For authentication, you can can provide your [MotherDuck Service Credential](https://motherduck.com/docs/authenticating-to-motherduck/#syntax) as the `motherduck_api_key` configuration option.

### Sync Overview

Expand Down

0 comments on commit 0a6cfaa

Please sign in to comment.