Skip to content

Anaconda login from ENV variable #529

@tgsmith61591

Description

@tgsmith61591

It appears the only way to login to Anaconda from CLI is interactively, or by plain text:

$ anaconda login --username MyUser --password abc123

This poses a problem on CI platforms when trying to automate deployments to an anaconda repo, especially because some CI solutions are not good about masking secrets in logs. In other words, this wouldn't work because some platforms, e.g., Circle CI, will print the command in plain text without obfuscating the secrets:

$ anaconda login --username $ANACONDA_USERNAME --password $ANACONDA_PASSWORD

Examining the source code, it appears there is no other option for logging in.

        if getattr(args, 'login_username', None):
            username = args.login_username
        else:
            username = input('Username: ')

Would it be feasible to add logic to support a reserved environment variable, e.g., ANACONDA_USERNAME/ANACONDA_PASSWORD like:

        if getattr(args, 'login_username', None):
            username = args.login_username
        elif os.getenv('ANACONDA_USERNAME'):
            username = os.env['ANACONDA_USERNAME']
        else:
            username = input('Username: ')

Twine does something similar, and it would make automation much more simple. If there is any agreement from the team, I'd be happy to submit a PR, just wanted to float the idea...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions