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

Beautify lookup after #1505 #1559

Merged
merged 9 commits into from
Jul 14, 2023
Merged

Conversation

mtrmac
Copy link
Contributor

@mtrmac mtrmac commented Jul 12, 2023

This is a set of small cleanups on top of #1505. Apart from the first commit, they should not change behavior, and are not worth backporting.

See individual commit messages for details.

@mtrmac
Copy link
Contributor Author

mtrmac commented Jul 12, 2023

To be rebased after #1505 merges.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mtrmac

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

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Thanks! Nice improvements :)

func filterDigest(value string) (filterFunc, error) {
d, err := digest.Parse(value)
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test for this case?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if we need to add some context to the error. "invalid digest filter: %v"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed both.

This causes an immediate failure on invalid values,
instead of silently not matching anything.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Should not change behavior, both callers now have
a value of that type.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Scary features should have scary names. Also add a comment
to make it less likely that this semantics will spread.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... so that early exits are colocated.

Should not change behavior, reference.TrimNamed() updating
"name" should not change the IsShortName value.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
…poAndTag

Right now that's not simpler, but it will enable simplification of the caller.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
We don't need a reference.NamedTagged now.

That also makes the namedTagged variable in the caller more local.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
@mtrmac mtrmac marked this pull request as ready for review July 13, 2023 20:14
@mtrmac
Copy link
Contributor Author

mtrmac commented Jul 13, 2023

(BTW, @vrothberg , thank you very much for adding all the unit tests, they made it it possible to refactor with a lot of confidence.)

@rhatdan
Copy link
Member

rhatdan commented Jul 14, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jul 14, 2023
@openshift-merge-robot openshift-merge-robot merged commit 062fa1b into containers:main Jul 14, 2023
@mtrmac mtrmac deleted the digests-nits branch July 14, 2023 19:41
@vrothberg
Copy link
Member

(BTW, @vrothberg , thank you very much for adding all the unit tests, they made it it possible to refactor with a lot of confidence.)

Glad they were of use :) I think we owe these tests to your thorough reviews on the other PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants