Skip to content

Conversation

@ilopezluna
Copy link
Contributor

This pull request introduces a way to handle custom registry options throughout the codebase by adding a centralized helper function for registry configuration.
This change will facilitate further integration testing, as it allows us to use a local OCI registry as the default one without needing to configure TLS.

@ilopezluna ilopezluna requested a review from a team October 31, 2025 19:59
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ilopezluna, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request streamlines how registry configurations are managed throughout the codebase by introducing a single, environment-variable-driven function. This change significantly improves flexibility, especially for development and testing environments, by simplifying the process of switching default registries and handling insecure connections, thereby reducing boilerplate and potential inconsistencies.

Highlights

  • Centralized Registry Configuration: Introduced a new helper function, GetDefaultRegistryOptions(), in pkg/distribution/registry/client.go to centralize the handling of custom registry options. This function reads DEFAULT_REGISTRY and INSECURE_REGISTRY environment variables to configure the default registry and allow insecure connections, respectively.
  • Enhanced Integration Testing: The new centralized configuration allows for easier integration testing by enabling the use of a local OCI registry as the default without requiring complex TLS configurations, as stated in the PR description.
  • Widespread Adoption of Default Options: Updated all calls to name.NewTag and name.ParseReference across cmd/cli/commands/package.go, cmd/cli/commands/tag.go, pkg/distribution/internal/store/index.go, pkg/distribution/registry/client.go, and pkg/metrics/metrics.go to utilize the newly introduced GetDefaultRegistryOptions() helper.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `pkg/distribution/registry/client.go:32-38` </location>
<code_context>
+// Returns a copy of the options to prevent race conditions from slice modifications.
+// - DEFAULT_REGISTRY: Override the default registry (index.docker.io)
+// - INSECURE_REGISTRY: Set to "true" to allow HTTP connections
+func GetDefaultRegistryOptions() []name.Option {
+	once.Do(func() {
+		var opts []name.Option
</code_context>

<issue_to_address>
**suggestion:** Consider thread-safety of environment variable usage in GetDefaultRegistryOptions.

If environment variables are expected to change at runtime, this implementation will not pick up those changes after the initial call. Consider documenting this behavior for clarity.

```suggestion
/*
GetDefaultRegistryOptions returns a name.Option slice with custom default registry
and insecure flag if the corresponding environment variables are set.

Environment variables are read only once, on the first call, and cached for consistency.
Subsequent changes to DEFAULT_REGISTRY or INSECURE_REGISTRY at runtime will NOT be picked up
until process restart. This is intentional for thread-safety and performance.

Returns a copy of the options to prevent race conditions from slice modifications.

- DEFAULT_REGISTRY: Override the default registry (index.docker.io)
- INSECURE_REGISTRY: Set to "true" to allow HTTP connections
*/
func GetDefaultRegistryOptions() []name.Option {
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a centralized helper function, GetDefaultRegistryOptions, to manage custom OCI registry configurations through environment variables. This is a good approach to standardize registry options across the codebase. The changes are consistently applied in all relevant files. My main feedback is the lack of unit tests for the new GetDefaultRegistryOptions function, which is crucial for ensuring its correctness and preventing future regressions. I've added a comment with details on how to add these tests.

@ilopezluna ilopezluna merged commit 1d61128 into main Nov 3, 2025
9 checks passed
@ilopezluna ilopezluna deleted the default-registry branch November 3, 2025 09:58
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.

3 participants