extension

package
v2.60.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 47 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SeverityError   = "error"
	SeverityWarning = "warning"
	SeverityInfo    = "info"
)

Finding severities

View Source
const (
	CheckManifest = "manifest"
	CheckBinary   = "binary"
	CheckFlags    = "flags"
	CheckCommands = "commands"
	CheckAPI      = "api"
	CheckScripts  = "scripts"
	CheckName     = "name"
)

Validation checks

Variables

View Source
var ErrArchiveTooLarge = errors.New("archive exceeds the maximum extracted size")

ErrArchiveTooLarge is returned if the extracted files exceed maxExtractedSize

View Source
var ErrChecksumMismatch = errors.New("checksum mismatch")

ErrChecksumMismatch is returned when the downloaded asset does not match the published checksum

View Source
var ErrCommitNotFound = errors.New("commit not found")
View Source
var ErrInvalidRepositoryName = errors.New("invalid extension repository name")

ErrInvalidRepositoryName is returned if the extension name is taken from the repository name, which doesn't have the c8y- prefix

View Source
var ErrLocalExtensionUpgrade = errors.New("local extensions can not be updated")
View Source
var ErrNoExtensionsInstalled = errors.New("no extensions installed")
View Source
var ErrNoPlatformAsset = errors.New("the release does not have an asset for this platform")
View Source
var ErrPinnedExtensionUpgrade = errors.New("pinned extensions can not be updated")
View Source
var ErrReleaseNotFound = errors.New("release not found")
View Source
var ErrRepositoryNotFound = errors.New("repository not found")
View Source
var ErrSystemExtensionUpgrade = errors.New("extensions in a system extensions folder can only be updated by the package manager which installed them")
View Source
var ErrUpToDate = errors.New("already up to date")
View Source
var ExtPrefix = "c8y-"

Functions

func CountFindings added in v2.57.0

func CountFindings(findings []Finding) (errorCount int, warningCount int)

CountFindings returns the number of errors and warnings

func ExtSDKVersion added in v2.57.0

func ExtSDKVersion() string

ExtSDKVersion returns the version of the extension Go SDK used by the Go template

func HandleHTTPError

func HandleHTTPError(resp *http.Response) error

func NewCmdExtension

func NewCmdExtension(f *cmdutil.Factory) *cobra.Command

func RESTPrefix

func RESTPrefix(hostname string) string

Types

type AliasCollection

type AliasCollection struct {
	Name    string
	Aliases []extensions.Alias
}

type AliasExtension

