|
1 | 1 | import { Injectable } from '@angular/core';
|
2 | 2 | import { ApplicationSettings, DockerRegistrySettings, DockerClientSettings } from './settings.model';
|
3 | 3 | import { of, BehaviorSubject } from 'rxjs';
|
4 |
| -import { map } from 'rxjs/operators'; |
| 4 | +import { map, switchMap } from 'rxjs/operators'; |
5 | 5 | import { MatDialog } from '@angular/material';
|
6 | 6 | import { RegistrySettingsModalComponent } from './registry-settings-modal/registry-settings-modal.component';
|
7 | 7 | import { FormGroup } from '@angular/forms';
|
@@ -95,9 +95,15 @@ export class SettingsService {
|
95 | 95 | public getRegistrySettingsForImage(image: string) {
|
96 | 96 | if (image.includes('/')) {
|
97 | 97 | 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 | + })); |
101 | 107 | } else {
|
102 | 108 | return this.getDockerIOSettings();
|
103 | 109 | }
|
@@ -138,7 +144,7 @@ export class SettingsService {
|
138 | 144 | return this.getSettings()
|
139 | 145 | .pipe(
|
140 | 146 | map(settings => settings.registries[0]),
|
141 |
| - ); |
| 147 | + ); |
142 | 148 | }
|
143 | 149 |
|
144 | 150 | public openRegistrySettingsDialog(registryFormGroup: FormGroup) {
|
|
0 commit comments