Skip to content

CODER_FIRST_* environment vars ignored for coder login #4485

Closed
@hh

Description

@hh

ENV vars to set defaults for coder login are ignored.

Note the email, password, and username provided via ENV vars show up in --help

ii@prerepair:~/sharingio/coder$ coder login -h
Authenticate with Coder deployment

Usage:
  coder login <url> [flags]

Flags:
  -e, --email string      Specifies an email address to authenticate with.
                          Consumes $CODER_EMAIL (default "hh@ii.coop")
  -h, --help              help for login
  -p, --password string   Specifies a password to authenticate with.
                          Consumes $CODER_PASSWORD (default "ii")
  -u, --username string   Specifies a username to authenticate with.
                          Consumes $CODER_USERNAME (default "ii")

If the '-u' option is not provided (and it's currently not defaulting to CODER_USERNAME, tty detection is enabled and calling coder login without arguments fails.

Ideally setting these ENV vars would allow us to run coder login and respect the ENV provided defaults. I'm also recommend removing the isTTY altogether.

https://github.com/coder/coder/blob/main/cli/login.go#L91-L94

	if username == "" {
                    if !isTTY(cmd) {
                        return xerrors.New("the initial user cannot be created in non-interactive mode. use the API")
                    }

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