1
0
mirror of https://github.com/opencontainers/go-digest.git synced 2025-04-18 03:24:02 +03:00

191 Commits

Author SHA1 Message Date
Derek McGowan
1e56c6daea
Merge pull request #107 from thaJeztah/fix_status_badge
README: update badges
2025-01-15 21:16:48 -07:00
Sebastiaan van Stijn
ba6a02b21d
README: update badges
- fix CI badge, which was still pointing to travis
- update GoDoc badge for pkg.go.dev
- add License badge

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 01:43:40 +01:00
Akihiro Suda
8f8f897fe8
Merge pull request #97 from thaJeztah/remove_SHA384_default
do not register sha384 by default
2025-01-16 09:00:47 +09:00
Sebastiaan van Stijn
528a66390c
do not register sha384 by default
The SHA-384 algorithm is not documented in the OCI image-spec ([1], [2]), and
is not encouraged to be used. Commit 084376bb543d4ce80b030a77a6f51f3b3fd861dc
registered all algorithms by default, but also included SHA-384.

This patch disables SHA-384 by default, to discourage its use.

[1]: https://github.com/opencontainers/image-spec/blob/v1.0.2/descriptor.md#digests
[2]: https://github.com/opencontainers/image-spec/blob/v1.0.2/descriptor.md#registered-algorithms

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 00:55:11 +01:00
Derek McGowan
8ab41e4146
Merge pull request #103 from thaJeztah/perf_and_shadow_nits
address some linting issues, and small refactor, performance optimizations
2025-01-15 13:04:01 -07:00
Sebastiaan van Stijn
247c259e4d
remove unneeded fmt.Sprintf and indirections
Remove fmt.Sprintf and use string-concatenation instead to reduce
some allocations.

Before / After:

    BenchmarkNewDigestFromEncoded-10     8474174   128.4 ns/op   112 B/op  3 allocs/op
    BenchmarkNewDigestFromEncoded-10    37912695    31.55 ns/op   80 B/op  1 allocs/op

    BenchmarkNewDigestFromBytes-10       5087299    237.2 ns/op	 200 B/op  5 allocs/op
    BenchmarkNewDigestFromBytes-10       8416543    146.8 ns/op	 168 B/op  3 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:13:34 +02:00
Sebastiaan van Stijn
e3a8687c79
digestset: report allocations in benchmarks
Just for convenience ':-)

Before:

    pkg: github.com/opencontainers/go-digest/digestset
    BenchmarkAdd10-10              183613      6368 ns/op
    BenchmarkAdd100-10              15739     75741 ns/op
    BenchmarkAdd1000-10              1430    831884 ns/op
    BenchmarkRemove10-10           169999      6984 ns/op
    BenchmarkRemove100-10           15312     78299 ns/op
    BenchmarkRemove1000-10           1470    815144 ns/op
    BenchmarkLookup10-10         27067897        43.69 ns/op
    BenchmarkLookup100-10        17203653        69.17 ns/op
    BenchmarkLookup1000-10       13043708        96.32 ns/op
    BenchmarkShortCode10-10       3574094       334.5 ns/op
    BenchmarkShortCode100-10       320438      3782 ns/op
    BenchmarkShortCode1000-10       29110     41460 ns/op

After:

    pkg: github.com/opencontainers/go-digest/digestset
    BenchmarkAdd10
    BenchmarkAdd10-10              176776      6400 ns/op         608 B/op      12 allocs/op
    BenchmarkAdd100-10              15267     76016 ns/op        5746 B/op     102 allocs/op
    BenchmarkAdd1000-10              1426    833977 ns/op       56267 B/op    1002 allocs/op
    BenchmarkRemove10-10           169448      7043 ns/op         128 B/op       2 allocs/op
    BenchmarkRemove100-10           15249     78730 ns/op         944 B/op       2 allocs/op
    BenchmarkRemove1000-10           1444    819247 ns/op        8240 B/op       2 allocs/op
    BenchmarkLookup10-10         27042379        45.68 ns/op        0 B/op       0 allocs/op
    BenchmarkLookup100-10        17098725        69.72 ns/op        0 B/op       0 allocs/op
    BenchmarkLookup1000-10       12769602        92.97 ns/op        0 B/op       0 allocs/op
    BenchmarkShortCode10-10       3551202       332.1 ns/op	      630 B/op       2 allocs/op
    BenchmarkShortCode100-10       313929      3805 ns/op        5449 B/op       4 allocs/op
    BenchmarkShortCode1000-10       28963     41373 ns/op       81992 B/op       3 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:13:34 +02:00
