2018-11-24 14:00:19 +00:00
|
|
|
import { logger } from '../npmci.logging';
|
2018-04-04 20:25:13 +00:00
|
|
|
import * as plugins from './mod.plugins';
|
2021-05-14 18:11:12 +00:00
|
|
|
import { ObjectMap } from '@pushrocks/lik';
|
2017-08-27 23:03:59 +00:00
|
|
|
|
2018-04-04 20:25:13 +00:00
|
|
|
import { DockerRegistry } from './mod.classes.dockerregistry';
|
2017-08-27 23:03:59 +00:00
|
|
|
|
|
|
|
export class RegistryStorage {
|
2021-05-14 18:11:12 +00:00
|
|
|
objectMap = new ObjectMap<DockerRegistry>();
|
2018-04-04 20:25:13 +00:00
|
|
|
constructor() {
|
2017-08-27 23:03:59 +00:00
|
|
|
// Nothing here
|
|
|
|
}
|
|
|
|
|
2018-04-04 20:25:13 +00:00
|
|
|
addRegistry(registryArg: DockerRegistry) {
|
|
|
|
this.objectMap.add(registryArg);
|
2017-08-27 23:03:59 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 20:25:13 +00:00
|
|
|
getRegistryByUrl(registryUrlArg: string) {
|
2021-10-19 01:09:50 +00:00
|
|
|
return this.objectMap.findSync((registryArg) => {
|
2018-04-04 20:25:13 +00:00
|
|
|
return registryArg.registryUrl === registryUrlArg;
|
|
|
|
});
|
2017-08-27 23:03:59 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 20:25:13 +00:00
|
|
|
async loginAll() {
|
2021-05-14 18:11:12 +00:00
|
|
|
await this.objectMap.forEach(async (registryArg) => {
|
2018-04-04 20:25:13 +00:00
|
|
|
await registryArg.login();
|
|
|
|
});
|
2018-11-24 14:00:19 +00:00
|
|
|
logger.log('success', 'logged in successfully into all available DockerRegistries!');
|
2017-08-27 23:03:59 +00:00
|
|
|
}
|
|
|
|
}
|