mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
fix(registry) EE-1861 improve registry selection (#5925)
* fix(registry) EE-1861 improve registry selection (#5899) * fix(registry) EE-1861 hide anonymous dockerhub registry if user has an authenticated one * fix(registry) EE-1861 pick up a best match dockerhub registry * fix(registry) EE-1861 set the anonymous registry as default if it is shown * fix(registry) EE-1861 refactor how to match registry Co-authored-by: Simon Meng <simon.meng@portainer.io> * fix(registry) EE-1861 fail to select registry with same name * fix(registry) EE-1861 show registry modal when pull and push image * fix(registry) EE-1861 cleanup code Co-authored-by: Simon Meng <simon.meng@portainer.io>
This commit is contained in:
parent
623079442f
commit
d18c8d0e88
6 changed files with 141 additions and 23 deletions
|
@ -77,13 +77,19 @@ class porImageRegistryController {
|
|||
async reloadRegistries() {
|
||||
return this.$async(async () => {
|
||||
try {
|
||||
const registries = await this.EndpointService.registries(this.endpoint.Id, this.namespace);
|
||||
this.registries = _.concat(this.defaultRegistry, registries);
|
||||
let showDefaultRegistry = false;
|
||||
this.registries = await this.EndpointService.registries(this.endpoint.Id, this.namespace);
|
||||
|
||||
// hide default(anonymous) dockerhub registry if user has an authenticated one
|
||||
if (!this.registries.some((registry) => registry.Type === RegistryTypes.DOCKERHUB)) {
|
||||
showDefaultRegistry = true;
|
||||
this.registries.push(this.defaultRegistry);
|
||||
}
|
||||
|
||||
const id = this.model.Registry.Id;
|
||||
const registry = _.find(this.registries, { Id: id });
|
||||
if (!registry) {
|
||||
this.model.Registry = this.defaultRegistry;
|
||||
this.model.Registry = showDefaultRegistry ? this.defaultRegistry : this.registries[0];
|
||||
}
|
||||
} catch (err) {
|
||||
this.Notifications.error('Failure', err, 'Unable to retrieve registries');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue