Skip to content

cli/registry/client: skip RepositoryInfo as intermediate#5959

Merged
thaJeztah merged 1 commit intodocker:masterfrom
thaJeztah:registry_client_skip_RepositoryInfo
Mar 27, 2025
Merged

cli/registry/client: skip RepositoryInfo as intermediate#5959
thaJeztah merged 1 commit intodocker:masterfrom
thaJeztah:registry_client_skip_RepositoryInfo

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

Remove RepositoryInfo as intermediate struct in some places; we want to remove the use of this additional abstration. More changes are needed to fully remove it, but chipping away its use in small bits.

- Human readable description for the release notes

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

@thaJeztah thaJeztah added this to the 28.0.3 milestone Mar 25, 2025
@thaJeztah thaJeztah marked this pull request as draft March 25, 2025 08:48
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.

Project coverage is 59.10%. Comparing base (930173a) to head (491e8fd).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5959      +/-   ##
==========================================
- Coverage   59.12%   59.10%   -0.02%     
==========================================
  Files         354      354              
  Lines       29747    29757      +10     
==========================================
  Hits        17587    17587              
- Misses      11186    11196      +10     
  Partials      974      974              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vvoland vvoland modified the milestones: 28.0.3, 28.0.4 Mar 25, 2025
@thaJeztah thaJeztah force-pushed the registry_client_skip_RepositoryInfo branch from 7c502f6 to 5263177 Compare March 25, 2025 09:52
Comment on lines +34 to +36
repoName := reference.TrimNamed(ref)
repoInfo, _ := registry.ParseRepositoryInfo(ref)
endpoint, err := getDefaultEndpointFromRepoInfo(repoInfo)
indexInfo := repoInfo.Index
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In case you're wondering why the extra variables; some of these are as a placeholder / intermediate state while I'm cleaning up things elsewhere.

@thaJeztah thaJeztah marked this pull request as ready for review March 25, 2025 11:52
@thaJeztah thaJeztah requested review from Benehiko and vvoland March 25, 2025 11:52
@thaJeztah thaJeztah force-pushed the registry_client_skip_RepositoryInfo branch 2 times, most recently from 719e5c6 to bb31ce8 Compare March 25, 2025 12:21
@vvoland vvoland modified the milestones: 28.0.4, 28.0.5 Mar 25, 2025
@thaJeztah
Copy link
Copy Markdown
Member Author

@vvoland @Benehiko ptal 🤗

}

func getDefaultEndpointFromRepoInfo(repoInfo *registry.RepositoryInfo) (registry.APIEndpoint, error) {
func getDefaultEndpoint(repoName reference.Named, insecure bool) (registry.APIEndpoint, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are we inversing the bool here? insecure vs secure.

Since the initial property is indexInfo.Secure perhaps we should just keep it as secure bool here?

There there is no need to have

if !insecure {
...
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since the previous implementation would be

repoInfo.Index.Secure = true
...
if !repoInfo.Index.Secure {} // test to see if not secure

But now it is

indexInfo.Secure = true
...
getDefaultEndpoint(ref, !indexInfo.Secure) // pass along if ( not ) secure = false
...
if !insecure {} // is insecure == false? yes let's proceed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ugh, yes, I screwed up there and the !insecure is flipped; I think a bad rebase (I extracted this from some branches where I made other changes).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Benehiko updated; flipped the boolean

@thaJeztah thaJeztah force-pushed the registry_client_skip_RepositoryInfo branch from bb31ce8 to 92345e6 Compare March 27, 2025 12:27
endpoint, err := getDefaultEndpointFromRepoInfo(repoInfo)
indexInfo := repoInfo.Index

endpoint, err := getDefaultEndpoint(ref, !indexInfo.Secure)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I recall now that I was looking whether this one should just get insecure (the argument) passed, which is set using the --insecure flag on docker manifest inspect, but , while related, they are technically different;

  • indexInfo.Secure is based on whether the registry is on a loopback address
  • --insecure allows overriding a secure registry to be accessed insecurely (which, if the registry is using TLS allows for an invalid TLS connection).

It's really a bit of a kludge altogether 💩 🔥 (it was added as a workaround because the CLI doesn't know about the daemon configuration, which has the "insecure-registries" option).

Remove RepositoryInfo as intermediate struct in some places; we want
to remove the use of this additional abstration. More changes are
needed to fully remove it, but chipping away its use in small bits.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the registry_client_skip_RepositoryInfo branch from 92345e6 to 491e8fd Compare March 27, 2025 12:34
if insecure {
for _, ep := range endpoints {
if ep.URL.Scheme == "http" {
endpoint = ep
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This should probably also have a break here 🤔 - let's keep that for a follow-up if we think it's important.

Copy link
Copy Markdown
Member

@Benehiko Benehiko left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah merged commit 99a6126 into docker:master Mar 27, 2025
87 checks passed
@thaJeztah thaJeztah deleted the registry_client_skip_RepositoryInfo branch March 27, 2025 17:46
@thaJeztah thaJeztah modified the milestones: 28.0.5, 28.1.0 Apr 10, 2025
@thaJeztah thaJeztah self-assigned this May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants