extensions

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceTypeLocalPath          = "local_path"
	SourceTypeGitHubSource       = "github_source"
	SourceTypeGitHubReleaseAsset = "github_release_asset"
)
View Source
const (
	ManifestFileName = "kongctl-extension.yaml"
	ManifestSchemaV1 = 1
	MaxManifestBytes = 256 * 1024
)
View Source
const (
	ContextEnvName    = "KONGCTL_EXTENSION_CONTEXT"
	KonnectPATEnvName = "KONGCTL_EXTENSION_KONNECT_PAT" // #nosec G101
	MaxDepth          = 5
)

Variables

This section is empty.

Functions

func CommandPathNames

func CommandPathNames(path CommandPath) []string

func CommandPathString

func CommandPathString(path CommandPath) string

func ContributionID

func ContributionID(extensionID string, path CommandPath) string

func EnsureCompatible

func EnsureCompatible(manifest Manifest, cliVersion string) error

func ExtensionID

func ExtensionID(publisher, name string) string

func IsClosedBuiltInRoot

func IsClosedBuiltInRoot(name string) bool

func IsOpenBuiltInRoot

func IsOpenBuiltInRoot(name string) bool

func NormalizeAndValidateManifest

func NormalizeAndValidateManifest(manifest *Manifest) error

func PrintExtensionHelp

func PrintExtensionHelp(w io.Writer, extensionID string, contribution CommandPath) error

func RegisterCommands

func RegisterCommands(root *cobra.Command, store Store, extensions []Extension) error

func RegisterInstalledCommands

func RegisterInstalledCommands(root *cobra.Command, store Store) error

func ResolveRuntime

func ResolveRuntime(root, command string) (string, error)

func SplitExtensionID

func SplitExtensionID(id string) (string, string, error)

func ValidateCompatibility

func ValidateCompatibility(compatibility Compatibility) error

func ValidateExtensionCommands

func ValidateExtensionCommands(root *cobra.Command, ext Extension) error

func ValidateExtensionID

func ValidateExtensionID(id string) error

func ValidateIdentitySegment

func ValidateIdentitySegment(field, value string) error

func ValidateRuntimeCommand

func ValidateRuntimeCommand(command string) error

Types

type Argument

