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

@redhat-developer/plugin-scaffolder-odo-actions

v0.20.0

Published

odo custom actions for Backstage (Backend Plugin)

Downloads

45

Readme

scaffolder-odo-actions

This is a Backend Plugin containing a set of Custom Actions using the odo CLI. It contains the following actions:

  • devfile:odo:command: a generic action that can execute any odo command from the scaffolder workspace.

  • devfile:odo:component:init: allows to execute the odo init command from the Scaffolder workspace. The goal of this action is to generate a starter project for a given Devfile that can be customized later on.

Preview

Preview

Installation

From your Backstage instance root folder:

yarn add --cwd packages/backend @redhat-developer/plugin-scaffolder-odo-actions

This will download the right odo binary for the current operating system and architecture from the Red Hat servers at https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/.

This behavior can be customized by adding a new "odo" field in your packages/backend/package.json file, like so:

// packages/backend/package.json

{
  "odo": {
    // specifying the version is optional.
    // You can also specify "latest" to use the latest version of odo, or "nightly" to use the latest nightly build of odo.
    "version": "3.15.0",
    "skipDownload": false
  }
}

Note that the custom actions here do require an odo binary to work properly. So if you choose to skip the download (using the odo.skipDownload property above), you need to make sure to meet any of the requirements below:

  • either you can explicitly set the path to the odo binary in your app-config.yaml (see below);
  • or odo is already installed and available globally in the system paths of the environment the Backstage instance is running in.

Configuration

Code

  1. Import the actions into your packages/backend/src/plugins/scaffolder.ts on the Scaffolder Backend Plugin of your Backstage instance:
// packages/backend/src/plugins/scaffolder.ts

import { createBuiltinActions } from '@backstage/plugin-scaffolder-backend';
import { ScmIntegrations } from '@backstage/integration';
import { odoInitAction, odoAction } from '@redhat-developer/plugin-scaffolder-odo-actions';
  1. Then pass the imported actions along with the built-in ones to the createRouter function. You should end up with something like this in the end:
// packages/backend/src/plugins/scaffolder.ts

const integrations = ScmIntegrations.fromConfig(env.config);

const builtInActions = createBuiltinActions({
  integrations,
  catalogClient,
  config: env.config,
  reader: env.reader,
});

const actions = [
  ...builtInActions,
  odoInitAction(env.config.getOptionalConfig("odo")),
  odoAction(env.config.getOptionalConfig("odo")),
];

return await createRouter({
  logger: env.logger,
  config: env.config,
  database: env.database,
  reader: env.reader,
  catalogClient,
  actions,
});

app-config.yaml

Optionally, the behavior of these custom actions can be customized by adding the following section to your app-config.yaml file:

# app-config.yaml

odo:
  # When adding this plugin to your Backstage instance, it will automatically try to download the right odo binary and use it.
  # But if you already have odo installed, you can override the path below.
  # binaryPath: '/path/to/odo'
  telemetry:
    # Disable the odo telemetry.
    # Default: false
    disabled: false
  devfileRegistry:
    # Used for calling `odo init` and any other custom actions relying on a Devfile registry.
    # If you are using the Devfile Selector Custom Field Extension in your template,
    # you need to also add this URL to the 'proxy.endpoints' field under a '/devfile-registry' field.
    # Default: 'https://registry.devfile.io'
    url: 'https://registry.devfile.io'

You should now see the custom devfile:odo:* actions if you navigate to the Actions page at http://localhost:3000/create/actions.

List of Actions

Usage

You can use the action in any of the steps of your Software Template. See https://github.com/ododev/odo-backstage-software-template for an example of a Software Template making use of the Actions here.

Example with the odo init action

This action can be used in conjunction with the devfile-field-extension Custom Field Extension to get the Devfile input data from the end-user, e.g.:

spec:
  parameters:

    - title: Provide details about the Devfile
      required:
        - devfile_data
      properties:
        devfile_data:
          type: object
          required:
            - devfile
            - version
          properties:
            devfile:
              type: string
            version:
              type: string
            starter_project:
              type: string
          ui:field: DevfileSelectorExtension

  steps:
    - id: odo-init
      name: Generate
      action: devfile:odo:component:init
      input:
        name: ${{ parameters.name }}
        devfile: ${{ parameters.devfile_data.devfile }}
        version: ${{ parameters.devfile_data.version }}
        starter_project: ${{ parameters.devfile_data.starter_project }}

Example with the generic odo action

spec:
  # [...]

  steps:
    - id: generic-odo-command
      name: Execute odo command
      action: devfile:odo:command
      input:
        command: ${{ parameters.command }} # e.g.: 'analyze'
        args: ${{ parameters.args }} # e.g.: ['-o', 'json']