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

Assorted cleanups to reduce trust / notary imports #5878

Merged
merged 12 commits into from
Mar 3, 2025

Conversation

thaJeztah
Copy link
Member

cli/trust: make NotaryServer a const

This var used to be vendored from github.com/docker/docker/registry, but was
removed there, and made a local var in a1cbaa8.

It is (and should never be) modified, so let's change it into a const.

internal/test/notary: add testPassRetriever helper

Add a basic helper to provide the equivalent of passphrase.ConstantRetriever
with a fixed passphrase for testing.

cli/command/trust: remove unused passphrase-retriever from test

The test only validates that an error is produced because the notary
server is offline, and does not sent a passphrase.

cli/command/trust: remove TestGetOrGenerateNotaryKeyAndInitRepo

This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the TestGetSignableRolesError
test.

cli/command/trust: remove TestGetSignableRolesForTargetAndRemoveError

This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the TestGetSignableRolesError
test.

cli/command/trust: add testPassRetriever helper

Add a basic helper to provide the equivalent of passphrase.ConstantRetriever
with a fixed passphrase for testing.

cli/command/image: remove TestAddTargetToAllSignableRolesError

This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the TestGetSignableRolesError
test in the cli/trust package.

cli/command/image: use t.SetEnv in trust tests

cli/command/image: move trust unit-tests to trust package

These tests were not testing functionality that was implemented
in the image package. Move them to the trust package, where
they belong.

cli/command/trust: use gotest.tools in tests

cli/command/image: move AddTargetToAllSignableRoles to cli/trust

This utility was shared between the "image" and "trust" packages, and a
shallow wrapper around features in the cli/trust package. Move it there
instead and rename it to trust.AddToAllSignableRoles.

There are no known external consumers of this utility, so skipping a
deprecation.

cli/command/image: rename vars that shadowed type

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

thaJeztah added 12 commits March 2, 2025 12:42
This var used to be vendored from github.com/docker/docker/registry, but was
removed there, and made a local var in a1cbaa8.

It is (and should never be) modified, so let's change it into a const.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Add a basic helper to provide the equivalent of passphrase.ConstantRetriever
with a fixed passphrase for testing.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
The test only validates that an error is produced because the notary
server is offline, and does not sent a passphrase.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the [TestGetSignableRolesError]
test.

[TestGetSignableRolesError]: https://github.com/docker/cli/blob/fe0a8d27912dc6fddc60cedcd35bbef27b776355/cli/trust/trust_test.go#L49-L55

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the [TestGetSignableRolesError]
test.

[TestGetSignableRolesError]: https://github.com/docker/cli/blob/fe0a8d27912dc6fddc60cedcd35bbef27b776355/cli/trust/trust_test.go#L49-L55

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Add a basic helper to provide the equivalent of passphrase.ConstantRetriever
with a fixed passphrase for testing.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the [TestGetSignableRolesError]
test in the cli/trust package.

[TestGetSignableRolesError]: https://github.com/docker/cli/blob/fe0a8d27912dc6fddc60cedcd35bbef27b776355/cli/trust/trust_test.go#L49-L55

Signed-off-by: Sebastiaan van Stijn <[email protected]>
These tests were not testing functionality that was implemented
in the image package. Move them to the trust package, where
they belong.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This utility was shared between the "image" and "trust" packages, and a
shallow wrapper around features in the cli/trust package. Move it there
instead and rename it to `trust.AddToAllSignableRoles`.

There are no known external consumers of this utility, so skipping a
deprecation.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Mar 2, 2025

Codecov Report

Attention: Patch coverage is 10.00000% with 18 lines in your changes missing coverage. Please review.

Project coverage is 59.28%. Comparing base (fe0a8d2) to head (c7072a8).
Report is 17 commits behind head on master.

❌ Your patch status has failed because the patch coverage (10.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5878      +/-   ##
==========================================
- Coverage   59.32%   59.28%   -0.04%     
==========================================
  Files         353      353              
  Lines       29748    29752       +4     
==========================================
- Hits        17647    17639       -8     
- Misses      11113    11127      +14     
+ Partials      988      986       -2     

@thaJeztah thaJeztah changed the title Assorted cleanups for trust to reduce imports Assorted cleanups to reduce trust / notary imports Mar 2, 2025
@thaJeztah thaJeztah marked this pull request as ready for review March 2, 2025 13:34
@thaJeztah thaJeztah requested review from Benehiko, vvoland and a team March 3, 2025 10:25
@thaJeztah thaJeztah merged commit 076ec3b into docker:master Mar 3, 2025
113 checks passed
@thaJeztah thaJeztah deleted the trust_cleans branch March 3, 2025 11:18
@thaJeztah thaJeztah added this to the 28.0.2 milestone Mar 3, 2025
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.

3 participants