Documentation
¶
Index ¶
- Constants
- Variables
- func CountFindings(findings []Finding) (errorCount int, warningCount int)
- func ExtSDKVersion() string
- func HandleHTTPError(resp *http.Response) error
- func NewCmdExtension(f *cmdutil.Factory) *cobra.Command
- func RESTPrefix(hostname string) string
- type AliasCollection
- type AliasExtension
- type Command
- type Extension
- func (e *Extension) Aliases() ([]extensions.Alias, error)
- func (e *Extension) Commands() ([]extensions.Command, error)
- func (e *Extension) CurrentVersion() string
- func (e *Extension) Executable() string
- func (e *Extension) IsBinary() bool
- func (e *Extension) IsLocal() bool
- func (e *Extension) IsPinned() bool
- func (e *Extension) Kind() extensions.Kind
- func (e *Extension) Manifest() (*extensions.Manifest, error)
- func (e *Extension) Name() string
- func (e *Extension) Path() string
- func (e *Extension) TemplatePath() string
- func (e *Extension) URL() string
- func (e *Extension) UpdateAvailable() bool
- func (e *Extension) ViewPath() string
- type ExtensionFile
- type ExtensionItemCollection
- type ExtensionKind
- type ExtensionSource
- type Finding
- type Manager
- func (m *Manager) Create(name string, tmplType extensions.ExtTemplateType) error
- func (m *Manager) EnableDryRunMode()
- func (m *Manager) Execute(opts extensions.ExecOptions) error
- func (m *Manager) Install(repo ghrepo.Interface, opts extensions.InstallOptions) (string, error)
- func (m *Manager) InstallLocal(dir string, opts extensions.InstallOptions) (string, error)
- func (m *Manager) List() []extensions.Extension
- func (m *Manager) Remove(name string) error
- func (m *Manager) SetClient(client *http.Client)
- func (m *Manager) SetConfig(cfg config.Config)
- func (m *Manager) Upgrade(name string, force bool) error
- type ValidateOptions
Constants ¶
const ( SeverityError = "error" SeverityWarning = "warning" SeverityInfo = "info" )
Finding severities
const ( CheckManifest = "manifest" CheckBinary = "binary" CheckFlags = "flags" CheckCommands = "commands" CheckAPI = "api" CheckScripts = "scripts" CheckName = "name" )
Validation checks
Variables ¶
var ErrArchiveTooLarge = errors.New("archive exceeds the maximum extracted size")
ErrArchiveTooLarge is returned if the extracted files exceed maxExtractedSize
var ErrChecksumMismatch = errors.New("checksum mismatch")
ErrChecksumMismatch is returned when the downloaded asset does not match the published checksum
var ErrCommitNotFound = errors.New("commit not found")
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
var ErrLocalExtensionUpgrade = errors.New("local extensions can not be updated")
var ErrNoExtensionsInstalled = errors.New("no extensions installed")
var ErrNoPlatformAsset = errors.New("the release does not have an asset for this platform")
var ErrPinnedExtensionUpgrade = errors.New("pinned extensions can not be updated")
var ErrReleaseNotFound = errors.New("release not found")
var ErrRepositoryNotFound = errors.New("repository not found")
var ErrSystemExtensionUpgrade = errors.New("extensions in a system extensions folder can only be updated by the package manager which installed them")
var ErrUpToDate = errors.New("already up to date")
var ExtPrefix = "c8y-"
Functions ¶
func CountFindings ¶ added in v2.57.0
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 RESTPrefix ¶
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) Description ¶
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) CurrentVersion ¶
func (*Extension) Executable ¶ added in v2.57.0
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 ¶
IsBinary returns true if the extension was installed from a binary release
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) TemplatePath ¶
func (*Extension) UpdateAvailable ¶
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 ExtensionSource ¶
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 (*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
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