Sebastiaan van Stijn
5d624a8c56
use errors.New() for errors that don't need formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:13:34 +02:00
Sebastiaan van Stijn
38caa322a4
RegisterAlgorithm: skip regex if not needed
No need to validate the format if we previously accepted it to be
registered.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:13:34 +02:00
Sebastiaan van Stijn
3d866abde6
remove import aliases
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:13:29 +02:00
Sebastiaan van Stijn
f5b4cdae29
testdigest: fix package GoDoc to be in the right format
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 13:23:25 +02:00
Sebastiaan van Stijn
a1f6e2eda3
address some linting issues
- rename "digester" vars that shadowed package-level digester type
- rename "hexdigestbytes" to be properly camelCase
- use "errors.Is()" instead of straight comparing errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 13:22:02 +02:00
Vincent Batts
22b78e4785
Merge pull request #99 from thaJeztah/go1.22
gha: add go1.22
2024-04-26 14:24:13 -04:00
Sebastiaan van Stijn
55a6c6bc03
gha: add go1.22
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-04-24 10:45:59 +02:00
Stephen Day
5dbcdd3702
Merge pull request #98 from thaJeztah/regroup_algorithms_and_docs
unify algorithms in a single list, and improve documentation
2024-04-22 14:16:34 -07:00
Stephen Day
3fdbb5d349
Merge pull request #93 from thaJeztah/blake3_fix_package_godoc
blake3: fix copyright header being used as GoDoc
2024-04-22 14:14:24 -07:00
Sebastiaan van Stijn
8e0b8045c6
unify algorithms in a single list, and improve documentation
Since b9e02e015be61903bbee58e3fd349114fa28e0b4, definition of algorithms was
distributed across two files, causing them to be documented in two separate
groups.

This patch:

- re-unifies all algorithms.
- improves documentation.
- adds doc-links to relevant specifications / reference material.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-30 11:59:42 +01:00
Akihiro Suda
429d0316a3
Merge pull request #96 from opencontainers/dependabot/github_actions/actions/setup-go-5
Bump actions/setup-go from 4 to 5
2023-12-12 15:45:14 +09:00
dependabot[bot]
bd00fc3b5b
Bump actions/setup-go from 4 to 5
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-11 16:31:51 +00:00
Akihiro Suda
d50d2fec9c
Merge pull request #95 from vbatts/go_modules
blake3: update go mod deps
2023-10-25 11:37:18 +09:00
Vincent Batts
a6b197204e
blake3: update go mod deps
addresses CVE-2022-29526, even though we do not use `Faccessat()`

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2023-10-24 15:46:29 -04:00
Vincent Batts
5d0a5887d1
Merge pull request #94 from thaJeztah/update_blake3
blake3: update to github.com/zeebo/blake3 v0.2.2
2023-09-20 11:43:45 -05:00
Sebastiaan van Stijn
79188f3279
blake3: update to github.com/zeebo/blake3 v0.2.2
full diff: https://github.com/zeebo/blake3/compare/v0.1.1...v0.2.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-17 13:48:29 +02:00
Sebastiaan van Stijn
484d76b322
blake3: fix copyright header being used as GoDoc
The copyright header did not have an empty line after, which resulted
in it being considered an incorrectly formatted "Package" description;
https://pkg.go.dev/github.com/opencontainers/go-digest/blake3

This patch adds an empty line to prevent that.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-17 13:36:31 +02:00
Akihiro Suda
316f76db9b
Merge pull request #92 from opencontainers/dependabot/github_actions/actions/checkout-4
Bump actions/checkout from 3 to 4
2023-09-05 09:02:40 +09:00
dependabot[bot]
de45815805
Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 16:29:18 +00:00
Akihiro Suda
7577c5569a
Merge pull request #90 from thaJeztah/use_strings_cut
Digest: use strings.Cut, and remove Digest.sepIndex()
2023-08-27 08:10:40 +09:00
Sebastiaan van Stijn
b5c8031c24
slightly refactor TestParseDigest, and remove RunTestCases
Use a local loop over the test-cases, which allows running tests
individually in some IDE's, and show which test(s) failed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-17 18:23:59 +02:00
Sebastiaan van Stijn
15f1367760
Digest: use strings.Cut, and remove Digest.sepIndex()
This requires go1.18 or up.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-17 18:23:55 +02:00
Vincent Batts
802ce17c4f
Merge pull request #89 from thaJeztah/update_go_versions
drop obsolete Go versions, and add go1.21
2023-08-15 11:46:56 -04:00
Sebastiaan van Stijn
bd322c5560
drop obsolete Go versions, and add go1.21
These versions were really old, and all reached EOL.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-15 13:28:51 +02:00
Derek McGowan
122dc63842
Merge pull request #88 from thaJeztah/move_tests 2023-08-01 07:41:41 -07:00
Sebastiaan van Stijn
bf451503f8
gofmt, and touch-up some godoc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-01 15:27:26 +02:00
Sebastiaan van Stijn
84af967803
TestFroms: use sub-tests
Use sub-tests to not fail early if an algorithm fails.

With this change:

    === RUN   TestFroms
    === RUN   TestFroms/sha256
    === RUN   TestFroms/sha384
    === RUN   TestFroms/sha512
    --- PASS: TestFroms (0.02s)
        --- PASS: TestFroms/sha256 (0.01s)
        --- PASS: TestFroms/sha384 (0.00s)
        --- PASS: TestFroms/sha512 (0.00s)
    PASS

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-01 15:27:26 +02:00
Sebastiaan van Stijn
f94d70dcad
TestFroms: fix some linting issues
Keep the linters happy:

- fix an unhandled error (but unlikely to happen)
- fix some variables being shadowed

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-01 15:27:26 +02:00
Sebastiaan van Stijn
0927e7df5c
move digest tests to root
These tests have to be in their own package to prevent a circular import
between testdigest and the main module, but Go allows for blackbox-testing
by using a "_test" package.

This patch:

- moves the test file to be next to the implementation.
- removes the redundant imports of "crypto/sha256" and "crypto/shasha512",
  as they are imported by default since 084376bb543d4ce80b030a77a6f51f3b3fd861dc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-01 15:27:11 +02:00
Akihiro Suda
63939eb433
Merge pull request #87 from testwill/master
fix: code optimization
2023-05-30 00:19:07 +09:00
guoguangwu
b03a7a20db fix: code optimization
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-05-29 22:55:39 +08:00
Stephen Day
19833f24b9
Merge pull request #85 from austinvazquez/update-go-matrix
Add Go 1.18, 1.19, 1.20 to GitHub actions matrix
2023-05-25 11:08:35 -07:00
Stephen Day
1aab4ea3ce
Merge pull request #83 from thaJeztah/fix_deprecated_comments
fix deprecation of NewDigestFromHex and Digest.Hex
2023-05-25 11:08:05 -07:00
Akihiro Suda
65fac7b55e
Merge pull request #86 from opencontainers/dependabot/github_actions/actions/setup-go-4
Bump actions/setup-go from 3 to 4
2023-03-30 08:58:05 +09:00
dependabot[bot]
c014774bfa
Bump actions/setup-go from 3 to 4
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 16:57:08 +00:00
Austin Vazquez
0803ae2b53 Add Go 1.18, 1.19, 1.20 to GitHub actions matrix
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2023-02-02 22:11:34 +00:00
Sebastiaan van Stijn
50500bcd27
fix deprecation of NewDigestFromHex and Digest.Hex
Both of these were deprecated in 55f675811a1b915549933c64571fd86b2676ba76, but
the format of the GoDoc comments didn't follow the correct format, which causes
them not being picked up by tools as "deprecated".

This patch:

- Fixes the comments to be in the right format.
- Updates uses in the codebase to use the alternatives.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-08 13:46:07 +01:00
Sebastiaan van Stijn
718acf6e65
gofmt code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-08 13:45:17 +01:00
Sebastiaan van Stijn
bde1400a84
Merge pull request #74 from opencontainers/dependabot/github_actions/actions/setup-go-3
Bump actions/setup-go from 2 to 3
2022-04-11 22:53:49 +02:00
dependabot[bot]
c68b67b574
Bump actions/setup-go from 2 to 3
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 16:12:48 +00:00
Sebastiaan van Stijn
c6bb3c699a
Merge pull request #73 from opencontainers/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2 to 3
2022-03-07 18:28:32 +01:00
dependabot[bot]
58786aee6a
Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 16:11:15 +00:00
Vincent Batts
20c89ecc59
Merge pull request #70 from bloodorangeio/codeowners
Add CODEOWNERS, remove .pullapprove.yml
2021-11-23 11:44:50 -05:00