backstage

package module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 0 Imported by: 0

README

Backstage Go SDK

A Go SDK and CLI tool for working with Backstage.

CLI tool

The backstage CLI tool provides command-line access to Backstage APIs.

# Authenticate to your Backstage instance.
$ backstage auth login --base-url "https://your-backstage.com" --token "<TOKEN>"

# List component entities in the catalog.
$ backstage catalog entities list --filter "kind=Component"

# Get an entity in the catalog.
$ backstage catalog entities get-by-name --kind "User" --name "odsod"

# Validate catalog entities in the ".backstage" dir.
$ backstage catalog entities validate ".backstage"

The CLI tool can be downloaded from the Releases page.

Software Catalog API

The catalog package provides a Go client to the Software Catalog API.

package main

import (
	"context"
	"fmt"

	"go.einride.tech/backstage/catalog"
)

func main() {
	ctx := context.Background()
	// Create a Software Catalog API client.
	client := catalog.NewClient(
		catalog.WithBaseURL("https://your-backstage-instance.example.com"),
		catalog.WithToken("YOUR_API_AUTH_TOKEN"),
	)
	// List component entities.
	response, err := client.ListEntities(ctx, &catalog.ListEntitiesRequest{
		Filters: []string{"kind=Component"},
	})
	if err != nil {
		panic(err)
	}
	for _, entity := range response.Entities {
		// Standard fields are parsed into Go structs.
		fmt.Println(entity.Metadata.Name)
		// Standard fields on specs can be parsed into Go structs.
		spec, err := entity.ComponentSpec()
		if err != nil {
			panic(err)
		}
		fmt.Println(spec.Lifecycle)
		// Custom fields can be accessed via raw JSON.
		fmt.Println(string(entity.Raw))
	}
}

Documentation

Overview

Package backstage is the top-level module for this Backstage Go SDK.

Directories

Path Synopsis
Package catalog provides primitives for the Backstage Software Catalog API.
Package catalog provides primitives for the Backstage Software Catalog API.
cmd
backstage Module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL