@ovotech/backstage-plugin-confluence-backend
TypeScript icon, indicating that this package has built-in type declarations

0.0.15 • Public • Published

Confluence search plugin backend

This plugin integrates Confluence documents to Backstage' search engine.

It is used in combination with its frontend counter-part.

Installation

Add the plugin to your backend app:

cd packages/backend && yarn add @k-phoen/backstage-plugin-confluence-backend

Configure the plugin in app-config.yaml:

# app-config.yaml
confluence:
  # Confluence base URL for wiki API
  # Typically: https://{org-name}.atlassian.net/wiki
  wikiUrl: https://org-name.atlassian.net/wiki

  # List of spaces to index
  # See https://confluence.atlassian.com/conf59/spaces-792498593.html
  spaces: [ENG]

  # Authentication credentials towards Confluence API
  auth:
    username: ${CONFLUENCE_USERNAME}
    # While Confluence supports BASIC authentication, using an API token is preferred.
    # See: https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/
    password: ${CONFLUENCE_PASSWORD}

It is also possible to use a Resource in the catalog to specify the spaces to index. The Resource should like like this:

apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: company-confluence-spaces
  description: List of all company Confluence spaces to index
  annotations:
    atlassian.net/confluence-spaces: 'Eng, Sales, Marketing, BizDev'
spec:
  type: confluence-spaces
  owner: my-team

Enable Confluence documents indexing in the search engine:

// packages/backend/src/plugins/search.ts
import { ConfluenceCollatorFactory } from '@k-phoen/backstage-plugin-confluence-backend';

export default async function createPlugin({
  logger,
  permissions,
  discovery,
  config,
  tokenManager,
}: PluginEnvironment) {
  // Initialize a connection to a search engine.
  const searchEngine = await ElasticSearchSearchEngine.fromConfig({
    logger,
    config,
  });
  const indexBuilder = new IndexBuilder({ logger, searchEngine });

  // …

  // Confluence indexing
  const halfHourSchedule = env.scheduler.createScheduledTaskRunner({
    frequency: Duration.fromObject({ minutes: 30 }),
    timeout: Duration.fromObject({ minutes: 15 }),
    // A 3 second delay gives the backend server a chance to initialize before
    // any collators are executed, which may attempt requests against the API.
    initialDelay: Duration.fromObject({ seconds: 3 }),
  });
  indexBuilder.addCollator({
    schedule: halfHourSchedule,
    factory: ConfluenceCollatorFactory.fromConfig(env.config, {
      logger: env.logger,
    }),
  });

  // …

  // The scheduler controls when documents are gathered from collators and sent
  // to the search engine for indexing.
  const { scheduler } = await indexBuilder.build();

  // A 3 second delay gives the backend server a chance to initialize before
  // any collators are executed, which may attempt requests against the API.
  setTimeout(() => scheduler.start(), 3000);
  useHotCleanup(module, () => scheduler.stop());

  return await createRouter({
    engine: indexBuilder.getSearchEngine(),
    types: indexBuilder.getDocumentTypes(),
    permissions,
    config,
    logger,
  });
}

If you have decided to use the Catalog (Resource) to define the spaces to index then there is a small change to the initialisation code:

...
indexBuilder.addCollator({
  schedule: halfHourSchedule,
  factory: ConfluenceCollatorFactory.fromConfig(env.config, {
    logger: env.logger,
    catalogClient: new CatalogClient({ discoveryApi: env.discovery }),
  }),
});
...

This will ensure the Catalog Client is specified - and it can then get the Resources of the specified type.

License

This library is under the MIT license.

