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

HIVE-2629: Rewrite hack/modchecker.go to be more generic #2490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dlom
Copy link
Contributor

@dlom dlom commented Oct 8, 2024

xref: HIVE-2629

Due to limitations in the generics system implemented by go, a small hack is employed to allow us to work generically with foreign types (logical pieces of the go.mod file). Lots of documentation is written inline

/assign @2uasimojo

Due to limitations in the generics system implemented by go, a small
hack is employed to allow us to work generically with foreign types
(logical pieces of the go.mod file)
Copy link
Contributor

openshift-ci bot commented Oct 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dlom

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. label Oct 8, 2024
@dlom
Copy link
Contributor Author

dlom commented Oct 8, 2024

/retitle HIVE-2629: Rewrite hack/modchecker.go to be more generic

@openshift-ci openshift-ci bot changed the title Rewrite hack/modchecker.go to be more generic HIVE-2629: Rewrite hack/modchecker.go to be more generic Oct 8, 2024
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 8, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 8, 2024

@dlom: This pull request references HIVE-2629 which is a valid jira issue.

In response to this:

Due to limitations in the generics system implemented by go, a small hack is employed to allow us to work generically with foreign types (logical pieces of the go.mod file). Lots of documentation is written inline

/assign @2uasimojo

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 8, 2024

@dlom: This pull request references HIVE-2629 which is a valid jira issue.

In response to this:

xref: HIVE-2629

Due to limitations in the generics system implemented by go, a small hack is employed to allow us to work generically with foreign types (logical pieces of the go.mod file). Lots of documentation is written inline

/assign @2uasimojo

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 openshift-eng/jira-lifecycle-plugin repository.

1 similar comment
@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 8, 2024

@dlom: This pull request references HIVE-2629 which is a valid jira issue.

In response to this:

xref: HIVE-2629

Due to limitations in the generics system implemented by go, a small hack is employed to allow us to work generically with foreign types (logical pieces of the go.mod file). Lots of documentation is written inline

/assign @2uasimojo

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 openshift-eng/jira-lifecycle-plugin repository.

Copy link
Contributor

openshift-ci bot commented Oct 9, 2024

@dlom: all tests passed!

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

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.29%. Comparing base (56d6d64) to head (8b2d0a0).
Report is 4 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2490   +/-   ##
=======================================
  Coverage   46.29%   46.29%           
=======================================
  Files         279      279           
  Lines       32892    32892           
=======================================
  Hits        15226    15226           
  Misses      16388    16388           
  Partials     1278     1278           

@dlom
Copy link
Contributor Author

dlom commented Oct 9, 2024

/cc @jstuever this has changed a lot since I last showed you it, if you're interested in giving it a glance. Eric is still the main reviewer

Copy link
Member

@2uasimojo 2uasimojo left a comment

Choose a reason for hiding this comment

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

This is great, @dlom. It's sad that the language ties our hands in ways that make the resulting code have to have awkward constructs, but you've worked into that admirably.

Before we merge this, I would like to see the commit message and PR summary updated to reflect all the things that have changed. You didn't just rewrite for generics; you also implemented fixers for excludes and replaces.

But on that note: I tried to get the tool to do anything with excludes and couldn't. Do you have a test case for that?

...which leads me to wonder what we would actually expect the behavior to be in that regard. Would we want to make sure that, if any exclude with a matching path is given, all the excludes for that path are identical in both files? That probably doesn't make sense given that the root file's go.sum can (and is even quite likely to) contain more versions of any given lib, and thus be subject to more exclusions of that lib.

We don't necessarily have to answer that question here; but whatever we decide, we should call it out in the code comments and the commit/PR messaging.

MapConflictFmtStr: "WARNING: require path %s listed at multiple versions: %v | %v\n",

CompareNotEqualFmtStr: "XX require %s: root(%v) apis(%v)\n",
FixFn: func(file *modfile.File, toDrop string, toAdd *modfile.Require) error {
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'm finding the var names slightly confusing here. Maybe something like:

Suggested change
FixFn: func(file *modfile.File, toDrop string, toAdd *modfile.Require) error {
FixFn: func(file *modfile.File, pathToReplace string, replacement *modfile.Require) error {

I don't love using replace in these names though, as that has meaning in the context of a modfile. Thoughts?

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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants