extension

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package extension provides a Forge extension adapter for the ctrlplane. It enables mounting CtrlPlane into a Forge application with automatic DI resolution, route registration, and lifecycle management.

Index

Constants

View Source
const ExtensionDescription = "CtrlPlane control plane for managing cloud infrastructure and deployments"
View Source
const ExtensionName = "ctrlplane"

ExtensionName is the name registered with Forge.

View Source
const ExtensionVersion = "0.1.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Config embeds the core ctrlplane configuration.
	ctrlplane.Config

	// BasePath is the URL prefix for all ctrlplane routes.
	BasePath string `default:"/api/cp" json:"base_path"`

	// AuthProvider is an explicitly configured auth provider.
	// If nil, the extension auto-discovers from Forge's DI container.
	AuthProvider auth.Provider `json:"-"`

	// DisableRoutes disables the registration of routes.
	DisableRoutes bool `default:"false" json:"disable_routes"`
}

Config holds configuration for the CtrlPlane Forge extension.

func (Config) ToCtrlPlaneConfig

func (c Config) ToCtrlPlaneConfig() ctrlplane.Config

ToCtrlPlaneConfig returns the embedded ctrlplane config.

type ExtOption

type ExtOption func(*Extension)

ExtOption configures the CtrlPlane Forge extension.

func WithAuthProvider

func WithAuthProvider(p auth.Provider) ExtOption

WithAuthProvider sets an explicit auth provider instead of auto-discovery.

func WithBasePath

func WithBasePath(path string) ExtOption

WithBasePath sets the URL prefix for all ctrlplane routes.

func WithConfig

func WithConfig(cfg Config) ExtOption

WithConfig sets the extension configuration directly.

func WithProvider

func WithProvider(name string, p provider.Provider) ExtOption

WithProvider registers a cloud/orchestrator provider.

func WithStore

func WithStore(opt app.Option) ExtOption

WithStore sets the store via an app option.

type Extension

type Extension struct {
	// contains filtered or unexported fields
}

Extension adapts CtrlPlane as a Forge extension. It implements the forge.Extension interface when used with Forge.

func New

func New(opts ...ExtOption) *Extension

New creates a CtrlPlane Forge extension with the given options.

func (*Extension) API

func (e *Extension) API() *api.API

API returns the API handler.

func (*Extension) CtrlPlane

func (e *Extension) CtrlPlane() *app.CtrlPlane

CtrlPlane returns the underlying CtrlPlane instance. This is nil until Init is called.

func (*Extension) Dependencies

func (e *Extension) Dependencies() []string

Dependencies returns the list of extension names this extension depends on. CtrlPlane has no required dependencies, but can optionally use auth extensions.

func (*Extension) Description

func (e *Extension) Description() string

func (*Extension) Handler

func (e *Extension) Handler() http.Handler

Handler returns the HTTP handler for all API routes. This is a convenience method for standalone use.

func (*Extension) Health

func (e *Extension) Health(ctx context.Context) error

Health implements forge.Extension.

func (*Extension) Init

func (e *Extension) Init(fapp forge.App) error

Init initializes the extension. In a Forge environment, this is called during app setup. For standalone use, call it manually.

func (*Extension) Name

func (e *Extension) Name() string

Name returns the extension name.

func (*Extension) Register

func (e *Extension) Register(fapp forge.App) error

Register implements forge.Extension.

func (*Extension) RegisterRoutes

func (e *Extension) RegisterRoutes(router forge.Router)

RegisterRoutes registers all ctrlplane API routes into a Forge router with full OpenAPI metadata. Use this for Forge extension integration where the parent app owns the router.

func (*Extension) Start

func (e *Extension) Start(ctx context.Context) error

Start begins background workers.

func (*Extension) Stop

func (e *Extension) Stop(ctx context.Context) error

Stop gracefully shuts down.

func (*Extension) Version

func (e *Extension) Version() string

Version implements forge.Extension.

Jump to

Keyboard shortcuts

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