-
Notifications
You must be signed in to change notification settings - Fork 416
WIP: OCPBUGS-62875: Pass dry-run option to all create API calls #2117
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
base: main
Are you sure you want to change the base?
Conversation
@liouk: This pull request references Jira Issue OCPBUGS-62875, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
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. |
WalkthroughThis PR systematically replaces hardcoded empty Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes The review scope is broad (12 files affected), but the changes are highly homogeneous—the same refactoring pattern is applied consistently across multiple files. The new logic is straightforward (simple conditional assignment). The mechanical nature of replacing static options with dynamic method calls and the low behavioral impact keep complexity minimal. The main verification task is confirming consistency of the implementation across all callsites. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: liouk The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/cli/create/route.go (1)
126-133
: Consider consolidating duplicate toCreateOptions() implementations.This method duplicates the logic from
CreateSubcommandOptions.toCreateOptions()
increate.go
(lines 68-75). Both helpers have identical implementations.Consider one of these approaches:
Option 1: Make
CreateRouteSubcommandOptions
embed or referenceCreateSubcommandOptions
:type CreateRouteSubcommandOptions struct { + CreateSubcommandOptions *CreateSubcommandOptions // PrintFlags holds options necessary for obtaining a printer PrintFlags *genericclioptions.PrintFlags
Then delegate to the shared helper:
func (o *CreateRouteSubcommandOptions) toCreateOptions() metav1.CreateOptions { - createOptions := metav1.CreateOptions{} - if o.DryRunStrategy == cmdutil.DryRunServer { - createOptions.DryRun = []string{metav1.DryRunAll} - } - - return createOptions + return o.CreateSubcommandOptions.toCreateOptions() }Option 2: Extract a standalone helper function that both can call:
func buildCreateOptions(dryRunStrategy cmdutil.DryRunStrategy) metav1.CreateOptions { createOptions := metav1.CreateOptions{} if dryRunStrategy == cmdutil.DryRunServer { createOptions.DryRun = []string{metav1.DryRunAll} } return createOptions }This reduces maintenance burden if the dry-run logic needs updating.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base
setting
📒 Files selected for processing (13)
pkg/cli/create/build.go
(1 hunks)pkg/cli/create/clusterquota.go
(1 hunks)pkg/cli/create/create.go
(2 hunks)pkg/cli/create/deploymentconfig.go
(1 hunks)pkg/cli/create/identity.go
(1 hunks)pkg/cli/create/imagestream.go
(1 hunks)pkg/cli/create/imagestreamtag.go
(1 hunks)pkg/cli/create/route.go
(2 hunks)pkg/cli/create/routeedge.go
(1 hunks)pkg/cli/create/routepassthrough.go
(1 hunks)pkg/cli/create/routereenecrypt.go
(1 hunks)pkg/cli/create/user.go
(1 hunks)pkg/cli/create/user_identity_mapping.go
(1 hunks)
🔇 Additional comments (13)
pkg/cli/create/routeedge.go (1)
139-139
: LGTM! Consistent application of the new options builder pattern.The change correctly replaces the static
metav1.CreateOptions{}
with a dynamic call too.CreateRouteSubcommandOptions.toCreateOptions()
, aligning with the PR objective to pass dry-run options to the server. The existingDryRunClient
check on line 138 is preserved, ensuring correct flow control.pkg/cli/create/deploymentconfig.go (1)
114-114
: LGTM! Correctly applies the dynamic options pattern.The change appropriately replaces the literal
metav1.CreateOptions{}
witho.CreateSubcommandOptions.toCreateOptions()
, enabling server-side dry-run behavior. The dry-run strategy check on line 112 remains intact, maintaining the expected control flow.pkg/cli/create/imagestreamtag.go (1)
184-184
: LGTM! Pattern applied correctly.The replacement of
metav1.CreateOptions{}
witho.CreateSubcommandOptions.toCreateOptions()
is consistent with the PR's objective to properly forward dry-run options to the API server. The existing dry-run handling on line 183 is preserved.pkg/cli/create/identity.go (1)
115-115
: LGTM! Change aligns with the PR objective.The update correctly replaces the hardcoded
metav1.CreateOptions{}
witho.CreateSubcommandOptions.toCreateOptions()
, ensuring that dry-run options are properly communicated to the server. The dry-run strategy check on line 113 remains unchanged.pkg/cli/create/clusterquota.go (1)
140-140
: LGTM! Consistent with the broader refactoring.The change from
metav1.CreateOptions{}
too.CreateSubcommandOptions.toCreateOptions()
properly implements the pattern for forwarding dry-run options to the API server. The control flow with the dry-run check on line 138 is maintained.pkg/cli/create/imagestream.go (1)
102-102
: LGTM! Properly implements the options builder pattern.The substitution of
metav1.CreateOptions{}
witho.CreateSubcommandOptions.toCreateOptions()
correctly enables dynamic configuration of create options, particularly for dry-run behavior. The dry-run strategy check on line 100 is preserved.pkg/cli/create/routepassthrough.go (1)
105-105
: LGTM! Change is consistent with the refactoring pattern.The replacement of
metav1.CreateOptions{}
witho.CreateRouteSubcommandOptions.toCreateOptions()
follows the established pattern across the PR, ensuring dry-run options are passed to the API server. The dry-run check on line 104 remains intact.pkg/cli/create/routereenecrypt.go (2)
154-154
: LGTM! Pattern correctly applied.The change from
metav1.CreateOptions{}
too.CreateRouteSubcommandOptions.toCreateOptions()
aligns with the PR's goal of forwarding dry-run options to the server. The dry-run strategy check on line 153 is preserved.
1-161
: Implementation verified; add tests for dry-run forwarding.All
toCreateOptions()
implementations are correctly in place:
CreateSubcommandOptions.toCreateOptions()
atpkg/cli/create/create.go:68
CreateRouteSubcommandOptions.toCreateOptions()
atpkg/cli/create/route.go:126
Both properly set
DryRun: []string{metav1.DryRunAll}
whenDryRunStrategy == cmdutil.DryRunServer
. All 11 create subcommands (routereenecrypt, routepassthrough, routeedge, user, user_identity_mapping, imagestreamtag, identity, deploymentconfig, clusterquota, build, imagestream) have been updated to usetoCreateOptions()
in their API calls.However, no test files exist in
pkg/cli/create/
to verify dry-run options are properly forwarded to the API server. Add tests to validate this behavior.pkg/cli/create/user.go (1)
110-110
: LGTM!The Create call now correctly uses dynamic CreateOptions from
toCreateOptions()
, enabling server-side dry-run when--dry-run=server
is specified.pkg/cli/create/create.go (1)
68-75
: LGTM!The helper correctly builds
CreateOptions
withDryRun
set tometav1.DryRunAll
whenDryRunStrategy
isDryRunServer
, enabling server-side dry-run validation without creating resources.pkg/cli/create/build.go (1)
222-222
: LGTM!The Create call now uses dynamic CreateOptions, consistent with the PR objectives to pass
--dry-run
to the server.pkg/cli/create/user_identity_mapping.go (1)
134-134
: LGTM!The Create call correctly uses dynamic CreateOptions from the helper method.
Overall idea sounds good to me. Nice catch! |
@liouk: The following test failed, say
Full PR test history. Your PR dashboard. 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. |
The
create
subcommands ofoc
do not pass along the--dry-run
option when used on the command-line. Therefore, the server-side dry run is ignored, and the resources get created.The fix provided in openshift/openshift-apiserver#511 was necessary for image streams, but we also need wiring on the
oc
side.