Skip to content

Commit

Permalink
Fix CLI list flags and re-introduce --http-header flag (#222)
Browse files Browse the repository at this point in the history
* Fix CLI flag list types

* Re-introduce --http-header CLI flag

* List and tuple CLI flags in sandbox invocation to catch issues early
  • Loading branch information
gouline committed Jan 26, 2024
1 parent 00f0055 commit 2f8c88d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 2f8c88d

Please sign in to comment.