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

update HasUniqueTag logic to fall back to the value the user provided #759

Merged
merged 1 commit into from
Aug 15, 2022
Merged

update HasUniqueTag logic to fall back to the value the user provided #759

merged 1 commit into from
Aug 15, 2022

Conversation

acornett21
Copy link
Contributor

Updating the HashUniqueTag logic to follow the below rules:

  1. if sha is given on cli, you MUST have a reachable /tags/list
  2. If tag given on cli is "latest", you MUST have a reachable /tags/list.
  3. If tag given on cli is not "latest", and is not a sha, use value user passed in.

The order above is so that the failover logic can be preserved for partners where we call the partners registry, and /tags/list is available but they also return tags as an empty list.

Signed-off-by: Adam D. Cornett adc@redhat.com

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 10, 2022
@acornett21
Copy link
Contributor Author

There might be a better way to throw errors in the tests, so if there is please let me know! Thanks!

@coveralls
Copy link

coveralls commented Aug 10, 2022

Coverage Status

coverage: 83.651% (-0.6%) from 84.283%
when pulling 00129b8 on acornett21:list_tag_bug_fix
into ee9cf5b on redhat-openshift-ecosystem:main.

Copy link
Contributor

@bcrochet bcrochet left a comment

Choose a reason for hiding this comment

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

Couple of changes, and please fix the DeferCleanup on L109 to be consistent.

if strings.HasPrefix(imgRef.ImageTagOrSha, "sha256:") {
tags, err = p.getDataToValidate(ctx, imgRepo)
if err != nil {
return false, fmt.Errorf("failed to get tags list for %s when sha256 provided: %v", imgRepo, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the only difference between these is just the log message. I don't think that necessarily adds any value. This can be reduced to a single if this || that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Along this line, to improve readability, I'd say that these two cases should be methods or functions. Then it literally becomes if this || that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been simplified, into one if statement.

@komish
Copy link
Contributor

komish commented Aug 11, 2022

Barring what Brad already said (I'm in agreement), this LGTM.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 11, 2022
…, if they do not provide a sha, or a latest tag

Signed-off-by: Adam D. Cornett <adc@redhat.com>
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 15, 2022
Copy link
Contributor

@komish komish left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 15, 2022
Copy link
Contributor

@bcrochet bcrochet left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link

openshift-ci bot commented Aug 15, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: acornett21, bcrochet, komish

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:
  • OWNERS [acornett21,bcrochet,komish]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@bcrochet bcrochet merged commit a33ea50 into redhat-openshift-ecosystem:main Aug 15, 2022
@acornett21 acornett21 deleted the list_tag_bug_fix branch January 2, 2024 20:11
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HasUniqueTag Does Not Fall Back to Tag User Provided
5 participants