From 189ed5f43a686c108bc31714037e306742745fbd Mon Sep 17 00:00:00 2001 From: Jan-Benedikt Jagusch Date: Wed, 24 Mar 2021 14:35:55 +0100 Subject: [PATCH] add --auth arg --- README.md | 4 ++-- conda_lock/conda_lock.py | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eaded29a0..fcc8b1871 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ is being built from support them). This can be disabled easily conda-lock --no-dev-dependencies -f ./recipe/meta.yaml ``` -#### --strip-auth and --auth-file +#### --strip-auth, --auth and --auth-file By default `conda-lock` will leave basic auth credentials for private conda channels in the lock file. If you wish to strip authentication from the file, provide the `--strip-auth` argument. @@ -95,7 +95,7 @@ In order to `conda-lock install` a lock file with its basic auth credentials str } ``` -Then, you need to provide the path to the authentication file through the `--auth-file` argument. +You can provide the authentication either as string through `--auth` or as a filepath through `--auth-file`. ``` conda-lock install --auth-file auth.json conda-linux-64.lock diff --git a/conda_lock/conda_lock.py b/conda_lock/conda_lock.py index ed2c8da7e..a09bc8b51 100644 --- a/conda_lock/conda_lock.py +++ b/conda_lock/conda_lock.py @@ -728,11 +728,16 @@ def lock( ) @click.option("-p", "--prefix", help="Full path to environment location (i.e. prefix).") @click.option("-n", "--name", help="Name of environment.") +@click.option( + "--auth", + help="The auth file provided as string. Has precedence over `--auth-file`.", + default="", +) @click.option("--auth-file", help="Path to the authentication file.", default="") @click.argument("lock-file") -def install(conda, mamba, micromamba, prefix, name, lock_file, auth_file): +def install(conda, mamba, micromamba, prefix, name, lock_file, auth, auth_file): """Perform a conda install""" - auth = read_json(auth_file) if auth_file else None + auth = json.loads(auth) if auth else read_json(auth_file) if auth_file else None _conda_exe = determine_conda_executable(conda, mamba=mamba, micromamba=micromamba) install_func = partial(do_conda_install, conda=_conda_exe, prefix=prefix, name=name) if auth: