extensions

package
v0.0.0-...-6f9ab45 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExtensionNotFound          = errors.New("extension not found")
	ErrInstalledExtensionNotFound = errors.New("extension not found")
	ErrRegistryExtensionNotFound  = errors.New("extension not found in registry")
	ErrExtensionInstalled         = errors.New("extension already installed")

	FeatureExtensions = alpha.MustFeatureKey("extensions")
)
View Source
var (
	ErrSourceNotFound    = errors.New("extension source not found")
	ErrSourceExists      = errors.New("extension source already exists")
	ErrSourceTypeInvalid = errors.New("invalid extension source type")
)

Functions

This section is empty.

Types

type CapabilityType

type CapabilityType string
const (
	// Custom commands expose new command groups & comments to AZD
	CustomCommandCapability CapabilityType = "custom-commands"
	// Lifecycle events enable extensions to subscribe to AZD project & service lifecycle events
	LifecycleEventsCapability CapabilityType = "lifecycle-events"
)

type Extension

type Extension struct {
	Id           string           `json:"id"`
	Namespace    string           `json:"namespace"`
	Capabilities []CapabilityType `json:"capabilities,omitempty"`
	DisplayName  string           `json:"displayName"`
	Description  string           `json:"description"`
	Version      string           `json:"version"`
	Usage        string           `json:"usage"`
	Path         string           `json:"path"`
	Source       string           `json:"source"`
	// contains filtered or unexported fields
}

Extension represents an installed extension.

func (*Extension) Fail

func (e *Extension) Fail(err error)

Fail signals that the extension has encountered an error.

func (*Extension) HasCapability

func (e *Extension) HasCapability(capability ...CapabilityType) bool

HasCapability checks if the extension has the specified capabilities.

func (*Extension) Initialize

func (e *Extension) Initialize()

Initialize signals that the extension is ready.

func (*Extension) StdErr

func (e *Extension) StdErr() *output.DynamicMultiWriter

StdErr returns the standard error writer for the extension.

func (*Extension) StdIn

func (e *Extension) StdIn() io.Reader

StdIn returns the standard input buffer for the extension.

func (*Extension) StdOut

func (e *Extension) StdOut() *output.DynamicMultiWriter

StdOut returns the standard output writer for the extension.

func (*Extension) WaitUntilReady

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

WaitUntilReady blocks until the extension signals readiness or failure.

type ExtensionArtifact

type ExtensionArtifact struct {
	// URL is the location of the artifact
	URL string `json:"url"`
	// Checksum is the checksum of the artifact
	Checksum ExtensionChecksum `json:"checksum"`
	// AdditionalMetadata is a map of additional metadata for the artifact
	AdditionalMetadata map[string]any `json:"-"`
}

ExtensionArtifact represents the artifact information of an extension An artifact can be a URL to a single binary file or a zip archive.

func (ExtensionArtifact) MarshalJSON

func (c ExtensionArtifact) MarshalJSON() ([]byte, error)

func (*ExtensionArtifact) UnmarshalJSON

func (c *ExtensionArtifact) UnmarshalJSON(data []byte) error

type ExtensionChecksum

type ExtensionChecksum struct {
	// Algorithm is the algorithm used to calculate the checksum
	// Examples: sha256, sha512
	Algorithm string `json:"algorithm"`
	// Value is the checksum value to match during the integrity check.
	Value string `json:"value"`
}

ExtensionChecksum represents the checksum of an extension artifact used to validate the integrity of the artifact.

type ExtensionDependency

type ExtensionDependency struct {
	// Id is the unique identifier of the dependent extension
	Id string `json:"id"`
	// Version is the version of the dependent extension and supports semantic versioning expressions.
	Version string `json:"version,omitempty"`
}

ExtensionDependency represents a dependency of an extension

type ExtensionExample

type ExtensionExample struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Usage       string `json:"usage"`
}

type ExtensionMetadata

type ExtensionMetadata struct {
	// Id is a unique identifier for the extension
	Id string `json:"id"`
	// Namespace is used to expose extension commands within a named group
	Namespace string `json:"namespace,omitempty"`
	// DisplayName is the name of the extension
	DisplayName string `json:"displayName"`
	// Description is a brief description of the extension
	Description string `json:"description"`
	// Versions is a list of versions of the extension that are released over time.
	Versions []ExtensionVersion `json:"versions"`
	// Source is used to store the extension source from where the extension is fetched
	Source string `json:"source,omitempty"`
	// Tags is a list of tags that can be used to filter extensions
	Tags []string `json:"tags,omitempty"`
	// Platforms is a map of platform specific metadata required for extensions
	Platforms map[string]map[string]any `json:"platforms,omitempty"`
}

Extension represents an extension in the registry

type ExtensionVersion

type ExtensionVersion struct {
	// Capabilities is a list of capabilities that the extension provides
	Capabilities []CapabilityType `json:"capabilities,omitempty"`
	// Version is the version of the extension
	Version string `json:"version"`
	// Usage is show how to use the extension
	Usage string `json:"usage"`
	// Examples is a list of examples for the extension
	Examples []ExtensionExample `json:"examples"`
	// Artifacts is a map of artifacts for the extension key on platform (os & architecture)
	Artifacts map[string]ExtensionArtifact `json:"artifacts,omitempty"`
	// Dependencies is a list of dependencies for the extension
	// An extension with dependencies and no artifacts is considered an extension pack.
	// The dependencies are resolved and installed when the extension pack is installed.
	Dependencies []ExtensionDependency `json:"dependencies,omitempty"`
	// Entry point is the entry point for the extension
	// This will typically be the name of the executable or script to run
	EntryPoint string `json:"entryPoint,omitempty"`
}

ExtensionVersion represents a version of an extension

type FilterOptions

type FilterOptions struct {
	// Version is used to specify the version of the extension to install
	Version string
	// Source is used to specify the source of the extension to install
	Source string
}

FilterOptions is used to filter extensions by version and source

type InvokeOptions

type InvokeOptions struct {
	Args   []string
	Env    []string
	StdIn  io.Reader
	StdOut io.Writer
	StdErr io.Writer
}

type ListOptions

type ListOptions struct {
	// Source is used to specify the source of the extension to install
	Source string
	// Tags is used to specify the tags of the extension to install
	Tags []string
}

ListOptions is used to filter extensions by source and tags

type LookupOptions

type LookupOptions struct {
	// Id is used to specify the id of the extension to install
	Id string
	// Namespace is used to specify the namespace of the extension to install
	Namespace string
}

LookupOptions is used to lookup extensions by id or namespace

type Manager

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

Manager is responsible for managing extensions

func NewManager

func NewManager(
	configManager config.UserConfigManager,
	sourceManager *SourceManager,
	transport policy.Transporter,
) (*Manager, error)

NewManager creates a new extension manager

func (*Manager) GetFromRegistry

func (m *Manager) GetFromRegistry(
	ctx context.Context,
	extensionId string,
	options *FilterOptions,
) (*ExtensionMetadata, error)

GetFromRegistry retrieves an extension from the registry by name

func (*Manager) GetInstalled

func (m *Manager) GetInstalled(options LookupOptions) (*Extension, error)

GetInstalled retrieves an installed extension by name

func (*Manager) Install

func (m *Manager) Install(ctx context.Context, id string, options *FilterOptions) (*ExtensionVersion, error)

Install an extension by name and optional version If no version is provided, the latest version is installed Latest version is determined by the last element in the Versions slice

func (*Manager) ListFromRegistry

func (m *Manager) ListFromRegistry(ctx context.Context, options *ListOptions) ([]*ExtensionMetadata, error)

func (*Manager) ListInstalled

func (m *Manager) ListInstalled() (map[string]*Extension, error)

ListInstalled retrieves a list of installed extensions

func (*Manager) Uninstall

func (m *Manager) Uninstall(id string) error

Uninstall an extension by name

func (*Manager) Upgrade

func (m *Manager) Upgrade(ctx context.Context, extensionId string, options *FilterOptions) (*ExtensionVersion, error)

Upgrade upgrades the extension to the specified version This is a convenience method that uninstalls the existing extension and installs the new version If the version is not specified, the latest version is installed

type Registry

type Registry struct {
	// Extensions is a list of extensions in the registry
	Extensions []*ExtensionMetadata `json:"extensions"`
}

Registry represents the registry.json structure

type Runner

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

func NewRunner

func NewRunner(commandRunner exec.CommandRunner) *Runner

func (*Runner) Invoke

func (r *Runner) Invoke(ctx context.Context, extension *Extension, options *InvokeOptions) (*exec.RunResult, error)

Invoke runs the extension with the provided arguments

type Source

type Source interface {
	// Name returns the name of the source.
	Name() string
	// ListExtensions returns a list of AZD compatible templates.
	ListExtensions(ctx context.Context) ([]*ExtensionMetadata, error)
	// GetExtension returns a template by path.
	GetExtension(ctx context.Context, extensionId string) (*ExtensionMetadata, error)
}

type SourceConfig

type SourceConfig struct {
	Name     string     `json:"name,omitempty"`
	Type     SourceKind `json:"type,omitempty"`
	Location string     `json:"location,omitempty"`
}

SourceConfig represents the configuration for an extension source.

type SourceKind

type SourceKind string

SourceKind represents the type of extension source.

const (
	SourceKindFile SourceKind = "file"
	SourceKindUrl  SourceKind = "url"
)

type SourceManager

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

SourceManager manages extension sources.

func NewSourceManager

func NewSourceManager(
	serviceLocator ioc.ServiceLocator,
	configManager config.UserConfigManager,
	transport policy.Transporter,
) *SourceManager

func (*SourceManager) Add

func (sm *SourceManager) Add(ctx context.Context, name string, source *SourceConfig) error

Add adds a new extension source.

func (*SourceManager) CreateSource

func (sm *SourceManager) CreateSource(ctx context.Context, config *SourceConfig) (Source, error)

Source returns a hydrated extension source for the current config.

func (*SourceManager) Get

func (sm *SourceManager) Get(ctx context.Context, name string) (*SourceConfig, error)

Get returns an extension source by name.

func (*SourceManager) List

func (sm *SourceManager) List(ctx context.Context) ([]*SourceConfig, error)

List returns a list of extension sources.

func (*SourceManager) Remove

func (sm *SourceManager) Remove(ctx context.Context, name string) error

Remove removes an extension source.

Jump to

Keyboard shortcuts

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