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

refactoring: remove redundant PlatformAdapter interface #3331

Conversation

metacosm
Copy link
Contributor

@metacosm metacosm commented Jun 9, 2020

What type of PR is this?
/kind cleanup

What does does this PR do / why we need it:
Remove seemingly redundant PlatformAdapter interface

Which issue(s) this PR fixes:
Fixes #3333

How to test changes / Special notes to the reviewer:
Behavior shouldn't be impacted.

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. kind/cleanup labels Jun 9, 2020
@openshift-ci-robot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@girishramnani
Copy link
Contributor

@metacosm please open an issue and discuss in the public slack channel before opening PRs if possible 🙂

@metacosm
Copy link
Contributor Author

metacosm commented Jun 9, 2020

I wanted to check the tests actually before proposing this as an actual change, hence the draft status… 😉

@codecov
Copy link

codecov bot commented Jun 9, 2020

Codecov Report

Merging #3331 into master will increase coverage by 0.02%.
The diff coverage is 20.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3331      +/-   ##
==========================================
+ Coverage   45.47%   45.50%   +0.02%     
==========================================
  Files         111      111              
  Lines       10942    10942              
==========================================
+ Hits         4976     4979       +3     
+ Misses       5481     5480       -1     
+ Partials      485      483       -2     
Impacted Files Coverage Δ
pkg/devfile/adapters/helper.go 10.34% <20.00%> (ø)
pkg/sync/sync.go 49.50% <0.00%> (+2.97%) ⬆️

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 77c876b...063d3f1. Read the comment docs.

@kadel
Copy link
Member

kadel commented Jun 9, 2020

I wanted to check the tests actually before proposing this as an actual change, hence the draft status… 😉

Test are not automatically executed on Draft PRs ;-) You need to manually trigger them

/test all

@metacosm metacosm marked this pull request as ready for review June 9, 2020 18:06
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 9, 2020
@metacosm
Copy link
Contributor Author

metacosm commented Jun 9, 2020

/retest

@girishramnani
Copy link
Contributor

I would prefer to use the interface as that enforces a layer of abstraction and someday allows someone to mock it for unit tests

@metacosm
Copy link
Contributor Author

I would prefer to use the interface as that enforces a layer of abstraction and someday allows someone to mock it for unit tests

Can you please explain? There's already such an interface: ComponentAdapter.

@@ -12,8 +12,8 @@ import (
"github.com/openshift/odo/pkg/odo/util/pushtarget"
)

// NewPlatformAdapter returns a Devfile adapter for the targeted platform
func NewPlatformAdapter(componentName string, context string, devObj devfileParser.DevfileObj, platformContext interface{}) (PlatformAdapter, error) {
// NewComponentAdapter returns a Devfile adapter for the targeted platform
Copy link
Contributor

Choose a reason for hiding this comment

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

can we also rename the ComponentAdapter interface to PlatformAdapter?
https://github.com/openshift/odo/blob/7da08b69bab0cc6e172c4e1a39ac570566f26d1d/pkg/devfile/adapters/common/interface.go#L4

IMO as this interface is intended for different platform(docker/k8s), PlatformAdapter sounds better, and component term is already too overloaded in odo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I just kept the most used interface and its name but it's probably indeed better to rename it and maybe move it somewhere where it makes more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, after taking another look at the code, ComponentAdapter is appropriate because its API deals with component and adapts the underlying implementation to the component functionality so I think it's OK to keep ComponentAdapter.

Copy link
Contributor

Choose a reason for hiding this comment

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

but there is a component adapter present here https://github.com/openshift/odo/blob/5f71123d4332e47116b8c8112e76f91ec73f8833/pkg/devfile/adapters/kubernetes/component/adapter.go#L29
its not called componentAdapter but its inside component/adapter.go wouldn't that be confusing?

Copy link
Contributor Author

@metacosm metacosm Jun 16, 2020

Choose a reason for hiding this comment

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

There's also one here… What's your point? I didn't do an indepth refactoring here, just a quick win.

@girishramnani
Copy link
Contributor

/retest

@girishramnani
Copy link
Contributor

/approve
/lgtm
looks good and is a small change - just refactors an interface

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: girishramnani

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 Jul 1, 2020
@girishramnani
Copy link
Contributor

/retest

@openshift-bot
Copy link

/retest

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

@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.

PlatformAdapter interface seems redundant and should be removed
8 participants