import { withApmSpan } from '../../../../utils/with_apm_span' ; import { getAllEnvironments } from '../../../environments/get_all_environments' ; import { Setup } from '../../../../lib/helpers/setup_request' ; import { getExistingEnvironmentsForService } from './get_existing_environments_for_service' ; import { ALL_OPTION_VALUE } from '../../../../../common/agent_configuration/all_option' ; export async function getEnvironments ( { serviceName , setup , searchAggregatedTransactions , size , } ) { return withApmSpan ( 'get_environments_for_agent_configuration' , async ( ) => { const [ allEnvironments , existingEnvironments ] = await Promise . all ( [ getAllEnvironments ( { searchAggregatedTransactions , serviceName , setup , size , } ) , getExistingEnvironmentsForService ( { serviceName , setup , size } ) , ] ) ; return [ ALL_OPTION_VALUE , ... allEnvironments ] . map ( ( environment ) => { return { name : environment , alreadyConfigured : existingEnvironments . includes ( environment ) , } ; } ) ; } ) ; }