Skip to content

Add CircleCI token as first-class config option#210

Closed
schurchleycci wants to merge 3 commits intomainfrom
config-circleci-token
Closed

Add CircleCI token as first-class config option#210
schurchleycci wants to merge 3 commits intomainfrom
config-circleci-token

Conversation

@schurchleycci
Copy link
Copy Markdown
Contributor

@schurchleycci schurchleycci commented Apr 9, 2026

Summary

  • Add CircleCIToken field to UserConfig with env-var > config-file precedence (CIRCLE_TOKEN > CIRCLECI_TOKEN > config file)
  • Refactor NewClient(token, baseURL string) to accept explicit params — the circleci package no longer reads env vars or imports config
  • Add newCircleCIClient() helper in cmd/ that resolves tokens via config.Resolve() and passes them through
  • Add auth set circleci command that prompts for a token, validates it via GET /api/v2/me, and saves to config
  • Add GetCurrentUser() to the CircleCI client for token validation
  • Add ErrSilent error type so commands can exit non-zero without double-printing
  • Show circleCIToken in config show output

Test plan

  • task build compiles cleanly
  • task test passes (746 tests)
  • task lint — 0 issues
  • chunk auth set circleci prompts for token, validates, and saves to config
  • chunk config show displays circleCIToken with source
  • Token resolves correctly from CIRCLE_TOKEN / CIRCLECI_TOKEN env vars and config file
  • Commands error cleanly when no token is configured

🤖 Generated with Claude Code

Note

Part 1 of 2 — stacked PR series for multi-provider auth support

@schurchleycci schurchleycci force-pushed the config-circleci-token branch 2 times, most recently from 9cc2b1d to 3234ded Compare April 10, 2026 13:52
@schurchleycci schurchleycci force-pushed the config-circleci-token branch 6 times, most recently from 43a66f4 to 6cfa14a Compare April 10, 2026 20:05
schurchleycci and others added 3 commits April 10, 2026 16:15
- Add CircleCIToken to UserConfig and ResolvedConfig with env-var >
  config-file precedence (CIRCLE_TOKEN > CIRCLECI_TOKEN > config file)
- NewClient() now resolves token via config.Resolve() instead of
  reading env vars directly; add NewClientWithToken() for tests and
  explicit-token use cases (e.g. token validation during auth set)
- Add `auth set circleci` command: prompts for token, validates via
  GET /api/v2/me, saves to config
- Add ErrSilent so commands can exit non-zero without double-printing
- Add GetCurrentUser() to CircleCI client for token validation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
NewClient() now uses config.Resolve() to look up the CircleCI token
(env vars + config file) instead of only reading env vars directly.
Also shows circleCIToken in config show output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename "custom base URL" test to "default base URL" since it tests
empty CIRCLECI_BASE_URL. Restore blank lines removed without reason
in task_test.go.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@schurchleycci
Copy link
Copy Markdown
Contributor Author

Superseded by #221 which collapses #210 and #212 into a single PR rebased onto current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant