show_default=False,
help="Enable verbose debug output/logging",
),
+ no_parallel: bool = typer.Option(
+ False,
+ "--no-parallel",
+ "-np",
+ show_default=False,
+ help="Disables parallel operations (multiprocessing)",
+ ),
include: Optional[List[str]] = typer.Option(
["All"],
"--include",
envvar="OP_VAULT_EXC",
help="Excludes the specified vault(s) from processing",
),
- no_tags: bool = typer.Option(
+ hide_tags: bool = typer.Option(
False, "--no-tags", "-n", help="Hide metadata tags in credential summary/output"
),
):
f.validate_import_data_opts(include, exclude)
vaults_dictionary = f.populate_vault_json(include, exclude)
f.show_vault_summary(vaults_dictionary)
- f.import_credentials(vaults_dictionary)
+ f.import_credentials(vaults_dictionary, no_parallel)
credential_data = f.caching.load_cache("credentials")
- f.credential_summary(credential_data, no_tags, True)
+ f.credential_summary(credential_data, hide_tags, True)
@app.command()
show_default=False,
help="Enable verbose debug output/logging",
),
- no_tags: bool = typer.Option(
+ hide_tags: bool = typer.Option(
False, "--no-tags", "-n", help="Hide metadata tags in credential summary/output"
),
):
"""Show credentials in current/filtered working set"""
f.startup_tasks(debug)
credential_data = caching.load_cache("credentials")
- f.credential_summary(credential_data, no_tags, False)
+ f.credential_summary(credential_data, hide_tags, False)
@app.command()
show_default=False,
help="Enable verbose debug output/logging",
),
- no_tags: bool = typer.Option(
+ hide_tags: bool = typer.Option(
False, "--no-tags", "-n", help="Hide metadata tags in credential summary/output"
),
match: Optional[List[str]] = typer.Option(
f.startup_tasks(debug)
f.validate_filter_items_opts(match, reject)
credential_data = f.filter_credentials(match, reject, ignore_case)
- f.credential_summary(credential_data, no_tags, True)
+ f.credential_summary(credential_data, hide_tags, True)
if f.prompt("Update working credential set to selection?"):
caching.save_cache(credential_data, "credentials")
else:
def credential_summary(
- credential_list: List[Dict], no_tags: bool, prompt_flag: bool
+ credential_list: List[Dict], hide_tags: bool, prompt_flag: bool
) -> None:
"""Displays a list/summary of the current working set of credentials"""
name = credential["title"]
# Tag display might make for messy output and take up excessive screen space
# We therefore provide an option to suppress them in summary/output
- if no_tags:
+ if hide_tags:
log.info("%s %s", cred_id, name)
continue
# Not all credentials have tags, catch the exception
return (vault, vault_credentials)
-def import_credentials(vaults: Dict[str, str]) -> None:
+def import_credentials(vaults: Dict[str, str], no_parallel: bool) -> None:
"""Given a dictionary of vaults, populates the credential database(s)"""
log.info("Importing credential metadata from 1Password database...")
# Use timers to profile performance
timer = start_timer()
- with multiprocessing.Pool() as pool:
- # Call the function for each item in parallel
- for vault, credentials in pool.map(get_credentials_mp, vaults):
+ if no_parallel:
+ # Fetches credentials in series with no multiprocessing
+ log.info("Parallel retrieval of credentials is DISABLED")
+ for vault in vaults:
+ null, credentials = get_credentials_mp(vault)
vault_creds_dictionary = {vault: credentials}
vault_credentials.append(vault_creds_dictionary)
+ else:
+ log.info("Parallel retrieval of credentials is ENABLED")
+ with multiprocessing.Pool() as pool:
+ # Call the function for each item in parallel
+ for vault, credentials in pool.map(get_credentials_mp, vaults):
+ vault_creds_dictionary = {vault: credentials}
+ vault_credentials.append(vault_creds_dictionary)
stop_timer(timer)