/@ovotech/backstage-plugin-confluence-backend/

    Package Sidebar

    Install

    npm i @ovotech/backstage-plugin-confluence-backend

    Weekly Downloads

    40

    Version

    0.0.15

    License

    MIT

    Unpacked Size

    28.7 kB

    Total Files

    6

    Last publish

    Collaborators

    • ovotech-sg
    • arturpolianskyi
    • ovotech-qs
    • stefan-dospinescu-ovo
    • ovox
    • tomshawovo
    • george.anthony
    • sean-kantan
    • potsec
    • rosario-ovo
    • andrew-brook-rad
    • kantan_m_rutter
    • callumdenby
    • caolan.derry
    • apjm
    • kingfruit85
    • ovoenergyapps
    • tigranargit
    • chris-cooney-ovo
    • dela_kaluza
    • radinadineva
    • iain.rawson.ovo
    • cohen990-ovo
    • cp-ui-tooling
    • ovo-bit-tech
    • klaudia.marzec
    • mykola.p
    • jgok
    • luis.gashi
    • radhika-bijibilla
    • rmcnovo
    • fahedarshad
    • ovo_steve
    • askomaro
    • engagement-insights
    • gjain-npm-ovo
    • mwz
    • mtardugno-ovo
    • stewart-kantan
    • myovo-self-serve-service-account
    • morris27sky
    • peterh-ovo
    • zoejm
    • bizval-bot
    • tom.sherman
    • vcheban-ovo
    • vzahakailo
    • data.discovery.ovo
    • nick-ovox
    • ronald.nsabiyera
    • nick.long
    • aga-ovo
    • pkari
    • ovotech-smart-thermostat
    • ovo.trading.tech
    • jennyunchan
    • qe-team
    • esra.kaya
    • npmpwoo
    • oliwia-lakatosz
    • lenardprattovo
    • asellick
    • accrecovo
    • csillabarna
    • andy-heywood-ovo
    • a.calderwood
    • dvoroniuc-ovo
    • laurawady
    • vmary
    • franciscodiasovo
    • vukovo
    • prtn-ovo
    • mattgrayovo
    • edpatrick-ovo
    • per.linnett
    • jagreenwood1
    • retail-payg-tech
    • madalinadulhac
    • n-jeremic-npm
    • k-fernandez
    • phala.kantan
    • ovo-aarongibbison
    • tom.harrison-ovo
    • michal-at-kantan
    • cristinapetrov
    • ovo-josh
    • anthony_tonev
    • scdf
    • rise-team
    • jackbott-ovo
    • kuwotu
    • darren_thomas_ovo
    • samrumley88
    • bisongee
    • ohs-aurora
    • t.vytrykush
    • alan_smith_ovo
    • kgould
    • arpad.fesis.ovo
    • ovo-james
    • lewright
    • veselin.stamenov
    • philip.fol.ovo
    • cifdso
    • thomas.bingovo
    • shonnguen
    • ovo-venkat
    • dyl349
    • michaelwheeler
    • pablomuro-ovotech
    • zyurii
    • azaspenko
    • melcbuckov
    • vslepkan
    • mladjan-perceptive
    • props
    • jthomasovo
    • tarlingovo
    • mikethorpe-ovo
    • renimihaylova
    • jeffer_ovo
    • jlucktay
    • anglox
    • manoj-ovo
    • bare7aovo
    • brettburman-code
    • volodymyr-viniar
    • sambs
    • ds-ovo
    • shnist
    • ezio-intravaia-ovo
    • zolegovo
    • ryan.lee1
    • willshawmedia
    • andbrss
    • vitalii_khudenko
    • bookings-team
    • benaston13
    • jcholewa
    • gabriel.hulubei
    • ovo-markswaffer
    • kseniya.belevich
    • ion.nasu
    • timothy.ajisafe
    • mosman128
    • fraserhamiltonovo
    • lilbyteltd
    • irina.dimitriu
    • militsa_tsvetkova
    • pkoretsovo
    • ylukomskyi-corgi
    • andrixb
    • nathanmarshovo
    • ranarajput123
    • jadamiec-ovo
    • crektek
    • miksg
    • a1nsley
    • saamiyayousuf
    • veljko.popovic
    • cenkovic_ovo
    • mbartish_ovo
    • maxatko
    • samrushton
    • mihaidavidovo
    • emmadavids
    • mattbarkway
    • dhasovo
    • willcorrigan-ovo
    • edvinas.ovo
    • zoelanham
    • tokict2
    • owen1111
    • rafal-mac
    • ovotarasrusyniak
    • vasileovo
    • lyuboslav.lyubenov.ovo
    • mfiialko-ovo
    • lucafrancesc
    • charlieinshaw
    • ovotech-air-source-heat-pump
    • edandrewovo
    • s.slotskyi-ovo
    • aleksandyr
    • ivan.mihov-ovo
    • chris.brookes
    • iuna4e
    • maricel-ovo
    • olliebatchelor
    • jamieovo
    • darinakulishovo
    • rsh-ovo
    • dlaird-ovo
    • ovo.backstage.admins
    • catalin.andrei
    • warren-ovo
    • gideoncaspi
    • amymctigue
    • iulian.alexandru-ovo
    • c-bojan
    • iskren.ovo
    • richard.ashworth7
    • yordan-petkov-ovo
    • olesiapaslavska
    • richard-ovo
    • jake-davisovo
    • afdecastro879
    • ovo-home
    • chrisstephens-ovo
    • liming.cheung
    • sbetts-ovo
    • conor.mather.ovo
    • jonny-ovo
    • ben-harris-ovo
    • wiggly-ovo
    • martinyanevovo
    • alex-verbovskiy-ovo
    • chrisarmourovo
    • mrutter_ovo
    • vitalii-mohola-1988
    • j_kapella
    • aliovo
    • viktorborys-ovo
    • jaredph_ovo
    • ewanhardingham-ovo
    • ignaciodomenech
    • nevenablagoeva
    • giedrestu
    • joetkoczovo
    • alexandru.vicol1
    • marandries
    • jaroslavasovo
    • ovo-minsma
    • adamblackwater
    • aug24-ovo
    • ola-npm-ovo
    • manuelaovo
    • patrick.gray64
    • dlawes-ovo
    • portothree
    • ledanny.yang1
    • freddyfallon
    • zarkodragovic
    • ovo-jason
    • timhillovo