Code Monkey home page Code Monkey logo

plugin-scaffolder-actions's Introduction

CNOE Scaffolder Actions Plugin

Getting Started

Add to your Backstage app.

# From your Backstage root directory
yarn add --cwd packages/backend @cnoe-io/plugin-scaffolder-actions
# To be able to keep using the built-in actions.
yarn add --cwd packages/backend @backstage/integration

Append it to your existing actions in packages/backend/src/plugins/scaffolder.ts

import { CatalogClient } from '@backstage/catalog-client';
import { createRouter, createBuiltinActions } from '@backstage/plugin-scaffolder-backend';
import { ScmIntegrations } from '@backstage/integration';
import { Router } from 'express';
import type { PluginEnvironment } from '../types';
import {
  createSanitizeResource,
  createVerifyDependency,
  createKubernetesApply,
} from "@cnoe-io/plugin-scaffolder-actions";

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  const catalogClient = new CatalogClient({ discoveryApi: env.discovery });
  const integrations = ScmIntegrations.fromConfig(env.config);

  const builtInActions = createBuiltinActions({
    integrations,
    catalogClient,
    config: env.config,
    reader: env.reader,
  });
  
  const cnoeActions = [
    createSanitizeResource(),
    createVerifyDependency(),
    createKubernetesApply(env.config),
  ]

  const actions = [
      ...builtInActions,
      ...cnoeActions,
  ]

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

Done! You can now use any of the action in your software templates.

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: hello-world-on-kubernetes
  title: Hello World on Kubernetes
spec:
  steps:
    - id: sanitize-resource
      name: Sanitize Resource
      action: cnoe:utils:sanitize
      input:
        resource: ${{ serialize.output }}

List of Actions

Here is a list of running actions.

Action id Description Reference
createKubernetesApply cnoe:kubernetes:apply Apply Kubernetes manifest to a template k8s-apply
createVerifyDependency cnoe:verify:dependency Verify resource dependencies for CNOE verify
createSanitizeResource cnoe:utils:sanitize Sanitize resources (remove empty fields) before further processing sanitize

For more detailed information about these actions, go to /create/actions endpoint of your Backstage instance after installing these actions. If you are running this locally, the endpoint should be http://localhost:3000/create/actions

plugin-scaffolder-actions's People

Contributors

nimakaviani avatar kahilof avatar nabuskey avatar jessesanford avatar

Stargazers

 avatar

Watchers

 avatar Joel Cooklin avatar Rick Sostheim avatar Paul Roberts avatar  avatar Tulika Garg avatar  avatar Vikram Sethi avatar  avatar

plugin-scaffolder-actions's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.