Skip to content

refactor(plugin): clean up --yes wiring in plugin cmds - #809

Closed
ajalon1 wants to merge 7 commits into
aj/fix-testsfrom
aj/fix-plugin-install-yes-flag
Closed

refactor(plugin): clean up --yes wiring in plugin cmds#809
ajalon1 wants to merge 7 commits into
aj/fix-testsfrom
aj/fix-plugin-install-yes-flag

Conversation

@ajalon1

@ajalon1 ajalon1 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

RATIONALE

CHANGES

PR Automation

Comment-Commands: Trigger CI by commenting on the PR:

  • /trigger-smoke-test or /trigger-test-smoke - Run smoke tests
  • /trigger-install-test or /trigger-test-install - Run installation tests

Labels: Apply labels to trigger workflows:

  • run-smoke-tests or go - Run smoke tests on demand (only works for non-forked PRs)

Important

For Forked PRs: The run-smoke-tests label won't work. A required Smoke Tests check will block merge until a maintainer acts:

  • A maintainer uses /approve-smoke-tests to run smoke tests (results will set the check)
  • A maintainer uses /skip-smoke-tests to bypass the check without running tests

Please comment requesting a maintainer review if you need smoke tests to run.

ajalon1 and others added 7 commits August 19, 2026 11:54
fix(ci): pin arduino/setup-task Task version to 3.52.0

`version: 3.x` in the three arduino/setup-task call sites floats to
whatever go-task/task release GitHub reports as latest on every run.
go-task/task cut v3.53.1 on 2026-08-18 but its release assets weren't
fully published until ~18 minutes after the tag was created; our
build-windows and smoke-test (macos-latest) jobs ran in that window,
resolved the brand-new tag, and 404'd downloading its binary:

  Failed to download version v3.53.1: Unexpected HTTP response: 404

Pin to the exact, already-published 3.52.0 to close the race, matching
the project's existing convention of pinning tool versions explicitly
(GOLANGCI_LINT_VERSION, LEFTHOOK_VERSION, JSCPD_VERSION,
GORELEASER_VERSION in Taskfile.yaml).

The action.yaml pin mirrors the fix Taras Pokornyy already landed for
that call site in #788; this extends it to the two other call sites
his PR doesn't touch.

Co-authored-by: Taras Pokornyy <34406052+taras-pokornyy@users.noreply.github.com>
* Update Docker base image to latest version
unpin wolfi images since they disappear
* Update Dockerfile.goreleaser
* Follow-up code review validation
* Remove comment about task resolution in cmd.go
Removed commented code regarding task resolution.
Adds a `RootFactory` type (`cmd/root_factory.go`) that constructs the root
cobra command from a set of injectable `Dependencies`, mirroring the approach
used by GitHub CLI (`pkg/cmdutil.Factory`) and kubectl (`pkg/cmd/util.Factory`).

Key changes:

- `cmd/root_factory.go`: defines `RootFactory`, `Dependencies`, and five
  functional option helpers (`WithConfigInitializer`, `WithTLSSetup`,
  `WithTelemetryProps`, `WithTelemetryClient`, `WithAnimation`,
  `WithPluginRegistrar`). Each `Build()` call returns a fresh, fully-wired
  `*cli.CommandAdder` with no shared mutable state.

- `cmd/root_helpers.go`: extracts `showFirstRunAnimation` and
  `setUnknownArgGuards` from the old `root.go` into a focused helper file so
  the factory can call them without causing import cycles.

- `cmd/root.go`: reduced to a thin bootstrap that registers import-cycle-
  breaking function values (`allCommandsOutputFn`, `runVersionCommandFn`),
  builds the production singleton via `NewRootFactory()`, and exposes the
  familiar `RootCmd` package-level var for backward compatibility.

- `cmd/exit.go`: updated to read the telemetry client from
  `productionFactory.TelemetryClient()` rather than a package-level pointer,
  so `Exit()` always flushes the most recently set client.

- `internal/telemetry/interaction.go` + `interaction_test.go`: ports the
  `StampInteractionMode` / `computeNonInteractive` / `hasYesFlag` helpers
  from PR #797 so the factory's `persistentPreRun` can stamp
  `NonInteractive` on every event without per-command duplication.

- `internal/telemetry/properties.go` + `properties_test.go`: adds the
  `NonInteractive bool` field to `CommonProperties` and `non_interactive`
  to `AsMap()`; updates tests to assert the field is always present.

Validation: `go build ./cmd/...`, `go test -race ./cmd/... ./internal/telemetry/...`
all green; `task lint` reports 0 issues across linux, darwin, and windows.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…ndling

Ports PR #797 (aj/track-non-interactive) onto the factory branch,
integrating with the RootFactory plumbing already in place.

What this commit adds on top of #799:

internal/cli/flags.go — YesFlagName constant ("yes") as the single
  canonical source for --yes flag registration across all commands.

internal/cli/runtime.go + runtime_test.go — IsNonInteractive(cmd)
  centralizes the three-source check (force-interactive viper key,
  DATAROBOT_CLI_NON_INTERACTIVE env var, --yes flag) so individual
  commands no longer inline the two-line OR pattern themselves.

internal/telemetry/interaction.go — simplified: StampInteractionMode
  now delegates entirely to cli.IsNonInteractive, removing the local
  yesFlagName / computeNonInteractive / hasYesFlag helpers that #799
  had added.

internal/telemetry/properties.go — seeds NonInteractive from
  reader.IsNonInteractive() in CollectCommonProperties so automation
  workflows are marked even when the dispatched command has no --yes flag.

Command migrations (all replace the two-line yesFlag || viperx.GetBool
pattern with cli.IsNonInteractive):
  cmd/artifact/code/checkout, codesync, init
  cmd/artifact/del
  cmd/dependencies/install (+test)
  cmd/dotenv
  cmd/plugin/install
  cmd/start
  cmd/workload/config, del, up

Docs: telemetry.md, flags.md, AGENTS.md updated to describe
  IsNonInteractive and YesFlagName as the canonical patterns.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Replace the package-level yesFlag variable with proper cmd threading.
confirmPluginDepsInstall now receives the real *cobra.Command and calls
cli.IsNonInteractive(cmd) directly, which checks --yes via cmd.Flags(),
the NON_INTERACTIVE env var, and viperx in priority order.

Previously, passing nil to IsNonInteractive fell back to the weaker
viperx-only path and the package-level yesFlag was shared state that
could leak across successive Execute calls in the same process.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@ajalon1
ajalon1 changed the base branch from main to aj/fix-tests August 20, 2026 17:57
@github-actions github-actions Bot added the go Pull requests that update go code label Aug 20, 2026
@ajalon1

ajalon1 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #810. still getting the hang of github PR stacks

@ajalon1 ajalon1 closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants