Skip to content

ROSAENG-62488 | refactor: Establish target architecure for separating CLI and core/library logic - #3439

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
markirish:ROSAENG-62488-inventory-presentation-calls
Aug 5, 2026
Merged

ROSAENG-62488 | refactor: Establish target architecure for separating CLI and core/library logic#3439
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
markirish:ROSAENG-62488-inventory-presentation-calls

Conversation

@markirish

@markirish markirish commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

PR Summary

Document the target two-layer architecture for ROSA CLI and add tracking files for the incremental migration in guidelines/refactor/.

Detailed Description of the Issue

Expands the Command Layering section of guidelines/ARCHITECTURE.md from a brief three-line guideline into a full architectural specification. The new content defines the target two-layer split (CLI layer in cmd/ and internal/cmd/; Core/Library layer in pkg/ and internal/pkg/), documents directory responsibilities, establishes boundary rules and import direction constraints, and provides a quick-reference table for where common concerns belong. It also describes the current state and sets migration guidelines for new and modified code.

Two new tracking files are added under guidelines/refactor/:

  • layer-violations.md catalogs ~370 existing sites where CLI concerns have leaked into core pkg/ packages
  • pkg-classification.md records the per-package classification (core vs. CLI-classified) and the split work required for each.

These files are co-located with ARCHITECTURE.md and grouped under refactor/ so they're easy to find and easy to remove once the migration is complete.

No code changes — documentation and guidelines only.

Related Issues and PRs

Type of Change

  • feat - adds a new user-facing capability.
  • fix - resolves an incorrect behavior or bug.
  • docs - updates documentation only.
  • style - formatting or naming changes with no logic impact.
  • refactor - code restructuring with no behavior change.
  • test - adds or updates tests only.
  • chore - maintenance work (tooling, housekeeping, non-product code).
  • build - changes build system, packaging, or dependencies for build output.
  • ci - changes CI pipelines, jobs, or automation workflows.
  • perf - improves performance without changing intended behavior.

Developer Verification Checklist

  • Commit subject/title follows [JIRA-TICKET] | [TYPE]: <MESSAGE>.
  • PR description clearly explains both what changed and why.
  • Relevant Jira/GitHub issues and related PRs are linked.
  • make install-hooks has been run in this clone.
  • Tests were added/updated where appropriate.
  • I manually tested the change.
  • make test passes.
  • make lint passes.
  • make rosa passes.
  • Documentation or repo-local agent guidance was added/updated where appropriate.
  • Any risk, limitation, or follow-up work is documented.

Summary by CodeRabbit

  • Documentation
    • Added architecture guidance defining boundaries between command-line presentation and reusable application logic.
    • Documented current layering violations, including CLI dependencies, terminal output, prompts, and process exits.
    • Added package classification and migration guidance for organizing core, private, CLI, and test-only components.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds documentation for separating CLI presentation from reusable core logic. It defines directory responsibilities, ownership rules, boundary requirements, dependency direction, and migration guidance. It classifies pkg/ packages by target layer. It also inventories CLI-specific violations, including framework coupling, terminal output, prompts, global state, and process exits.

