-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Prevent oc rollout
panic when resource given is not a dc
#16438
Prevent oc rollout
panic when resource given is not a dc
#16438
Conversation
5faee15
to
279ef22
Compare
pkg/oc/cli/cmd/rollout/cancel.go
Outdated
@@ -112,6 +112,7 @@ func (o CancelOptions) Run() error { | |||
config, ok := info.Object.(*deployapi.DeploymentConfig) | |||
if !ok { | |||
allErrs = append(allErrs, kcmdutil.AddSourceToErr("cancelling", info.Source, fmt.Errorf("expected deployment configuration, got %T", info.Object))) |
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.
can you use kapi.Scheme.ObjectKind(info.Object).Kind ? seems nicer than raw go type
11e5260
to
0f75016
Compare
@mfojtik thanks, comment addressed. Left raw go type as fallback |
0f75016
to
3260b5a
Compare
/retest |
/unassign |
@mfojtik friendly ping |
pkg/oc/cli/cmd/rollout/cancel.go
Outdated
@@ -111,7 +111,12 @@ func (o CancelOptions) Run() error { | |||
for _, info := range o.Infos { | |||
config, ok := info.Object.(*deployapi.DeploymentConfig) | |||
if !ok { | |||
allErrs = append(allErrs, kcmdutil.AddSourceToErr("cancelling", info.Source, fmt.Errorf("expected deployment configuration, got %T", info.Object))) | |||
kind, _, err := kapi.Scheme.ObjectKind(info.Object) |
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.
the info.Resource
(i think) carries the resource name name, I would use that instead of getting the kind... it will also show nicer in CLI (not capitalized). WDYT?
test/cmd/deployments.sh
Outdated
# create a replication controller and attempt to perform `oc rollout cancel` on it. | ||
# expect an error about the resource type, rather than a panic or a success. | ||
os::cmd::expect_success 'oc create -f test/integration/testdata/test-replication-controller.yaml' | ||
os::cmd::expect_failure_and_text 'oc rollout cancel rc/test-replication-controller' 'expected deployment configuration, got ReplicationController' |
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.
This will change to "expected deployment configuration, got replicationcontroller" :)
3260b5a
to
0c17437
Compare
@mfojtik thanks for the feedback, review comments addressed |
allright, squash the commits, this looks good to me. |
0c17437
to
d863f04
Compare
@mfojtik sorry about the delay. Commits squashed |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: juanvallejo, mfojtik The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue (batch tested with PRs 16861, 16438). |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1493071
Prevents nil pointer dereference by skipping command logic
when given resource is not of type *deployapi.DeploymentConfig.
Before
After
cc @openshift/cli-review