import { getTags } from '@snyk/docker-registry-v2-client' ; import { RegistryInterface , RegistryOpts , ConfigInterface } from './interfaces' ; import chalk from 'chalk' ; import { logger } from './logger' ; const REGISTRY_BASE_V2 = 'registry-1.docker.io' ; export class Registry implements RegistryInterface { private registryConfig : RegistryOpts ; constructor ( clientConfig ) { this . registryConfig = { registryBase : clientConfig . privateRegistry || REGISTRY_BASE_V2 , repoUser : clientConfig . repoUser , repoPass : clientConfig . repoPass , } ; } param { string } repoName return { Promise < string [ ] | undefined > } async getRepositoryTags ( repoName ) { if ( ! repoName ) return ; try { const repoTags = await getTags ( this . registryConfig . registryBase , repoName , this . registryConfig . repoUser , this . registryConfig . repoPass ) ; return repoTags ; } catch ( err ) { console . log ( chalk . red ( `Registry client error: ${ err . message }` ) ) ; logger . error ( `Registry client error: ${ err . message }` ) ; return ; } } }