Skip to content

feat: read the connection settings from ASCENDER_ environment variables - #72

Merged
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:feat/ascender-environment-variables
Sep 14, 2026
Merged

cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:feat/ascender-environment-variables

Conversation

@blaipr

@blaipr blaipr commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Every connection setting the client takes from the environment now answers to an ASCENDER_ name: ASCENDER_HOST, ASCENDER_OAUTH_TOKEN, ASCENDER_TOKEN, ASCENDER_USERNAME, ASCENDER_PASSWORD, ASCENDER_VERIFY_SSL, ASCENDER_VERBOSE, ASCENDER_FORMAT and ASCENDER_COLOR.

Same shape as ascender-manage: the new name is what the documentation says, and the old ones keep working.

Why a helper rather than one more level of env.get

The token lookup was already four deep:

default=env.get('CONTROLLER_OAUTH_TOKEN', env.get('CONTROLLER_TOKEN', env.get('TOWER_OAUTH_TOKEN', env.get('TOWER_TOKEN', '')))),

Adding two more spellings inside that would have put the default out of sight of the argument it belongs to. env_default takes the suffix and walks the prefixes, so the precedence is stated once and every argument reads the same way:

default=env_default(env, 'OAUTH_TOKEN', '', extra=('TOKEN',)),

Precedence

ASCENDER_, then CONTROLLER_, then TOWER_, prefix before suffix. So ASCENDER_TOKEN beats CONTROLLER_OAUTH_TOKEN: the prefix says which release the script was written against, where the suffix is only a spelling of the same thing. Below the new prefix the old chain keeps exactly the order it had, and a name that is set but empty still wins over a later one, which is what the nested env.get calls did.

One behaviour change

ascender login -f human prints export ASCENDER_OAUTH_TOKEN= rather than export CONTROLLER_OAUTH_TOKEN=. Both are read, so a shell that already sourced the old line keeps working.

Checking

Eight tests name the precedence one rule at a time, and two more go through parse_args so the wiring is covered rather than just the helper. Both kinds fail against the old code rather than passing regardless.

The integration tests that prove the token path works by stripping the username and password out of the environment now strip all three prefixes. With only one removed, a developer with an older spelling exported would have stayed authenticated by password and those tests would have passed without exercising the token at all.

378 unit tests pass, ruff format --check and ruff check are clean, and the documentation builds with -W.

Every connection setting the client takes from the environment now answers to
an ASCENDER_ name: ASCENDER_HOST, ASCENDER_OAUTH_TOKEN, ASCENDER_TOKEN,
ASCENDER_USERNAME, ASCENDER_PASSWORD, ASCENDER_VERIFY_SSL, ASCENDER_VERBOSE,
ASCENDER_FORMAT and ASCENDER_COLOR. This is the same shape as ascender-manage:
the new name is what the documentation says, and the old ones keep working.

The nesting is what made this worth a helper rather than one more level of
env.get. The token was already four deep, and adding two more spellings inside
it would have put the default out of sight of the name it belongs to. env_default
takes the suffix and the ordered prefixes instead, so the precedence is stated
once and every argument reads the same way.

Precedence is ASCENDER_, then CONTROLLER_, then TOWER_, prefix before suffix, so
ASCENDER_TOKEN beats CONTROLLER_OAUTH_TOKEN: the prefix says which release the
script was written against, where the suffix is only a spelling. Below the new
prefix the old chain keeps the order it already had, and a name that is set but
empty still wins over a later one, which is what the nested env.get calls did.

ascender login -f human prints the ASCENDER_ name now. Both are read, so a shell
that already sourced the old line keeps working.

The integration tests that prove the token path works by stripping the username
and password out of the environment now strip all three prefixes. With only one
of them removed, a developer with the older spelling exported would have stayed
authenticated by password and the tests would have passed without exercising
the token at all.
@ciq-it-service-account

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cigamit cigamit self-assigned this Sep 14, 2026
@cigamit cigamit added the enhancement New feature or request label Sep 14, 2026
@cigamit
cigamit merged commit 9ba4f52 into ctrliq:main Sep 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

3 participants