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

refactor(digests): standardise representation of digests to digest.Digest #898

Merged
merged 1 commit into from
Oct 22, 2022

Conversation

andaaron
Copy link
Contributor

  • Digests were represented by different ways
  • We needed a uniform way to represent the digests and enforce a format
  • also replace usage of github.com/google/go-containerregistry/pkg/v1 with github.com/opencontainers/image-spec/specs-go/v1

Signed-off-by: Laurentiu Niculae niculae.laurentiu1@gmail.com
(cherry picked from commit 96b2f29)
(cherry picked from commit 3d41b58)

What type of PR is this?
refactoring

Which issue does this PR fix:
#869

What does this PR do / Why do we need it:
In some cases it's unclear if the digest strings are supposed to contain just the hex or also the algorithm.
API now returns full digests with the algorithm name, and the cli now removes it for easy of view purpose (in any case if we don't remove it the algorithm name uses half the characters allowed by the digest column width).
Using the go-digest.Digest struct has some additional benefits such as having validation as methods.
Also we were using 2 different structs for manifest used in some places, resulting in incompatibility between these types when we wanted to compare objects, and duplicating methods returning basically the same information in different struct types.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

}

src := is.BlobUploadPath(repo, uuid)

_, err = os.Stat(src)
_, err := os.Stat(src)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).

is.Lock(&lockLatency)
defer is.Unlock(&lockLatency)

_, err = os.Stat(blobPath)
_, err := os.Stat(blobPath)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Merging #898 (7c7d41b) into main (5f99f9a) will decrease coverage by 0.44%.
The diff coverage is 82.60%.

@@            Coverage Diff             @@
##             main     #898      +/-   ##
==========================================
- Coverage   89.17%   88.72%   -0.45%     
==========================================
  Files          72       72              
  Lines       13774    13786      +12     
==========================================
- Hits        12283    12232      -51     
- Misses       1163     1211      +48     
- Partials      328      343      +15     
Impacted Files Coverage Δ
pkg/extensions/search/common/common.go 94.26% <ø> (ø)
pkg/extensions/search/cve/cve.go 100.00% <ø> (ø)
pkg/storage/cache.go 53.58% <55.55%> (-0.52%) ⬇️
pkg/cli/service.go 79.34% <66.66%> (-0.82%) ⬇️
pkg/storage/local/local.go 81.49% <68.42%> (-2.12%) ⬇️
pkg/extensions/lint/lint.go 87.17% <75.00%> (ø)
pkg/storage/s3/s3.go 79.95% <77.08%> (-1.38%) ⬇️
pkg/api/routes.go 96.83% <90.16%> (-0.41%) ⬇️
pkg/extensions/search/schema.resolvers.go 83.77% <91.66%> (+0.25%) ⬆️
pkg/extensions/search/common/oci_layout.go 92.02% <96.15%> (-1.52%) ⬇️
... and 16 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@andaaron andaaron force-pushed the digest branch 4 times, most recently from 50abc99 to 15bbe94 Compare October 21, 2022 21:28
…gest

  - Digests were represented by different ways
  - We needed a uniform way to represent the digests and enforce a format
  - also replace usage of github.com/google/go-containerregistry/pkg/v1
    with github.com/opencontainers/image-spec/specs-go/v1

Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
(cherry picked from commit 96b2f29)
(cherry picked from commit 3d41b58)
Copy link
Contributor

@rchincha rchincha left a comment

Choose a reason for hiding this comment

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

lgtm

@rchincha rchincha merged commit ac6c6a8 into project-zot:main Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants