Skip to content

Add a global organization flag to CLI commands - #1024

Merged
mcncl merged 3 commits into
mainfrom
feat/global_org_flag
Oct 8, 2026
Merged

mcncl merged 3 commits into
mainfrom
feat/global_org_flag

Conversation

@mcncl

@mcncl mcncl commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Build list and view currently rely on the selected organization, making multi-organization use awkward for scripts and agents. Add a global --org flag so callers can select an organization for one invocation without editing configuration:

bk build list --org other-org
bk build view 123 --pipeline my-pipeline --org other-org
bk --org other-org job list

Resolves PB-2563.

Changes

  • Apply --org above environment and saved defaults for all organization-scoped commands, using the selected organization's credentials. Explicit API environment tokens retain precedence.
  • Reject disagreements between explicit --org and qualified pipeline/build source targets before execution. Cross-organization pipeline copy --target destinations remain independent.
  • Ignore cached pipeline names when the effective organization differs from the saved selection, and avoid caching repository discoveries under a temporary organization.
  • Preserve pipeline lookup errors for numeric build targets, with the selected organization and a --pipeline hint instead of an invalid-input error.
  • Preserve authentication/configure behavior and logout flag conflicts. Explicit organization switches still persist their selection.

Testing

  • Tests have run locally (go test ./... through mise run test, with injected API token/organization variables unset as in CI).
  • Code is formatted (mise run format, using gofumpt).
  • mise run lint: 0 issues.
  • Regression tests exercise request paths and credentials, configuration preservation, cached-org read boundaries and rediscovery, qualified-target conflicts, explicit switches, and empty/conflicting flags.

Allow build list, build view, and other organization-scoped commands to
select an organization for one invocation without changing saved defaults.
Use the existing organization-specific credential selection and preserve
command-specific authentication and pipeline behavior.

Keep temporary pipeline discoveries out of saved configuration and make
explicit organization switches persist independently of the override.
Cover precedence, credentials, persistence, and flag compatibility.

Resolves PB-2563

Amp-Thread-ID: T-e2c85e09-760b-48dd-9382-cdc2132f076c
@mcncl
mcncl requested review from a team as code owners October 8, 2026 08:10

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking findings. I’m leaving approval to a human because this changes organization-specific credential routing across authentication and secret commands.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 38215, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

About buildsworth

Model: gpt-6.1-sol with xhigh thinking.

How to request a review: Comment @buildsworth-bk review on the PR, or request buildsworth-bk as a reviewer.

Risk labels (how buildsworth classifies risk) — buildsworth classifies risk itself from the diff. Unless repository policy already allows L2 approval, grant it by mentioning @buildsworth-bk (see approval ceiling and L2 approval grant):

  • L1 — Low risk (dep bumps, docs/copy, lockfiles, small presentational fixes). buildsworth may approve by default.
  • L2 — Standard risk (new UI, additive API fields, refactors). Approved only when repository policy or a verified grant allows it; otherwise comment-only.
  • L3 — High risk (auth, migrations, payments, secrets, perf-critical pipeline paths). Human approval required unless repository policy explicitly allows L3 approval; per-PR grants cannot allow it.

@scadu scadu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One blocker: --org still reads pipelines cached for the saved org. Also, --org and org/pipeline win in a different order depending on the command, see inline.

Comment thread internal/pipeline/resolver/picker.go
Comment thread main_test.go Outdated
Keep cached pipeline names scoped to the saved organization so a
one-off organization cannot reinterpret them as a different target.

Reject disagreements between --org and qualified source targets before
execution. Leave cross-organization pipeline copy destinations intact.
Cover matching and conflicting targets, cache boundaries, and repository
rediscovery in regression tests.

Amp-Thread-ID: https://ampcode.com/threads/T-e2c85e09-760b-48dd-9382-cdc2132f076c
@mcncl
mcncl requested a review from scadu October 8, 2026 08:57

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No new actionable findings. I’m still leaving approval to a human because this changes organization-specific credential routing across authentication and secret commands.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 38226, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

Comment thread internal/config/config.go
A valid build number needs a pipeline before it can be resolved. Keep
pipeline lookup errors instead of reporting the build input as invalid,
and include the effective organization and a --pipeline hint.

Cover empty repository discovery under an overridden organization,
underlying error identity, and unchanged invalid-input behavior.

Amp-Thread-ID: https://ampcode.com/threads/T-e2c85e09-760b-48dd-9382-cdc2132f076c

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No new actionable findings. Approval still needs a human because --org changes organization-specific credential routing through authentication and secret commands.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 38228, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@mcncl
mcncl merged commit 39525a3 into main Oct 8, 2026
2 checks passed
@mcncl
mcncl deleted the feat/global_org_flag branch October 8, 2026 09:23
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