Skip to content

Commit 98809bf

Browse files
committed
command line option for profile
1 parent 54b88e5 commit 98809bf

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/datacustomcode/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def scan(filename: str, config: str, dry_run: bool, no_requirements: bool):
193193
@click.argument("entrypoint")
194194
@click.option("--config-file", default=None)
195195
@click.option("--dependencies", default=[], multiple=True)
196-
def run(entrypoint: str, config_file: Union[str, None], dependencies: List[str]):
196+
@click.option("--profile", default="default")
197+
def run(entrypoint: str, config_file: Union[str, None], dependencies: List[str], profile: str):
197198
from datacustomcode.run import run_entrypoint
198199

199-
run_entrypoint(entrypoint, config_file, dependencies)
200+
run_entrypoint(entrypoint, config_file, dependencies, profile)

src/datacustomcode/run.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,22 @@
2020

2121

2222
def run_entrypoint(
23-
entrypoint: str, config_file: Union[str, None], dependencies: List[str]
23+
entrypoint: str, config_file: Union[str, None], dependencies: List[str], profile: str
2424
) -> None:
2525
"""Run the entrypoint script with the given config and dependencies.
2626
2727
Args:
2828
entrypoint: The entrypoint script to run.
2929
config_file: The config file to use.
3030
dependencies: The dependencies to import.
31+
profile: The profile to use.
3132
"""
33+
if profile != "default":
34+
if config.reader_config and hasattr(config.reader_config, 'options'):
35+
config.reader_config.options["credentials_profile"] = profile
36+
if config.writer_config and hasattr(config.writer_config, 'options'):
37+
config.writer_config.options["credentials_profile"] = profile
38+
3239
if config_file:
3340
config.load(config_file)
3441
for dependency in dependencies:

0 commit comments

Comments
 (0)