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

remove duplicate list and refactor #4177

Merged

Conversation

girishramnani
Copy link
Contributor

@girishramnani girishramnani commented Oct 30, 2020

What type of PR is this?
/kind bug
/kind cleanup

What does does this PR do / why we need it:

  • resolve odo list printing devfile components as s2i components
  • refactor the code to not use Kclient directly in the cli
  • refactor the code to not use Deployment struct ( structs from the lowest ) layer in the cli layer

Which issue(s) this PR fixes:

Fixes #4144

PR acceptance criteria:

How to test changes / Special notes to the reviewer:

@openshift-ci-robot openshift-ci-robot added kind/bug Categorizes issue or PR as related to a bug. kind/cleanup labels Oct 30, 2020
@girishramnani
Copy link
Contributor Author

@dgolovin This might change the odo list -o json output, please confirm.

@girishramnani girishramnani changed the title remove duplicate list and major refactor remove duplicate list and refactor Oct 30, 2020
@kadel
Copy link
Member

kadel commented Nov 2, 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 Nov 2, 2020
@prietyc123
Copy link
Contributor

@girishramnani unit test TestList for List function are failing due to component field mismatch. Could you please fix those.

@girishramnani
Copy link
Contributor Author

unit test should be resolved now

@codecov
Copy link

codecov bot commented Nov 5, 2020

Codecov Report

Merging #4177 (06171fa) into master (0dea26a) will decrease coverage by 0.21%.
The diff coverage is 64.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4177      +/-   ##
==========================================
- Coverage   42.56%   42.35%   -0.22%     
==========================================
  Files         156      154       -2     
  Lines       13266    13197      -69     
==========================================
- Hits         5647     5589      -58     
+ Misses       7017     6999      -18     
- Partials      602      609       +7     
Impacted Files Coverage Δ
pkg/component/pushed_component.go 57.69% <ø> (ø)
pkg/odo/util/completion/completionhandlers.go 35.20% <ø> (ø)
pkg/url/url.go 73.41% <ø> (-0.23%) ⬇️
pkg/component/component.go 23.33% <64.51%> (+0.88%) ⬆️
pkg/kclient/volumes.go 89.36% <0.00%> (-8.32%) ⬇️
...g/devfile/adapters/kubernetes/component/adapter.go 31.11% <0.00%> (-6.43%) ⬇️
pkg/devfile/adapters/kubernetes/utils/utils.go 80.66% <0.00%> (-0.36%) ⬇️
pkg/catalog/catalog.go 50.55% <0.00%> (ø)
pkg/kclient/supervisord.go 0.00% <0.00%> (ø)
pkg/testingutil/devfile.go 0.00% <0.00%> (ø)
... and 18 more

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 809462a...7d9143a. Read the comment docs.

@@ -856,8 +856,33 @@ func GetComponentNames(client *occlient.Client, applicationName string) ([]strin
return names, nil
}

// List lists components in active application
func List(client *occlient.Client, applicationName string, localConfigInfo *config.LocalConfigInfo) (ComponentList, error) {
func ListDevfileComponents(client *occlient.Client, selector string) (ComponentList, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Please add comments.

Copy link
Member

@kadel kadel Nov 11, 2020

Choose a reason for hiding this comment

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

+1 especially description for selector.
It looks a little bit weird to me as we don't use selectors for odo components. Why not keep applicationName are we ever going to use something else then application name selector?
ListS2IComponents has applicationName argument, it would be nice to match that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes @kadel - we use the project selector when we want to have components from all application, but in case of s2i components - we list all applications and then list per component application
https://github.com/openshift/odo/blob/e5798c42c9ce191425e3ed18e52db985e1e2f920/pkg%2Fodo%2Fcli%2Fcomponent%2Flist.go#L254-L261

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now the S2I approach is not optimised as it Xn calls to the where n is the number of applications and X is the calls done per application.

components = append(components, component)
}

compoList := GetMachineReadableFormatForList(components)
Copy link
Member

Choose a reason for hiding this comment

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

+1 for returning the machine readable output here.

// List lists all components in active application
func List(client *occlient.Client, applicationName string, localConfigInfo *config.LocalConfigInfo) (ComponentList, error) {
var applicationSelector string
if applicationName != "" {
Copy link
Member

Choose a reason for hiding this comment

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

If the applicationName field will be "" or nil for some reason, what would happen to the calls to ListDevfileComponents and ListS2Icomponents below?

Is there going to be a situation where this field could be empty? Isn't that something that CLI level should prevent from happening?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not exactly sure if CLI prevents it but as List actually checks the local component as well - chances are that doesn't require application name

pkg/component/component.go Show resolved Hide resolved
pkg/odo/cli/component/list.go Outdated Show resolved Hide resolved
Type string `json:"type,omitempty"`
SourceType string `json:"sourceType,omitempty"`
S2IComponents []Component `json:"s2iComponents"`
DevfileComponents []Component `json:"devfileComponents"`
Copy link
Member

Choose a reason for hiding this comment

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

Thinking out loud. Can we have Items and make S2IComponents & DevfileComponents a part of it? I'm asking this because it'll help us have uniformity with the way k8s returns a list of items. This should also cascade to the way we return list of services, AFAIK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am thinking as part of refactor we might consolidate these two list with a new label called IsLegacy once devfile matures further.

Copy link
Member

Choose a reason for hiding this comment

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

So you mean that we can have just one list called Items and then in the individual items, there could be a bool label IsLegacy which indicates that it's an s2i component, right? Sounds good to me. Or we could label it IsS2i. But that's a separate discussion for when we refactor it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah

pkg/component/component.go Outdated Show resolved Hide resolved
pkg/component/component.go Outdated Show resolved Hide resolved
@dharmit
Copy link
Member

dharmit commented Nov 12, 2020

@girishramnani will this PR also fix #4023? Not asking that it should, just wondering if it would.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Nov 15, 2020
@girishramnani
Copy link
Contributor Author

@girishramnani will this PR also fix #4023? Not asking that it should, just wondering if it would.

actually that one has a bigger problem which we might not be able to solve right now

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Nov 19, 2020
@dharmit
Copy link
Member

dharmit commented Nov 19, 2020

@girishramnani Multiple test cases failing in unit test

Copy link
Member

@dharmit dharmit left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Nov 25, 2020
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 82c0570 into redhat-developer:master Nov 25, 2020
@rm3l rm3l added the area/refactoring Issues or PRs related to code refactoring label Jun 16, 2023
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. area/refactoring Issues or PRs related to code refactoring 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.

odo list showing a duplicate entry of devfile component
8 participants