import type { IFindImageParams , IFindTagsParams , IImage } from '@spinnaker/core' ; import { REST , RetryService } from '@spinnaker/core' ; export interface IDockerImage extends IImage { account : string ; registry : string ; repository : string ; tag : string ; } export class DockerImageReader { public static getImage ( imageName , region , credentials ) { return REST ( '/images' ) . path ( credentials , region , imageName ) . query ( { provider : 'docker' } ) . get ( ) . then ( ( results ) => ( results && results . length ? results [ 0 ] : null ) ) . catch ( ( ) : IDockerImage => null ) ; } public static findImages ( params ) { return RetryService . buildRetrySequence < IDockerImage [ ] > ( ( ) => REST ( '/images/find' ) . query ( params ) . get ( ) , ( results ) => results . length > 0 , 10 , 1000 ) . then ( ( results ) => results ) . catch ( ( ) : IDockerImage [ ] => [ ] ) ; } public static findTags ( params ) { return RetryService . buildRetrySequence < string [ ] > ( ( ) => REST ( '/images/tags' ) . query ( params ) . get ( ) , ( results ) => results . length > 0 , 10 , 1000 ) . then ( ( results ) => results ) . catch ( ( ) : string [ ] => [ ] ) ; } }