type AliasExtension struct {
	Source      string `json:"-" yaml:"-"`
	Name        string `json:"name,omitempty" yaml:"name,omitempty"`
	Command     string `json:"command,omitempty" yaml:"command,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	Shell       bool   `json:"shell" yaml:"shell"`
}

func (*AliasExtension) GetCommand

func (a *AliasExtension) GetCommand() string

func (*AliasExtension) GetDescription

func (a *AliasExtension) GetDescription() string

func (*AliasExtension) GetName

func (a *AliasExtension) GetName() string

func (*AliasExtension) IsShell

func (a *AliasExtension) IsShell() bool

type Command

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

func (*Command) Command

func (c *Command) Command() string

func (*Command) Description

func (c *Command) Description() string

func (*Command) Name

func (c *Command) Name() string

type Extension

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

func (*Extension) Aliases

func (e *Extension) Aliases() ([]extensions.Alias, error)

Custom extension components

func (*Extension) Commands

func (e *Extension) Commands() ([]extensions.Command, error)

func (*Extension) CurrentVersion

func (e *Extension) CurrentVersion() string

func (*Extension) Executable added in v2.57.0

func (e *Extension) Executable() string

Executable returns the absolute path to the binary declared in the extension manifest. It returns an empty string if no binary is declared

func (*Extension) IsBinary

func (e *Extension) IsBinary() bool

IsBinary returns true if the extension was installed from a binary release

func (*Extension) IsLocal

func (e *Extension) IsLocal() bool

func (*Extension) IsPinned

func (e *Extension) IsPinned() bool

func (*Extension) Kind added in v2.57.0

func (e *Extension) Kind() extensions.Kind

Kind returns how the extension was installed

func (*Extension) Manifest added in v2.57.0

func (e *Extension) Manifest() (*extensions.Manifest, error)

Manifest returns the parsed extension manifest (extension.yaml)

func (*Extension) Name

func (e *Extension) Name() string

func (*Extension) Path

func (e *Extension) Path() string

func (*Extension) TemplatePath

func (e *Extension) TemplatePath() string

func (*Extension) URL

func (e *Extension) URL() string

func (*Extension) UpdateAvailable

func (e *Extension) UpdateAvailable() bool

func (*Extension) ViewPath

func (e *Extension) ViewPath() string

type ExtensionFile

type ExtensionFile struct {
	extensions.Manifest `yaml:",inline"`
	Aliases             []AliasExtension `json:"aliases,omitempty" yaml:"aliases,omitempty"`
}

ExtensionFile is the extension manifest (extension.yaml)

type ExtensionItemCollection

type ExtensionItemCollection struct {
	Items []ExtensionSource
}

func NewExtensionItemCollection

func NewExtensionItemCollection() *ExtensionItemCollection

func (*ExtensionItemCollection) Add

func (t *ExtensionItemCollection) Add(name string, paths []string)

func (*ExtensionItemCollection) AddSources

func (t *ExtensionItemCollection) AddSources(sources []ExtensionSource)

type ExtensionKind

type ExtensionKind int
const (
	GitKind ExtensionKind = iota
	BinaryKind
)

type ExtensionSource

type ExtensionSource struct {
	Name  string
	Paths []string
}

type Finding added in v2.57.0

type Finding struct {
	Severity string `json:"severity"`
	Check    string `json:"check"`
	Location string `json:"location"`
	Message  string `json:"message"`
}

Finding is a problem found when validating an extension

func ValidateExtension added in v2.57.0

func ValidateExtension(ext extensions.Extension, opts ValidateOptions) []Finding

ValidateExtension checks an extension for problems and returns the findings, sorted by severity

type Manager

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

func NewManager

func NewManager(ios *iostreams.IOStreams, cfg *config.Config) *Manager

func (*Manager) Create

func (m *Manager) Create(name string, tmplType extensions.ExtTemplateType) error

func (*Manager) EnableDryRunMode

func (m *Manager) EnableDryRunMode()

func (*Manager) Execute

func (m *Manager) Execute(opts extensions.ExecOptions) error

Execute runs an extension executable. Scripts are run via sh on Windows to support shebang lines

func (*Manager) Install

func (m *Manager) Install(repo ghrepo.Interface, opts extensions.InstallOptions) (string, error)

Install installs an extension from repo, and pins to a release tag or commit hash if provided. GitHub repositories which publish release assets for the current platform are installed as binary extensions, all others are installed using git clone

func (*Manager) InstallLocal

func (m *Manager) InstallLocal(dir string, opts extensions.InstallOptions) (string, error)

func (*Manager) List

func (m *Manager) List() []extensions.Extension

func (*Manager) Remove

func (m *Manager) Remove(name string) error

func (*Manager) SetClient

func (m *Manager) SetClient(client *http.Client)

func (*Manager) SetConfig

func (m *Manager) SetConfig(cfg config.Config)

func (*Manager) Upgrade

func (m *Manager) Upgrade(name string, force bool) error

type ValidateOptions added in v2.57.0

type ValidateOptions struct {
	// GlobalFlags are the c8y global flags (persistent flags of the root command). The flag check
	// is skipped if nil
	GlobalFlags *pflag.FlagSet

	// SkipFlagCheck skips the flag check, which runs the extension's binary
	SkipFlagCheck bool

	// GOOS is the operating system to validate for. Defaults to runtime.GOOS
	GOOS string

	// CompleteTimeout is the maximum duration to wait for the binary to list its flags
	CompleteTimeout time.Duration

	// RootCommand is the c8y root command, used to check that the name is not a built-in
	// command. The check is skipped if nil
	RootCommand *cobra.Command

	// Installed is true if the extension is installed (and not a folder being developed), so its
	// installed name can be compared with the declared name
	Installed bool
}

ValidateOptions controls the validation of an extension

Jump to

Keyboard shortcuts

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