Skip to content

Conversation

@sj26
Copy link
Member

@sj26 sj26 commented Jul 6, 2025

I have an org token already configured:

# ~/.config/bk.yaml
organizations:
    buildkite:
        api_token: ...

I go into a directory I haven't used bk in before, and it asks me to configure a token:

$ bk build view
Error: You must set a valid API token. Run `bk configure`. (failed during: bk)

So I do:

bk config
┃ Organization slug: buildkite
┃ API Token:

Hold on - it already knows my token! Why is it asking me, I don't know it!

We should skip this when we already have a token for the matching org. So, that's what this PR does.

(Technically the bk build view error is also incorrect - I have an API token configured, bk just doesn't understand which one to use.)

Based on #497 because Amp helped me out:

https://ampcode.com/threads/T-60c7ab55-fc0c-4c76-8855-3d8ba87fd8a0

sj26 and others added 3 commits July 6, 2025 23:14
- Add GetTokenForOrg method to config to retrieve tokens for specific organizations
- Modify bk configure to check for existing tokens before prompting
- Display "Using existing API token for organization: {org}" when token exists
- Add comprehensive test coverage for token reuse scenarios
- Maintains backward compatibility for new organizations

Amp-Thread: https://ampcode.com/threads/T-60c7ab55-fc0c-4c76-8855-3d8ba87fd8a0
Co-authored-by: Amp <amp@ampcode.com>
Only write token configuration when it's new, not when reusing existing tokens.
This prevents unnecessary file writes when the configuration hasn't changed.

Amp-Thread: https://ampcode.com/threads/T-60c7ab55-fc0c-4c76-8855-3d8ba87fd8a0
Co-authored-by: Amp <amp@ampcode.com>
@sj26 sj26 requested a review from a team as a code owner July 6, 2025 13:36
sj26 and others added 2 commits July 6, 2025 23:41
Update documentation to use the correct golangci-lint command that actually works:
`docker-compose -f .buildkite/docker-compose.yaml run golangci-lint golangci-lint run`

Amp-Thread: https://ampcode.com/threads/T-60c7ab55-fc0c-4c76-8855-3d8ba87fd8a0
Co-authored-by: Amp <amp@ampcode.com>
@sj26 sj26 self-assigned this Jul 6, 2025
@sj26
Copy link
Member Author

sj26 commented Jul 6, 2025

Discovered the documented lint command was wrong, so updated that too.

@mcncl mcncl enabled auto-merge (squash) July 6, 2025 23:10
@mcncl mcncl disabled auto-merge July 6, 2025 23:17
Copy link
Contributor

@lizrabuya lizrabuya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@mcncl mcncl merged commit d3e9c8c into main Jul 7, 2025
1 check passed
@mcncl mcncl deleted the bk-configure-already-org-token branch July 7, 2025 03:38
@sj26
Copy link
Member Author

sj26 commented Jul 8, 2025

🙏

@toolmantim toolmantim mentioned this pull request Jul 16, 2025
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.

4 participants