Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment Variable config #408

Merged
merged 4 commits into from
Dec 3, 2024
Merged

Environment Variable config #408

merged 4 commits into from
Dec 3, 2024

Conversation

moskyb
Copy link
Contributor

@moskyb moskyb commented Dec 2, 2024

This PR: Allows users to specify their buildkite API tokens and organization slugs via environment variable, allowing them to end-run around the bk configure command. This should make running the bk cli in headless environments (like CI jobs 👀) much easier.

Environment variables take precedence over config items specified in files, as is fairly standard across CLI tools.

Example:

$ rm ~/.config/bk.yaml
$ export BUILDKITE_API_TOKEN=bkua_haha_nice_try 
$ export BUILDKITE_ORGANIZATION_SLUG=bennos-extra-secret-org 
$ bk pipeline view "my-cool-pipeline"
  My Cool Pipeline: Possibly the coolest pipeline around
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

                         Speed: 11s    Reliability: 80%

    agents:
      queue: default

    steps:
      - command: buildkite-agent pipeline upload

Additionally, it adds another envar for BUILDKITE_REST_API_HOST, similar to the graphql host envar added in #406. This should make local development easier.

🍷🧀 This PR should pair with #407 nicely - they allow gradations in how interactive you want CLI configuration to be

Comment on lines +187 to +189
func firstNonEmpty(s ...string) string {
for _, k := range s {
if k != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was there a reason for changing this? I think we only ever give it strings, but in its current form it could be used with any comparable type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nothing other than YAGNI - i figured if we weren't using generics we probably shouldn't use generics, but i'm more than happy to change it back if you like

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah, not at all, think it was in as a just in case, but we can re-visit if it's ever needed

@mcncl mcncl enabled auto-merge (squash) December 3, 2024 02:00
@mcncl mcncl merged commit 870be22 into main Dec 3, 2024
1 check passed
@mcncl mcncl deleted the envar-config branch December 3, 2024 02:03
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.

2 participants