Skip to content

Conversation

@mareklibra
Copy link
Contributor

@mareklibra mareklibra commented Sep 23, 2019

Will be reused by cluster dashboard.

Depends on:

Just the last commit is relevant.

@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. component/kubevirt Related to kubevirt-plugin component/shared Related to console-shared size/L Denotes a PR that changes 100-499 lines, ignoring generated files. component/core Related to console core functionality and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 23, 2019
@mareklibra mareklibra changed the title Move pod's getNodeName() selector to @console/shared console-shared: Move pod's getNodeName() selector Sep 23, 2019
@spadgett
Copy link
Member

/hold

These selectors are an anti-pattern imo. We should be trying to remove them instead of adding more.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 25, 2019
@spadgett spadgett changed the base branch from master-4.3 to master September 26, 2019 14:35
@spadgett
Copy link
Member

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 26, 2019
@mareklibra
Copy link
Contributor Author

mareklibra commented Sep 27, 2019

These selectors are an anti-pattern imo. We should be trying to remove them instead of adding more.

@spadgett , Can you please explain? I see following benefits when used:

  • shared "parsing" logic for input
  • better maintenance as the "logic coded as a string" is at one place only
  • better use of typescript
  • better descriptive (by function name)
  • possibility to track its use using IDE
  • single place to be changed if API changes (ideally)

@mareklibra
Copy link
Contributor Author

Sorry, I missed your comment in #2808

@spadgett
Copy link
Member

  • shared "parsing" logic for input

This isn't parsing anything. It's returning a straight property value.

  • better maintenance as the "logic coded as a string" is at one place only

We shouldn't be doing "logic coded as a string" at all. That's my point :)

  • better use of typescript

_.get is not type safe.

  • better descriptive (by function name)

IMO, it actually obscures what's really happening for someone who knows the API. You don't know if there's extra logic in the helper or what field it's really returning. It's an unnecessary level of indirection.

  • possibility to track its use using IDE

Shouldn't this still be possible checking references to a property in a type definition? In fact, I think this makes it harder to know where things are being used.

  • single place to be changed if API changes (ideally)

These APIs are stable. I see more of an argument for these helpers for alpha APIs, but that's not how we've been using these.

@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 30, 2019
@mareklibra
Copy link
Contributor Author

shared "parsing" logic for input

This isn't parsing anything. It's returning a straight property value.

Right, that's the reason for the quotes. But as there is no validation when parsing (or following the parser), the selectors can be the place to safely and once deal with unexpected input.

better maintenance as the "logic coded as a string" is at one place only

We shouldn't be doing "logic coded as a string" at all. That's my point :)

I agree. I have changed this PR to avoid _.get(). I still think the selectors can simplify the code for deeper paths.

@mareklibra
Copy link
Contributor Author

Rebased.
@spadgett , can you please have a look again?

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2019
@spadgett spadgett added this to the v4.3 milestone Oct 1, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mareklibra, spadgett

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

The pull request process is described here

Details 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. label Oct 1, 2019
@openshift-merge-robot openshift-merge-robot merged commit 8b62d7c into openshift:master Oct 1, 2019
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. component/core Related to console core functionality component/kubevirt Related to kubevirt-plugin component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants