npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@janus-idp/backstage-scaffolder-backend-module-annotator

v2.2.1

Published

The annotator module for @backstage/plugin-scaffolder-backend

Downloads

4,715

Readme

Annotator custom action for Scaffolder Backstage

The annotator module for @backstage/plugin-scaffolder-backend.

This module allows users to create custom actions for annotating their entity objects. Additionally, it enables users to utilize existing custom actions provided by the module for annotating entities with timestamps and scaffolder entity references.

Installation

Available custom actions

| Action | Description | | ------------------------- | :-----------------------------------------------------------------------------------------------------: | | catalog:timestamping | Adds the backstage.io/createdAt annotation containing the current timestamp to your entity object | | catalog:scaffolded-from | Adds scaffoldedFrom spec containing the template entityRef to your entity object | | catalog:annotate | Allows you to annotate your entity object with specified label(s), annotation(s) and spec property(ies) |

To begin, install the module package into the backend workspace of your backstage instance:

yarn workspace backend add @janus-idp/backstage-scaffolder-backend-module-annotator

Registering the annotator action plugin with the backend system

To install the module into the backend system, add the following into the packages/backend/src/index.ts file:

const backend = createBackend();

// highlight-add-start
backend.add(import('@janus-idp/backstage-scaffolder-backend-module-annotator'));
// highlight-add-end

backend.start();

Creating custom actions for your templates using the annotator module

Create the custom action

The createAnnotatorAction action accepts the following parameters:

| Parameter Name | Type | Required | Description | | ---------------------------------- | :------: | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | actionId | string | Yes | A unique id for the action. Default: catalog:annotate, please provide one or else it may conflict with the generic catalog:annotate custom action that is provided by this module. | | actionDescription | string | No | A description of what the action accomplishes. Default: "Creates a new scaffolder action to annotate the entity object with specified label(s), annotation(s) and spec property(ies)." | | loggerInfoMsg | string | No | A message that will be logged upon the execution of the action. Default: "Annotating your object" | | annotateEntityObject.labels | object | No | Key-value pairs to be added to the metadata.labels of the entity | | annotateEntityObject.annotations | object | No | Key-value pairs to be added to the metadata.annotations of the entity | | annotateEntityObject.spec | object | No | Key-value pairs to be added to the spec of the entity. The value for each key can either be a string or an object with the key readFromContext, enabling users to specify the path in the context from which the value should be retrieved. |

  1. Create your custom action

  2. Add the annotator module package @janus-idp/backstage-scaffolder-backend-module-annotator into your module's package.json

  3. In the action file, add the following snippet to it:

// highlight-add-start
import { createAnnotatorAction } from '@janus-idp/backstage-scaffolder-backend-module-annotator';

export const createAddCompanyTitleAction = () => {
  return createAnnotatorAction(
    'catalog:company-title',
    'Creates a new `catalog:company-title` Scaffolder action to annotate scaffolded entities with the company title.',
    'Annotating catalog-info.yaml with the company title',
  );
};
// highlight-add-end
  1. Install the custom action into your backstage instance following steps similar to the installation instructions above

Use your custom action in your desired template(s)

The annotator template action accepts the following inputs

Input

| Parameter Name | Type | Required | Description | | ---------------- | :------: | :------: | ------------------------------------------------------------------------------------------------------------------ | | labels | object | No | Key-value pairs to be added to the metadata.labels of the entity | | annotations | object | No | Key-value pairs to be added to the metadata.annotations of the entity | | spec | object | No | Key-value pairs to be added to the spec of the entity | | entityFilePath | string | No | The file path from which the YAML representation of the entity should be read | | objectYaml | object | No | The YAML representation of the object/entity | | writeToFile | string | No | The file path where the YAML representation of the entity should be stored. Default value is './catalog-info.yaml' |

Output

| Name | Type | Description | | ----------------- | :------: | -------------------------------------------------------------------------------------------- | | annotatedObject | object | The entity object marked with your specified annotation(s), label(s), and spec property(ies) |

To annotate the entity file, add your custom action to your template file after Fetch Skeleton + Template step. Please note that your custom action needs to be installed into the backstage instance running the software template.

// highlight-add-start
- id: company-title
  name: Add company title to catalog-info.yaml
  action: catalog:company-title
  input:
    labels: {
      company: 'My Company'
    }
// highlight-add-end