type Argument struct {
	Name        string `json:"name"                  yaml:"name"`
	Required    bool   `json:"required,omitempty"    yaml:"required,omitempty"`
	Repeatable  bool   `json:"repeatable,omitempty"  yaml:"repeatable,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

type CommandCache

type CommandCache struct {
	SchemaVersion int           `json:"schema_version"`
	ID            string        `json:"id"`
	GeneratedAt   string        `json:"generated_at"`
	InstallType   InstallType   `json:"install_type"`
	Manifest      Manifest      `json:"manifest"`
	CommandPaths  []CommandPath `json:"command_paths"`
}

type CommandPath

type CommandPath struct {
	ID          string        `json:"id"                    yaml:"id,omitempty"`
	Path        []PathSegment `json:"path"                  yaml:"path"`
	Summary     string        `json:"summary,omitempty"     yaml:"summary,omitempty"`
	Description string        `json:"description,omitempty" yaml:"description,omitempty"`
	Usage       string        `json:"usage,omitempty"       yaml:"usage,omitempty"`
	Examples    []string      `json:"examples,omitempty"    yaml:"examples,omitempty"`
	Args        []Argument    `json:"args,omitempty"        yaml:"args,omitempty"`
	Flags       []Flag        `json:"flags,omitempty"       yaml:"flags,omitempty"`
}

type Compatibility

type Compatibility struct {
	MinVersion string `json:"min_version,omitempty" yaml:"min_version,omitempty"`
	MaxVersion string `json:"max_version,omitempty" yaml:"max_version,omitempty"`
}

type CompatibilityResult

type CompatibilityResult struct {
	Compatible     bool
	Unknown        bool
	CurrentVersion string
	Constraint     string
}

func CheckCompatibility

func CheckCompatibility(manifest Manifest, cliVersion string) (CompatibilityResult, error)

type Extension

type Extension struct {
	ID           string        `json:"id"`
	InstallType  InstallType   `json:"install_type"`
	Manifest     Manifest      `json:"manifest"`
	CommandPaths []CommandPath `json:"command_paths"`
	PackageDir   string        `json:"package_dir,omitempty"`
	LinkedDir    string        `json:"linked_dir,omitempty"`
	Install      *InstallState `json:"install,omitempty"`
	Link         *LinkState    `json:"link,omitempty"`
}

func LoadLocalExtension

func LoadLocalExtension(source string, installType InstallType) (Extension, error)

type FetchedGitHubSource

type FetchedGitHubSource struct {
	SourceType     string
	Dir            string
	Repository     string
	URL            string
	Ref            string
	ResolvedCommit string
	ReleaseTag     string
	AssetName      string
	AssetURL       string
	Cleanup        func()
}

func FetchGitHubReleaseAsset

func FetchGitHubReleaseAsset(ctx context.Context, source GitHubSource, tempRoot string) (FetchedGitHubSource, error)

func FetchGitHubSource

func FetchGitHubSource(ctx context.Context, source GitHubSource, tempRoot string) (FetchedGitHubSource, error)

func FetchGitHubSourceClone

func FetchGitHubSourceClone(ctx context.Context, source GitHubSource, tempRoot string) (FetchedGitHubSource, error)

type Flag

type Flag struct {
	Name        string `json:"name"                  yaml:"name"`
	Type        string `json:"type,omitempty"        yaml:"type,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

type GitHubSource

type GitHubSource struct {
	Owner string
	Repo  string
	Ref   string
}

func ParseGitHubSource

func ParseGitHubSource(source, ref string) (GitHubSource, bool, error)

func (GitHubSource) CloneURL

func (s GitHubSource) CloneURL() string

func (GitHubSource) Repository

func (s GitHubSource) Repository() string

func (GitHubSource) RepositoryURL

func (s GitHubSource) RepositoryURL() string

type HostContext

type HostContext struct {
	KongctlPath    string `json:"kongctl_path"`
	KongctlVersion string `json:"kongctl_version"`
}

type InstallResult

type InstallResult struct {
	Extension    Extension `json:"extension"`
	ManifestHash string    `json:"manifest_hash"`
	RuntimeHash  string    `json:"runtime_hash"`
	PackageHash  string    `json:"package_hash"`
}

type InstallState

type InstallState struct {
	SchemaVersion  int          `json:"schema_version"`
	ID             string       `json:"id"`
	InstalledAt    string       `json:"installed_at"`
	CLIVersion     string       `json:"cli_version"`
	Source         SourceState  `json:"source"`
	ManifestHash   string       `json:"manifest_hash"`
	RuntimeHash    string       `json:"runtime_hash"`
	PackageHash    string       `json:"package_hash,omitempty"`
	RuntimeCommand string       `json:"runtime_command"`
	Trust          TrustState   `json:"trust"`
	Upgrade        UpgradeState `json:"upgrade"`
}

type InstallType

type InstallType string
const (
	InstallTypeInstalled InstallType = "installed"
	InstallTypeLinked    InstallType = "linked"
)

type InvocationContext

type InvocationContext struct {
	OriginalArgs  []string `json:"original_args"`
	RemainingArgs []string `json:"remaining_args"`
}

type JQContext

type JQContext struct {
	Expression string `json:"expression,omitempty"`
	RawOutput  bool   `json:"raw_output,omitempty"`
	Color      string `json:"color,omitempty"`
	ColorTheme string `json:"color_theme,omitempty"`
}

type LinkState

type LinkState struct {
	SchemaVersion  int    `json:"schema_version"`
	ID             string `json:"id"`
	LinkedAt       string `json:"linked_at"`
	CLIVersion     string `json:"cli_version"`
	Path           string `json:"path"`
	RuntimeCommand string `json:"runtime_command"`
}

type Manifest

type Manifest struct {
	SchemaVersion int           `json:"schema_version" yaml:"schema_version"`
	Publisher     string        `json:"publisher"      yaml:"publisher"`
	Name          string        `json:"name"           yaml:"name"`
	Version       string        `json:"version,omitempty" yaml:"version,omitempty"`
	Summary       string        `json:"summary,omitempty" yaml:"summary,omitempty"`
	Runtime       Runtime       `json:"runtime"        yaml:"runtime"`
	Compatibility Compatibility `json:"compatibility" yaml:"compatibility,omitempty"`
	CommandPaths  []CommandPath `json:"command_paths" yaml:"command_paths"`
}

func LoadManifestFile

func LoadManifestFile(path string) (Manifest, []byte, error)

func ParseManifest

func ParseManifest(data []byte) (Manifest, error)

type MatchedCommandPath

type MatchedCommandPath struct {
	ID          string   `json:"id"`
	ExtensionID string   `json:"extension_id"`
	Path        []string `json:"path"`
}

type OutputContext

type OutputContext struct {
	Format     string    `json:"format"`
	ColorTheme string    `json:"color_theme,omitempty"`
	JQ         JQContext `json:"jq,omitempty"`
}

type PackageObservation

type PackageObservation struct {
	Manifest       Manifest `json:"manifest"`
	ManifestHash   string   `json:"manifest_hash"`
	RuntimeHash    string   `json:"runtime_hash"`
	PackageHash    string   `json:"package_hash"`
	RuntimeCommand string   `json:"runtime_command"`
}

PackageObservation captures the observable package identity shown before a remote executable extension is trusted.

func ObservePackage

func ObservePackage(sourceRoot string) (PackageObservation, error)

ObservePackage computes package identity and integrity hashes without modifying managed extension state.

type PathSegment

type PathSegment struct {
	Name    string   `json:"name"              yaml:"name"`
	Aliases []string `json:"aliases,omitempty" yaml:"aliases,omitempty"`
}

type ResolvedContext

type ResolvedContext struct {
	Profile          string `json:"profile"`
	BaseURL          string `json:"base_url"`
	Output           string `json:"output"`
	LogLevel         string `json:"log_level"`
	ColorTheme       string `json:"color_theme,omitempty"`
	ConfigFile       string `json:"config_file"`
	ExtensionDataDir string `json:"extension_data_dir"`
	AuthMode         string `json:"auth_mode"`
	AuthSource       string `json:"auth_source"`
}

type Runtime

type Runtime struct {
	Command string `json:"command" yaml:"command"`
}

type RuntimeContext

type RuntimeContext struct {
	SchemaVersion      int                `json:"schema_version"`
	MatchedCommandPath MatchedCommandPath `json:"matched_command_path"`
	Invocation         InvocationContext  `json:"invocation"`
	Resolved           ResolvedContext    `json:"resolved"`
	Output             OutputContext      `json:"output"`
	Host               HostContext        `json:"host"`
	Session            SessionContext     `json:"session"`
}

func LoadRuntimeContextFromEnv

func LoadRuntimeContextFromEnv() (*RuntimeContext, error)

type SessionContext

type SessionContext struct {
	ID                string   `json:"id"`
	ContributionStack []string `json:"contribution_stack"`
	Depth             int      `json:"depth"`
	MaxDepth          int      `json:"max_depth"`
}

type SourceState

type SourceState struct {
	Type           string `json:"type"`
	Path           string `json:"path,omitempty"`
	Repository     string `json:"repository,omitempty"`
	URL            string `json:"url,omitempty"`
	Ref            string `json:"ref,omitempty"`
	ResolvedCommit string `json:"resolved_commit,omitempty"`
	ReleaseTag     string `json:"release_tag,omitempty"`
	AssetName      string `json:"asset_name,omitempty"`
	AssetURL       string `json:"asset_url,omitempty"`
}

type SplitArgsResult

type SplitArgsResult struct {
	Remaining       []string
	ProfileOverride string
	ShowHelp        bool
}

func SplitExtensionArgs

func SplitExtensionArgs(command *cobra.Command, args []string, cfg config.Hook) (SplitArgsResult, error)

type Store

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

func DefaultStore

func DefaultStore() (Store, error)

func NewStore

func NewStore(root string) Store

func (Store) DataDir

func (s Store) DataDir(id string) (string, error)

func (Store) Dispatch

func (s Store) Dispatch(
	ctx context.Context,
	streams *iostreams.IOStreams,
	cfg config.Hook,
	buildInfo *build.Info,
	ext Extension,
	contribution CommandPath,
	originalArgs []string,
	remainingArgs []string,
	profileOverride string,
) error

func (Store) Get

func (s Store) Get(id string) (Extension, error)

func (Store) InstallGitHubSource

func (s Store) InstallGitHubSource(
	sourceRoot string,
	fetched FetchedGitHubSource,
	cliVersion string,
	now time.Time,
	trustConfirmed bool,
) (InstallResult, error)

func (Store) InstallLocal

func (s Store) InstallLocal(source, cliVersion string, now time.Time) (InstallResult, error)

func (Store) LinkLocal

func (s Store) LinkLocal(source, cliVersion string, now time.Time) (Extension, error)

func (Store) List

func (s Store) List() ([]Extension, error)

func (Store) ResolveRuntime

func (s Store) ResolveRuntime(ext Extension) (string, error)

func (Store) Root

func (s Store) Root() string

func (Store) RuntimeDir

func (s Store) RuntimeDir() string

func (Store) TempDir

func (s Store) TempDir() string

func (Store) Uninstall

func (s Store) Uninstall(id string, removeData bool) (UninstallResult, error)

func (Store) VerifyInstalledRuntime

func (s Store) VerifyInstalledRuntime(ext Extension) (string, error)

type TrustState

type TrustState struct {
	Confirmed bool   `json:"confirmed"`
	Model     string `json:"model"`
}

type UninstallResult

type UninstallResult struct {
	ID             string `json:"id"`
	RemovedInstall bool   `json:"removed_install"`
	RemovedLink    bool   `json:"removed_link"`
	RemovedData    bool   `json:"removed_data"`
}

type UpgradeState

type UpgradeState struct {
	Policy string `json:"policy"`
}

Jump to

Keyboard shortcuts

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