coder / backstage-plugins

Official Coder plugins for the Backstage platform
40 stars 3 forks source link

Devcontainers backend plugin: update code/documentation to account for Backstage's 'New Backend System' #93

Open Parkreiner opened 7 months ago

Parkreiner commented 7 months ago

The current code/documentation for the backend devcontainers plugin is based on Backstage's previous backend system. But recently, they've rolled out a New Backend System

I don't think we'll actually need to make any changes to the processor class itself, but we do want to make sure that:

  1. The class follows any new patterns for exports
  2. The documentation is updated to walk somebody through adding the devcontainers plugin for the old/classic backend system, and the new one
SuperCoolAlan commented 2 weeks ago

I've gotten started on testing out this migration. Importing the backend plugin was not too difficult following https://backstage.io/docs/backend-system/building-backends/migrating/. That was until I reached incompatible dependencies during build time. I'll continue on to see if I can figure out what's giving me issues during the build.

ipe4647 commented 13 hours ago

This is working with the new backend system:

# packages/backend/src/index.ts

...
import { createBackendModule } from '@backstage/backend-plugin-api';
import { DevcontainersProcessor } from '@coder/backstage-plugin-devcontainers-backend';
import { loggerToWinstonLogger } from '@backstage/backend-common';

const backend = createBackend();
....

export const catalogModuleDevcontainersProcessor = createBackendModule({
    pluginId: 'catalog',
    moduleId: 'devcontainers-processor',
    register(env) {
      env.registerInit({
        deps: {
          catalog: catalogProcessingExtensionPoint,
          logger: coreServices.logger,
          urlReader: coreServices.urlReader,
        },
        async init({ catalog, logger, urlReader }) {
          catalog.addProcessor(new DevcontainersProcessor(urlReader, {
            tagName: "devcontainers",
            logger: loggerToWinstonLogger(logger)
          }));
        },
      });
    },
  });
backend.add(catalogModuleDevcontainersProcessor);

...

backend.start();

I don't know how long will it work since backstage/backend-common is deprecated.

This is running every 2 minutes. It would be nice if we can increase this. Maybe processing loop ties in: https://backstage.io/docs/features/software-catalog/configuration/#processing-interval