Skip to content
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

Don't panic when an invalid component name is passed in #2839

Merged

Conversation

johnmcollier
Copy link
Member

What type of PR is this?

Uncomment only one /kind line, and delete the rest.
For example, > /kind bug would simply become: /kind bug

/kind bug

What does does this PR do / why we need it:
This PR fixes the issue seen in #2826 when odo would panic if experimental mode was enabled and an invalid component name was passed into odo create.

The issue was caused by a partially initialized CLI context being created when experimental mode is true, which caused fields needed for odo-s2i like LocalConfigInfo to be nil in the CLI context. When an invalid/non-existent devfile component name is passed in, odo would fall back to trying to create an s2i-style component. But since the CLI context wasn't properly initialized, a null pointer exception would occur and odo would panic.

Which issue(s) this PR fixes:

Fixes #2826

How to test changes / Special notes to the reviewer:

  1. Build my branch
  2. Run odo create fake-component, you should see something like this:
Johns-MacBook-Pro-3:odo johncollier$ ./odo create fake-component
 ✗  Checking if the specified component type is supported devfile component type [352140ns]

Please run 'odo catalog list components' for a list of supported devfile component types
 ✗  imagestreams.image.openshift.io "fake-component" not found
  1. Run make test-cmd-devfile-create to verify the updated functional tests that capture this scenario

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 7, 2020
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
@codecov
Copy link

codecov bot commented Apr 8, 2020

Codecov Report

Merging #2839 into master will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2839      +/-   ##
==========================================
+ Coverage   43.64%   43.67%   +0.03%     
==========================================
  Files          94       95       +1     
  Lines        8743     8762      +19     
==========================================
+ Hits         3816     3827      +11     
- Misses       4563     4571       +8     
  Partials      364      364              
Impacted Files Coverage Δ
pkg/testingutil/survey_ui.go 0.00% <0.00%> (ø)
pkg/testingutil/deployments.go 0.00% <0.00%> (ø)
...g/devfile/adapters/kubernetes/component/adapter.go 27.88% <0.00%> (+0.93%) ⬆️
pkg/kclient/deployments.go 40.24% <0.00%> (+5.57%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5d8e75...6f6ba33. Read the comment docs.

Copy link
Contributor

@mik-dass mik-dass left a comment

Choose a reason for hiding this comment

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

works for me locally and CI is green
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Apr 8, 2020
@kadel
Copy link
Member

kadel commented Apr 8, 2020

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kadel

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

The pull request process is described here

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-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Apr 8, 2020
@openshift-merge-robot openshift-merge-robot merged commit fffec54 into redhat-developer:master Apr 8, 2020
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. Required by Prow. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic if invalid component name is entered during odo create
5 participants