Skip to content

OCPBUGS-64640: skip unnecessary environment setup for version and lis…#1384

Open
dorzel wants to merge 1 commit intoopenshift:mainfrom
dorzel:OCPBUGS-64640
Open

OCPBUGS-64640: skip unnecessary environment setup for version and lis…#1384
dorzel wants to merge 1 commit intoopenshift:mainfrom
dorzel:OCPBUGS-64640

Conversation

@dorzel
Copy link
Copy Markdown
Member

@dorzel dorzel commented Apr 6, 2026

…t subcommands

Description

Skip unnecessary environment setup (umask check, workspace validation, cache dir resolution) for version, list operators, and list releases subcommands. Keep welcome message, log level configuration, and version output for all subcommands

Github / Jira issue: https://redhat.atlassian.net/browse/OCPBUGS-64640

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code Improvements (Refactoring, Performance, CI upgrades, etc)
  • Internal repo assets (diagrams / docs on github repo)
  • This change requires a documentation update on openshift docs

How Has This Been Tested?

  • ran oc-mirror version --v2
  • ran oc-mirror --v2 list releases
  • ran oc-mirror --v2 list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.21
  • ran a small m2d, d2m

Expected Outcome

Output in question does not exist for version and list subcommands. Continues to exist for all other commands.

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Apr 6, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@dorzel: This pull request references Jira Issue OCPBUGS-64640, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @nidangavali

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

…t subcommands

Description

Skip unnecessary environment setup (umask check, workspace validation, cache dir resolution) for version, list operators, and list releases subcommands. Keep welcome message, log level configuration, and version output for all subcommands

Github / Jira issue: https://redhat.atlassian.net/browse/OCPBUGS-64640

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code Improvements (Refactoring, Performance, CI upgrades, etc)
  • Internal repo assets (diagrams / docs on github repo)
  • This change requires a documentation update on openshift docs

How Has This Been Tested?

  • ran oc-mirror version --v2
  • ran oc-mirror --v2 list releases
  • ran oc-mirror --v2 list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.21
  • ran a small m2d, d2m

Expected Outcome

Output in question does not exist for version and list subcommands. Continues to exist for all other commands.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from nidangavali April 6, 2026 17:33
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 643857c6-48ae-4540-88bd-06071b100d41

📥 Commits

Reviewing files that changed from the base of the PR and between 18c646f and 1d26b5e.

📒 Files selected for processing (1)
  • internal/pkg/cli/executor.go

Walkthrough

The change reorganizes the PersistentPreRunE hook in the mirror command to add early log-level validation with a welcome message, introduce control-flow shortcuts for specific subcommands to skip environment setup, and consolidate redundant logging and validation blocks into the earlier validated section.

Changes

Cohort / File(s) Summary
Command Execution Hook Restructuring
internal/pkg/cli/executor.go
Reorganized PersistentPreRunE to perform log-level validation and emit a welcome message earlier, added conditional returns to skip environment setup for version and list subcommands, repositioned logs after validation, and removed redundant logging/validation blocks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ 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 and usage tips.

@openshift-ci openshift-ci bot requested review from adolfo-ab and aguidirh April 6, 2026 17:33
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 6, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dorzel
Once this PR has been reviewed and has the lgtm label, please assign r4f4 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@dorzel
Copy link
Copy Markdown
Member Author

dorzel commented Apr 6, 2026

/retest

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 6, 2026

@dorzel: all tests passed!

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.

log.Info(emoji.Gear+" environment version: %s", version.Get().GitVersion)

// Skip environment setup for subcommands that don't need it
if cmd.Name() == "version" || (cmd.Parent() != nil && cmd.Parent().Name() == "list") {
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.

I think this condition won't include oc-mirror list --help

@r4f4
Copy link
Copy Markdown
Contributor

r4f4 commented Apr 8, 2026

What is the benefit of doing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants