Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.

Commit 6620f44

Browse files
author
Leonardo Chaia
committed
fix: fixes Docker Hub private repo authentication
1 parent 61fa029 commit 6620f44

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/app/registry/registry.service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class RegistryService {
4040
};
4141
return this.settingsService.getSettings()
4242
.pipe(
43+
take(1),
4344
map(settings => settings.registries.filter(r => r.allowsCatalog)),
4445
switchMap(registries => registries.length ? forkJoin(registries.map(r => getRepos(r))) : of([]))
4546
);

src/app/settings/settings.service.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { ApplicationSettings, DockerRegistrySettings, DockerClientSettings } from './settings.model';
33
import { of, BehaviorSubject } from 'rxjs';
4-
import { map } from 'rxjs/operators';
4+
import { map, switchMap } from 'rxjs/operators';
55
import { MatDialog } from '@angular/material';
66
import { RegistrySettingsModalComponent } from './registry-settings-modal/registry-settings-modal.component';
77
import { FormGroup } from '@angular/forms';
@@ -95,9 +95,15 @@ export class SettingsService {
9595
public getRegistrySettingsForImage(image: string) {
9696
if (image.includes('/')) {
9797
return this.getSettings()
98-
.pipe(map(settings =>
99-
settings.registries.filter(x => image.includes(this.getRegistryName(x)))[0]
100-
));
98+
.pipe(switchMap(settings => {
99+
const registry = settings.registries.find(x => image.includes(this.getRegistryName(x)));
100+
// If no registry, asume Docker Hub username
101+
if (registry) {
102+
return of(registry);
103+
} else {
104+
return this.getDockerIOSettings();
105+
}
106+
}));
101107
} else {
102108
return this.getDockerIOSettings();
103109
}
@@ -138,7 +144,7 @@ export class SettingsService {
138144
return this.getSettings()
139145
.pipe(
140146
map(settings => settings.registries[0]),
141-
);
147+
);
142148
}
143149

144150
public openRegistrySettingsDialog(registryFormGroup: FormGroup) {

0 commit comments

Comments
 (0)