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 CLI list flags and re-introduce --http-header flag #222

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ sandbox-models:
--metabase-username $$MB_USER \
--metabase-password $$MB_PASSWORD \
--metabase-database $$POSTGRES_DB \
--include-schemas "public",other \
--http-header x-dummy-key dummy-value \
--verbose )
.PHONY: sandbox-models

Expand Down
15 changes: 12 additions & 3 deletions dbtmetabase/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import functools
import logging
from pathlib import Path
from typing import Any, Callable, List, Mapping, Optional, Sequence, Union, cast
from typing import Any, Callable, List, Mapping, Optional, Sequence, Tuple, Union, cast

import click
import yaml
Expand Down Expand Up @@ -34,9 +34,9 @@ def callback(
# Lists in defaults (config or option) should be lists
return value

elif isinstance(value, str):
if isinstance(value, str):
str_value = value
if isinstance(value, list):
elif isinstance(value, list):
# When type=list, string value will be a list of chars
str_value = "".join(value)
else:
Expand Down Expand Up @@ -143,6 +143,13 @@ def _add_setup(func: Callable) -> Callable:
show_default=True,
help="HTTP timeout in seconds.",
)
@click.option(
"--http-header",
"http_headers",
type=(str, str),
multiple=True,
help="Additional HTTP request headers.",
)
@click.option(
"-v",
"--verbose",
Expand All @@ -159,6 +166,7 @@ def wrapper(
skip_verify: bool,
cert: Optional[str],
http_timeout: int,
http_headers: Sequence[Tuple[str, str]],
verbose: bool,
**kwargs,
):
Expand All @@ -177,6 +185,7 @@ def wrapper(
skip_verify=skip_verify,
cert=cert,
http_timeout=http_timeout,
http_headers={k: v for k, v in http_headers},
),
**kwargs,
)
Expand Down
Loading