Suggested reviewers: jerichokeyne, braetroutman

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the scope and rationale, but it omits required behavior, testing, proof, breaking-change, and risk sections. Add the missing template sections and mark non-applicable items as N/A, including validation steps, expected results, proof, breaking changes, and risks.
✅ Passed checks (14 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the architecture change and follows the required ticket and type format despite a minor spelling error.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The pull request changes only three Markdown guideline files and adds no Ginkgo tests or test titles to assess.
Test Structure And Quality ✅ Passed The diff changes only three Markdown documentation files and adds no Ginkgo tests or cluster operations requiring review under this check.
Microshift Test Compatibility ✅ Passed The pull request changes only three Markdown guideline files; it adds no Ginkgo e2e tests or test code requiring MicroShift compatibility review.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The patch changes only three Markdown guideline files and adds no Ginkgo e2e tests or test code, so SNO compatibility review is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The commit changes only three Markdown guideline files. It adds no deployment manifests, operator code, controllers, or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The PR changes only three Markdown files and no Go or executable code; no OTE/openshift-tests binary integration is present, so it cannot introduce a stdout contract violation.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The patch changes only three Markdown guidance files; it adds no Ginkgo e2e tests or executable network code, so this check is not applicable.
No-Weak-Crypto ✅ Passed The PR changes only three Markdown files; the added lines contain no MD5, SHA-1, DES, RC4, Blowfish, ECB, crypto implementation, or secret-comparison code.
Container-Privileges ✅ Passed The PR changes only three Markdown documentation files. No container or Kubernetes manifests, privilege settings, capabilities, host namespaces, or root-user changes are present.
No-Sensitive-Data-In-Logs ✅ Passed The diff contains only Markdown changes, with no new logging code or sensitive literals; documented log examples use generic errors and placeholders.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
guidelines/ARCHITECTURE.md (1)

243-250: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Update the prohibited Survey import path to /v2.

go.mod declares github.com/AlecAivazis/survey/v2, so this checklist still lets /v2 imports through while the core-layer prohibition targets the base path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@guidelines/ARCHITECTURE.md` around lines 243 - 250, Update the prohibited
Survey dependency entry in the architecture checklist to use the declared
github.com/AlecAivazis/survey/v2 import path, ensuring the core-layer
prohibition matches go.mod and does not allow v2 imports through.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@guidelines/ARCHITECTURE.md`:
- Around line 215-228: Align the architecture terminology across both documents:
in guidelines/ARCHITECTURE.md lines 215-228, either add the permitted
internal/pkg/ → pkg/ dependency edge or remove the corresponding allowance from
the prose; in guidelines/refactor/pkg-classification.md lines 11-15, change the
private-core target from internal/ to the canonical internal/pkg/.

In `@guidelines/refactor/layer-violations.md`:
- Line 3: Correct the truncated word in the introductory paragraph by replacing
“revent” with “prevent”; leave the surrounding text unchanged.

In `@guidelines/refactor/pkg-classification.md`:
- Around line 13-15: Correct the truncated words in the classification tables:
update “egardless” to “regardless” and “oading” to “loading” in the shown rows,
and fix “tilities,” “onsumer,” and “uration” to “utilities,” “consumer,” and
“duration” in the additional affected rows.

---

Nitpick comments:
In `@guidelines/ARCHITECTURE.md`:
- Around line 243-250: Update the prohibited Survey dependency entry in the
architecture checklist to use the declared github.com/AlecAivazis/survey/v2
import path, ensuring the core-layer prohibition matches go.mod and does not
allow v2 imports through.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 2093a330-aad9-4a52-8bd6-452eec6c9766

📥 Commits

Reviewing files that changed from the base of the PR and between 2138c63 and 240b710.

📒 Files selected for processing (3)
  • guidelines/ARCHITECTURE.md
  • guidelines/refactor/layer-violations.md
  • guidelines/refactor/pkg-classification.md

Comment thread guidelines/ARCHITECTURE.md Outdated
Comment thread guidelines/refactor/layer-violations.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/ARCHITECTURE.md Outdated
Comment thread guidelines/ARCHITECTURE.md Outdated
Comment thread guidelines/ARCHITECTURE.md
Comment thread guidelines/ARCHITECTURE.md
Comment thread guidelines/ARCHITECTURE.md
Comment thread guidelines/ARCHITECTURE.md Outdated
Comment thread guidelines/ARCHITECTURE.md Outdated
Comment thread guidelines/ARCHITECTURE.md
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/pkg-classification.md Outdated
Comment thread guidelines/refactor/layer-violations.md Outdated
@amandahla

Copy link
Copy Markdown
Contributor

@markirish I added some suggestions regarding name conflict with common packages because, since we are here refactoring, it might be a good opportunity to rename/move if makes sense.

@markirish
markirish force-pushed the ROSAENG-62488-inventory-presentation-calls branch from 240b710 to 85f55ef Compare July 31, 2026 18:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
guidelines/ARCHITECTURE.md (1)

223-228: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document direct CLI imports of internal/core/.

internal/core/ is described as private implementation supporting pkg/, while the import matrix also allows cmd/ and internal/cli/ to import it directly. If direct CLI use is intended outside migration work, document the exception and its scope; otherwise make the matrix row must not.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@guidelines/ARCHITECTURE.md` around lines 223 - 228, Clarify the import policy
in the architecture matrix for direct imports from internal/core/ by either
documenting the intended cmd/ and internal/cli/ exception and its scope, or
changing those allowed cells to must not if direct CLI use is only transitional.
Keep the existing pkg/core relationship unchanged.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@guidelines/refactor/layer-violations.md`:
- Around line 327-343: Reconcile the aggregate totals in the layer-violations
inventory with the entries in the interactive, Cobra/pflag, and os.Exit tables.
Update the displayed totals to match the actual table counts, or explicitly
document and consistently apply a different counting rule; ensure both affected
summary sections use accurate migration-tracking figures.

In `@guidelines/refactor/pkg-architecture.md`:
- Line 93: Split the roles functionality before classifying it as CLI-only: keep
prompting, reporting, terminal checks, manual command generation, and os.Exit
behavior in internal/cli/roles, while moving reusable role creation, upgrade,
AWS operations, and trust-policy logic from pkg/helper/roles into pkg/ or
internal/core/. Update the split-work row at Line 154 to describe this
separation rather than moving the package unchanged.

---

Nitpick comments:
In `@guidelines/ARCHITECTURE.md`:
- Around line 223-228: Clarify the import policy in the architecture matrix for
direct imports from internal/core/ by either documenting the intended cmd/ and
internal/cli/ exception and its scope, or changing those allowed cells to must
not if direct CLI use is only transitional. Keep the existing pkg/core
relationship unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 19a379e8-626c-49b0-bbdd-54003ac2a2ff

📥 Commits

Reviewing files that changed from the base of the PR and between 240b710 and 85f55ef.

📒 Files selected for processing (3)
  • guidelines/ARCHITECTURE.md
  • guidelines/refactor/layer-violations.md
  • guidelines/refactor/pkg-architecture.md

Comment thread guidelines/refactor/layer-violations.md Outdated
Comment thread guidelines/refactor/pkg-architecture.md Outdated
Comment thread guidelines/refactor/pkg-architecture.md Outdated
@markirish
markirish force-pushed the ROSAENG-62488-inventory-presentation-calls branch from 85f55ef to b73386b Compare July 31, 2026 22:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@guidelines/ARCHITECTURE.md`:
- Around line 168-180: Update the “Current State” section in ARCHITECTURE.md to
replace the inaccurate claim that the internal/ directory does not exist with a
description of its current contents and the ownership it should have in the
target architecture. Adjust any related migration guidance to match that
existing structure, while leaving the other architecture observations unchanged.

In `@guidelines/refactor/pkg-architecture.md`:
- Line 40: Update the architecture entry for pkg/helper/machinepools to classify
it as a split rather than a direct merge: move only reusable label, taint, and
tag parsing into pkg/machinepool, while retaining Cobra parameters, prompts,
reporter output, and os.Exit handling under internal/cli/ in accordance with the
project path rules.
- Around line 36-38: Update the architecture table entries for
pkg/utils/versions and pkg/download to describe parsing, comparison, error
wrapping, or structured error propagation instead of presentation or
human-readable formatting; retain terminal progress rendering under
internal/cli/. Ensure the descriptions reflect that Public Core functions return
structured data and errors rather than formatted strings.
- Line 60: The architecture classification table entry for
internal/core/httputil currently references the unclassified
internal/core/version target. Update that reference to the existing pkg/version
target, or add an explicit internal/core/version classification if that target
is intentional; keep the dependency description accurate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c9547cf-dcab-4838-aad0-f64348f8e1f8

📥 Commits

Reviewing files that changed from the base of the PR and between 85f55ef and b73386b.

📒 Files selected for processing (3)
  • guidelines/ARCHITECTURE.md
  • guidelines/refactor/layer-violations.md
  • guidelines/refactor/pkg-architecture.md

Comment thread guidelines/ARCHITECTURE.md
Comment thread guidelines/refactor/pkg-architecture.md Outdated
Comment thread guidelines/refactor/pkg-architecture.md Outdated
Comment thread guidelines/refactor/pkg-architecture.md Outdated
@markirish
markirish force-pushed the ROSAENG-62488-inventory-presentation-calls branch from b73386b to 7d64286 Compare July 31, 2026 22:44

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
guidelines/refactor/layer-violations.md (1)

429-437: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Reconcile the pkg/aws/helpers.go summary entry.

The highest-impact list says pkg/aws/helpers.go has Cobra usage via pflag, but the Cobra and pflag tables do not list that file. Add the exact call site or remove the parenthetical. Keep the summary traceable to the inventory tables.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@guidelines/refactor/layer-violations.md` around lines 429 - 437, The
pkg/aws/helpers.go entry in the highest-impact summary is inconsistent with the
inventory tables. Update the summary and corresponding Cobra/pflag inventory so
the referenced usage has an exact traceable call site, or remove the “via pflag”
parenthetical if no such usage exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@guidelines/ARCHITECTURE.md`:
- Around line 14-18: Clarify the ownership guidance in the earlier High-Level
Shape section by explicitly labeling its bullets as the current
architecture/state, or revise them to match the target ownership defined here.
Ensure contributors can distinguish existing placement in pkg/ from the intended
CLI placement in cmd/ or internal/cli/ without conflicting rules.

In `@guidelines/refactor/layer-violations.md`:
- Around line 124-145: Update the section heading in the guidelines so it
describes all listed os.Exit usage rather than only direct calls, or separately
label the input_validation.go entry as an indirect exit reference. Keep the
existing direct-call entries and their details unchanged.

In `@guidelines/refactor/pkg-architecture.md`:
- Line 64: Update the `internal/core/policy` architecture classification to
cover only reusable policy attach/detach operations, removing manual-mode
command generation and terminal behavior from Private Core. Place manual-mode
branching and command strings in `cmd/` or `internal/cli/`, while retaining
shared business logic in `pkg/` or `internal/core/`.
- Line 61: Update the architecture table row currently labeled
`internal/core/maputil` to use the correct `internal/core/object`/`pkg/object`
target and remove the obsolete `maputil` naming, while preserving the existing
`object.Object` description.

---

Outside diff comments:
In `@guidelines/refactor/layer-violations.md`:
- Around line 429-437: The pkg/aws/helpers.go entry in the highest-impact
summary is inconsistent with the inventory tables. Update the summary and
corresponding Cobra/pflag inventory so the referenced usage has an exact
traceable call site, or remove the “via pflag” parenthetical if no such usage
exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 61d63353-8663-4a9e-a526-f8bea2920069

📥 Commits

Reviewing files that changed from the base of the PR and between b73386b and 7d64286.

📒 Files selected for processing (3)
  • guidelines/ARCHITECTURE.md
  • guidelines/refactor/layer-violations.md
  • guidelines/refactor/pkg-architecture.md

Comment thread guidelines/ARCHITECTURE.md
Comment thread guidelines/refactor/layer-violations.md Outdated
Comment thread guidelines/refactor/pkg-architecture.md Outdated
Comment thread guidelines/refactor/pkg-architecture.md Outdated
@markirish
markirish force-pushed the ROSAENG-62488-inventory-presentation-calls branch from 7d64286 to 668106c Compare August 3, 2026 14:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@guidelines/ARCHITECTURE.md`:
- Around line 228-251: Revise the Import Direction matrix and accompanying prose
to establish one acyclic dependency direction between pkg/ and internal/core/.
Assign shared types and constants to a single owning package, or introduce a
third shared package that neither layer reversely imports, and update all
permitted-import statements so they consistently enforce that ownership.
- Line 168: Update the os.Exit ownership row in ARCHITECTURE.md to allow both
cmd/ and internal/cli/ for CLI exits, or explicitly limit cmd/ ownership to
final process termination while including internal/cli/ runtime lifecycle exits.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 1563ea53-f8cf-4cac-8392-e29b6fc76114

📥 Commits

Reviewing files that changed from the base of the PR and between 7d64286 and 668106c.

📒 Files selected for processing (3)
  • guidelines/ARCHITECTURE.md
  • guidelines/refactor/layer-violations.md
  • guidelines/refactor/pkg-architecture.md

Comment thread guidelines/ARCHITECTURE.md Outdated
Comment thread guidelines/ARCHITECTURE.md
@markirish
markirish force-pushed the ROSAENG-62488-inventory-presentation-calls branch 2 times, most recently from 27c51c6 to abf0e47 Compare August 3, 2026 16:45
@markirish
markirish requested a review from amandahla August 3, 2026 17:05
Comment thread guidelines/ARCHITECTURE.md
Comment thread guidelines/ARCHITECTURE.md
Comment thread guidelines/ARCHITECTURE.md
@markirish
markirish force-pushed the ROSAENG-62488-inventory-presentation-calls branch from abf0e47 to 436ee23 Compare August 3, 2026 17:27
@amandahla

Copy link
Copy Markdown
Contributor

@markirish thanks for addressing all the comments, looks great. Last one:

I tested the documentation with Claude using a very simple prompt Consider the document guidelines/refactor and explain to me in simple words and with a bullet list how would you refactor the command rosa create oidc-config

This is the output (adding just to illustrate, not related to my comment at the end)

What would change, step by step

  - Extract the business logic out of the strategy execute methods. The CreateUnmanagedOidcConfigAutoStrategy.execute() currently creates S3 buckets, uploads documents, stores secrets, calls OCM, manages spinners, prints output, AND calls os.Exit. The actual AWS + OCM work would
  move into a plain function (e.g., in pkg/ or internal/core/) that accepts resolved values and returns a result struct + error. No spinner, no os.Exit, no output.HasFlag().
  - Move interactive prompts into the cmd/ Run function. Today checkInteractiveModeNeeded and the prompts inside run() (managed? prefix? installer role ARN?) use *cobra.Command, interactive.GetString, interactive.GetOption, and confirm.Prompt. These stay in the CLI layer — but
  instead of being scattered through the business logic, they all happen before calling the core function.
  - Remove os.Exit from business logic. The file has ~20 os.Exit(1) calls sprinkled through strategy methods. In the refactored version, core functions return errors, and the Run function in cmd/ is the only place that calls os.Exit.
  - Remove output.HasFlag() / r.Reporter.IsTerminal() checks from core code. The core function doesn't decide how to display things — it returns a result. The cmd/ layer decides whether to show a spinner, print JSON, or display a human-friendly message.
  - Stop reading the package-level args struct from strategy methods. Today CreateUnmanagedOidcConfigAutoStrategy.executeNoExit() reads args.installerRoleArn (a package-global). The refactored core function would receive the installer role ARN as a parameter.
  - Consolidate the duplicated execute / executeNoExit pairs. CreateManagedOidcConfigAutoStrategy and CreateUnmanagedOidcConfigAutoStrategy each have two methods that do nearly the same thing — one calls os.Exit on error, the other returns errors. After refactoring, there's one core
  function (returns errors) and the CLI layer wraps it with os.Exit when needed.
  - Move manual-mode AWS command-string generation to internal/cli/. The CreateUnmanagedOidcConfigManualStrategy.execute() builds AWS CLI command strings using awscb (the command builder). This is purely a CLI display concern — it generates text for the user to copy-paste. It stays
  in the CLI layer.
  - Move pkg/constants/oidc_config.go flag names to the CLI layer. Constants like InstallerRoleArnFlag and InformOperatorRolesOutput are CLI-specific (flag names and display templates). They'd move to internal/cli/ per the refactor guide. Pure domain constants stay in
  pkg/constants/.
  - Move pkg/interactive/oidc/oidc.go to internal/cli/interactive/oidc/. This package uses interactive.GetOption, *cobra.Command, r.Reporter, and os.Exit — all CLI concerns. It's already classified as CLI Presentation in the refactor guide.
  - Keep pkg/ocm/oidc_config.go where it is. The OCM client methods (CreateOidcConfig, ListOidcConfigs, etc.) are pure API calls that return data and errors. They're already clean core-layer code — no changes needed.

Then I asked for checking how to avoid cyclic imports, that this is my main concern.
Claude found this common scenario between commands: cmd/create/oidcconfig → cmd/create/oidcprovider (horizontal cmd→cmd import)

Lets see what Coderabbit has to say about it:

@coderabbitai review this PR with extra attention to whether the refactoring documentation adequately addresses sibling command imports — the pattern where one cmd/ package imports another cmd/ package and calls SiblingCmd.Cmd.Flags().Set(...) followed by
SiblingCmd.Cmd.Run(...).

This pattern exists in at least 22 places across the codebase. A concrete example: cmd/create/oidcconfig/cmd.go imports cmd/create/oidcprovider and at line 303-314 mutates its flags and invokes oidcprovider.Cmd.Run() directly. The same pattern appears in cmd/create/cluster
(which chains into oidcprovider, operatorroles, admin, idp, and describe/cluster), cmd/register/oidcconfig, cmd/dlt/oidcconfig, cmd/dlt/cluster, cmd/initialize, and others.

Please check:

  1. Does the documentation explain that sibling cmd/ → cmd/ imports are a coupling smell that must be resolved during refactoring?
  2. Does it prescribe the fix: extract the shared operation into a core-layer function (pkg/ or internal/core/) so both commands call the core function instead of one invoking the other through Cobra flag mutation?
  3. Does it mention that extraction order matters — when command A calls command B's Cmd.Run(), B's core logic should be extracted first (or simultaneously), otherwise A's refactored code still depends on B's Cobra wiring?
  4. Does it call out cmd/create/cluster as the largest hub of sibling imports, which affects the sequencing of refactoring work across the repo?

If any of these points are missing or underspecified, flag them as suggestions for the contributor to address.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Documentation structure =='
ast-grep outline guidelines/ARCHITECTURE.md --items all 2>/dev/null || true
ast-grep outline guidelines/refactor/layer-violations.md --items all 2>/dev/null || true
ast-grep outline guidelines/refactor/pkg-architecture.md --items all 2>/dev/null || true

echo '== Documentation references to sibling commands, command imports, Cobra, and extraction order =='
rg -n -i -C 3 \
  'sibling|cmd/.*cmd/|command.*import|import.*command|cobra|Flags\(\)\.Set|Cmd\.Run|extract.*first|sequenc|migration order|cyclic' \
  guidelines/ARCHITECTURE.md guidelines/refactor/layer-violations.md guidelines/refactor/pkg-architecture.md || true

echo '== Concrete oidcconfig -> oidcprovider dependency =='
rg -n -C 5 \
  'oidcprovider|Flags\(\)\.Set|Cmd\.Run\s*\(' \
  cmd/create/oidcconfig/cmd.go || true

echo '== Sibling cmd imports and direct Cobra execution sites =='
rg -n -P -C 2 \
  '"github\.com/openshift/rosa/cmd/[^"]+"' \
  cmd internal/cmd 2>/dev/null || true
rg -n -P -C 3 \
  '\.Cmd\.Flags\(\)\.Set\s*\(|\.Cmd\.Run\s*\(' \
  cmd internal/cmd 2>/dev/null || true

echo '== cmd/create/cluster sibling imports and direct command calls =='
rg -n -C 4 \
  '"github\.com/openshift/rosa/cmd/|\.Cmd\.Flags\(\)\.Set\s*\(|\.Cmd\.Run\s*\(' \
  cmd/create/cluster 2>/dev/null || true

Length of output: 61077


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Changed files in this PR =='
git diff --name-status "$(git merge-base HEAD origin/main)" HEAD 2>/dev/null || \
git diff --name-status HEAD~1 HEAD

echo '== Architecture migration guidance and import-direction rules =='
nl -ba guidelines/ARCHITECTURE.md | sed -n '200,310p'

echo '== Architecture command-layer guidance =='
nl -ba guidelines/ARCHITECTURE.md | sed -n '76,145p'

echo '== Search all refactor documents that exist on this branch =='
fd -t f . guidelines/refactor -x sh -c '
  echo "--- $1"
  rg -n -i -C 2 "sibling|horizontal|cmd.*import|cobra.*run|flags\(\).*set|dependency|sequenc|cycle|create/cluster" "$1" || true
' sh {}

echo '== Direct cross-command calls: source file, import, flag mutation, Run call =='
rg -n -P -C 2 '\.Cmd\.(?:Flags\(\)\.Set|Run)\s*\(' cmd \
  | sed -n '1,500p'

Length of output: 1398


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Architecture migration guidance and import-direction rules =='
awk 'NR >= 200 && NR <= 310 { printf "%d:%s\n", NR, $0 }' guidelines/ARCHITECTURE.md

echo '== Architecture command-layer guidance =='
awk 'NR >= 76 && NR <= 145 { printf "%d:%s\n", NR, $0 }' guidelines/ARCHITECTURE.md

echo '== Existing refactor documents and references to the reported pattern =='
fd -t f . guidelines/refactor -x sh -c '
  echo "--- $1"
  rg -n -i -C 2 "sibling|horizontal|cmd.*import|cobra.*run|flags\(\).*set|dependency|sequenc|cycle|create/cluster" "$1" || true
' sh {}

echo '== Direct command execution and flag mutation sites =='
rg -n -P -C 2 '\.Cmd\.(?:Flags\(\)\.Set|Run)\s*\(' cmd | sed -n '1,500p'

Length of output: 21684


@amandahla I found one documentation gap.

Suggestion — document sibling command execution as a prohibited CLI coupling pattern.

guidelines/ARCHITECTURE.md Lines 253-280 defines the layer direction, but it does not address imports between command packages. The table and the statement at Line 269 that cmd/ “may import from any other layer” can be read as allowing this pattern.

The current code has this coupling:

  • cmd/create/oidcconfig/cmd.go sets oidcprovider.Cmd flags at Line 303 and calls oidcprovider.Cmd.Run(...) at Line 314.
  • cmd/create/cluster/cmd.go calls sibling command Run methods and mutates sibling command flags at Lines 3714-3735.

Please add a rule near the import-direction or migration guidance sections:

  • A command package may import a child command package only for command registration.
  • A command package must not invoke another command package’s Cmd.Run(...), mutate another command’s flags, or use another command’s package-global arguments.
  • When two commands need the same operation, extract the operation into pkg/ or internal/core/. Both commands must call that core-layer operation with resolved values.
  • When command A invokes command B, extract B’s core operation first, or extract both operations in the same change. Otherwise, A remains coupled to B’s Cobra wiring.
  • Treat cmd/create/cluster as a migration hub. It directly chains into describe/cluster, operatorroles, oidcprovider, and logs/install. Its downstream operations need coordinated extraction before cmd/create/cluster can become a thin command.

This rule should distinguish command registration from command execution. Parent command registration is valid. Direct reuse of another command’s Cobra object is the coupling that the refactor must remove.

You are interacting with an AI system.

… CLI and core/library logic

- Create new target repo code structure for separating architectural layers
- Define responsibilities of architectural layers, including where current packages should be moved to
- Define which third-party packages and function calls are forbidden in which layers
- Define dependency allowed and forbidden dependency direction for repo packages
- Inventory current Cobra, pflag, terminal, prompt reporter, and os.Exit boundary violations exist
@markirish
markirish force-pushed the ROSAENG-62488-inventory-presentation-calls branch from 436ee23 to 385071b Compare August 3, 2026 17:56
@markirish
markirish requested a review from amandahla August 3, 2026 19:43
@amandahla

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2026
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amandahla, markirish

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 4, 2026
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@markirish: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/govulncheck 385071b link false /test govulncheck

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@markirish

Copy link
Copy Markdown
Contributor Author

/retest-required

@openshift-merge-bot
openshift-merge-bot Bot merged commit e82fa7d into openshift:master Aug 5, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants