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

feat: allow for configuring the docker hub registry endpoint via API #21385

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tuunit
Copy link

@tuunit tuunit commented Jan 7, 2025

Comprehensive Summary of your change

This PR adds the possibility to change the registry endpoint of DockerHub via API. This is useful for Harbor instances that run in airgapped environments and have to go through a DMZ or use a reverse proxy to access DockerHub.

Why not just use a normal Docker Registry type instead of the DockerHub adapter?

Because of the logic for library images which only applies to the Registry Type DockerHub:

func defaultLibrary(ctx context.Context, registryID int64, a lib.ArtifactInfo) (bool, string, error) {
if registryID <= 0 {
return false, "", nil
}
reg, err := registry.Ctl.Get(ctx, registryID)
if err != nil {
return false, "", err
}
if reg.Type != model.RegistryTypeDockerHub {
return false, "", err
}
name := strings.TrimPrefix(a.Repository, a.ProjectName+"/")
if strings.Contains(name, "/") {
return false, "", nil
}
return true, name, nil
}

By allowing to change the registry endpoint for DockerHub, those kinds of environments can still benefit from the library substitution logic.

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@tuunit tuunit force-pushed the feat/configurable-endpoint-for-dockerhub branch from a250a3e to 2df26b3 Compare January 7, 2025 11:27
@tuunit tuunit marked this pull request as ready for review January 7, 2025 11:33
@tuunit tuunit requested a review from a team as a code owner January 7, 2025 11:33
@tuunit
Copy link
Author

tuunit commented Jan 7, 2025

/label release-note/enhancement

@Vad1mo Vad1mo added the release-note/enhancement Label to mark PR to be added under release notes as enhancement label Jan 7, 2025
@tuunit tuunit force-pushed the feat/configurable-endpoint-for-dockerhub branch from 2df26b3 to d33cf33 Compare January 8, 2025 10:21
@tuunit
Copy link
Author

tuunit commented Jan 8, 2025

@Vad1mo any feedback on the approach? Do you want me to write an apitest?

@Vad1mo
Copy link
Member

Vad1mo commented Jan 8, 2025

Makes sense to me..

It might be the stupid questions. but why is the URL hardcoded and not changeable in the first place?
Why not add the convenience to the user to preset it and allow the user to enter what he wants.

@tuunit
Copy link
Author

tuunit commented Jan 8, 2025

I have no idea why it is hardcoded 😅 If you want me to change the UI as well to allow changing it. I can do it as part of this PR or another. Just let me know what you guys would prefer on how to continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/enhancement Label to mark PR to be added under release notes as enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants