import { DockerContainerRunner , SingleHostDiscovery , UrlReader , ContainerRunner } from '@backstage/backend-common' ; import { CatalogClient } from '@backstage/catalog-client' ; import { createRouter , createBuiltinActions , TemplateAction } from '@backstage/plugin-scaffolder-backend' ; import { createHttpBackstageAction } from '@roadiehq/scaffolder-backend-module-http-request' ; import Docker from 'dockerode' ; import { Router } from 'express' ; import type { PluginEnvironment } from '../types' ; import { ScmIntegrations } from '@backstage/integration' ; import { Config } from '@backstage/config' ; export const createActions = ( options ) : TemplateAction < any > [ ] => { const { reader , integrations , config , containerRunner , catalogClient } = options ; const defaultActions = createBuiltinActions ( { reader , integrations , containerRunner , catalogClient , config , } ) ; return [ createHttpBackstageAction ( { config } ) , ... defaultActions ] ; } ; export default async function createPlugin ( { logger , config , database , reader , } ) { const dockerClient = new Docker ( ) ; const containerRunner = new DockerContainerRunner ( { dockerClient } ) ; const discovery = SingleHostDiscovery . fromConfig ( config ) ; const catalogClient = new CatalogClient ( { discoveryApi : discovery } ) ; return await createRouter ( { containerRunner , logger , config , database , catalogClient , reader , actions : createActions ( { reader , integrations : ScmIntegrations . fromConfig ( config ) , config , catalogClient : catalogClient , containerRunner : containerRunner , } ) , } ) ; }