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

Separate layers - Application + Project #5293

Merged

Conversation

feloy
Copy link
Contributor

@feloy feloy commented Dec 15, 2021

What type of PR is this?

/kind cleanup

What does this PR do / why we need it:

Which issue(s) this PR fixes:

Part of #5247

PR acceptance criteria:

How to test changes / Special notes to the reviewer:

@netlify
Copy link

netlify bot commented Dec 15, 2021

✔️ Deploy Preview for odo-docusaurus-preview ready!

🔨 Explore the source changes: 05acfba

🔍 Inspect the deploy log: https://app.netlify.com/sites/odo-docusaurus-preview/deploys/61d59d510a683400082b2d97

😎 Browse the preview: https://deploy-preview-5293--odo-docusaurus-preview.netlify.app

@feloy feloy changed the title Refactor/application on main Separate layers - Application Dec 15, 2021
@feloy feloy mentioned this pull request Dec 15, 2021
4 tasks
@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

Kubernetes Tests finished successfully.
View logs: TXT HTML

@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

Unit Tests finished successfully.
View logs: TXT HTML

@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

OpenShift Tests finished successfully.
View logs: TXT HTML

@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

Kubernetes Tests finished successfully.
View logs: TXT HTML

@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

Unit Tests finished successfully.
View logs: TXT HTML

@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

OpenShift Tests finished successfully.
View logs: TXT HTML

@feloy feloy force-pushed the refactor/application-on-main branch from bf7541c to 1061fe5 Compare December 15, 2021 13:45
@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

Unit Tests finished with errors.
View logs: TXT HTML

@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

Kubernetes Tests finished successfully.
View logs: TXT HTML

@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

OpenShift Tests finished successfully.
View logs: TXT HTML

@feloy feloy force-pushed the refactor/application-on-main branch from 1061fe5 to 07d6d2d Compare December 15, 2021 15:09
@feloy feloy changed the title Separate layers - Application Separate layers - Application + Project Dec 15, 2021
@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

Unit Tests finished successfully.
View logs: TXT HTML

@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

OpenShift Tests finished with errors.
View logs: TXT HTML

@feloy
Copy link
Contributor Author

feloy commented Dec 15, 2021

Kubernetes Tests finished with errors.
View logs: TXT HTML

@kadel
Copy link
Member

kadel commented Dec 17, 2021

This is great 👍 I like the approach with Client interfaces

/approve

@openshift-ci
Copy link

openshift-ci bot commented Dec 17, 2021

[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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Dec 17, 2021
This was referenced Dec 20, 2021
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.

I understand that at times I have requested/suggested changes in the piece of code that you have only copied over. I have done that since we are sort of refactoring the bits here. If you think we should handle them separately, we can discuss.

@@ -0,0 +1,111 @@
package application
Copy link
Member

Choose a reason for hiding this comment

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

Why a separate kubernetes.go? Are we going to have a openshift.go at some point? Also, #5247 (comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not particularly, this is to separate the implementation from the definition of the interface, and to make something similar to url and storage.

}

// NewCmdDescribe implements the odo command.
func NewCmdDescribe(name, fullName string) *cobra.Command {
o := NewDescribeOptions()
kubclient, _ := kclient.New()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
kubclient, _ := kclient.New()
// The error is not handled at this point, it will be handled during Context creation
kubclient, _ := kclient.New()

}

// NewCmdList implements the odo command.
func NewCmdList(name, fullName string) *cobra.Command {
o := NewListOptions()
kubclient, _ := kclient.New()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
kubclient, _ := kclient.New()
// The error is not handled at this point, it will be handled during Context creation
kubclient, _ := kclient.New()

pkg/application/kubernetes.go Show resolved Hide resolved
}

// List all applications names in current project by looking at `app` labels in deployments
func (o kubernetesClient) List() ([]string, error) {
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...

Should this function and other List functions in business logic return a struct (AppList in this case) which can be used as-is if the user requested JSON output; and if the user requested human-readable output, the CLI layer could parse things?

I'm thinking this way because:

  1. IIUC, k8s does this by default, in the sense that kubectl gets a big JSON which it parses to print human-readable output.
  2. Our business layer could act as an API provided we don't break 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.

That would an interesting subject for another refactoring

Copy link
Member

Choose a reason for hiding this comment

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

Sure. Let's discuss this alongside the v3 plans.

pkg/project/kubernetes.go Outdated Show resolved Hide resolved
pkg/project/kubernetes.go Outdated Show resolved Hide resolved
pkg/project/kubernetes.go Show resolved Hide resolved
pkg/project/kubernetes.go Outdated Show resolved Hide resolved
pkg/project/kubernetes.go Show resolved Hide resolved
@feloy feloy force-pushed the refactor/application-on-main branch from 07d6d2d to 05acfba Compare January 5, 2022 13:29
@feloy feloy requested a review from dharmit January 5, 2022 13:47
@openshift-ci
Copy link

openshift-ci bot commented Jan 5, 2022

@feloy: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/psi-unit-test-windows 05acfba link false /test psi-unit-test-windows
ci/prow/psi-unit-test-mac 05acfba link false /test psi-unit-test-mac

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/test-infra repository. I understand the commands that are listed here.

@odo-robot
Copy link

odo-robot bot commented Jan 5, 2022

Unit Tests on commit 27b892c finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jan 5, 2022

OpenShift Tests on commit 27b892c finished successfully.
View logs: TXT HTML

@dharmit
Copy link
Member

dharmit commented Jan 5, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jan 5, 2022
@odo-robot
Copy link

odo-robot bot commented Jan 5, 2022

Kubernetes Tests on commit 27b892c finished successfully.
View logs: TXT HTML

@openshift-merge-robot openshift-merge-robot merged commit b20103c into redhat-developer:main Jan 5, 2022
@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 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.

5 participants