discovery

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package discovery is implements discovery interface for plugin discovery Discovery is the interface to fetch the list of available plugins, their supported versions and how to download them either stand-alone or scoped to a server. A separate interface for discovery helps to decouple discovery (which is usually tied to a server or user identity) from distribution (which can be shared).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDiscoveryName

func CheckDiscoveryName(ds configtypes.PluginDiscovery, dn string) bool

CheckDiscoveryName returns true if discovery name exists else return false

func CompareDiscoverySource

func CompareDiscoverySource(ds1, ds2 configtypes.PluginDiscovery, dsType string) bool

CompareDiscoverySource returns true if both discovery source are same for the given type

func RefreshDatabase added in v1.2.0

func RefreshDatabase() error

RefreshDatabase function refreshes the plugin inventory database if the digest timestamp is past 24 hours

func UpdateArtifactsBasedOnImageRepositoryOverride

func UpdateArtifactsBasedOnImageRepositoryOverride(p *cliv1alpha1.CLIPlugin, imageRepoOverride map[string]string)

UpdateArtifactsBasedOnImageRepositoryOverride updates artifacts based on image repository override

Types

type DBBackedOCIDiscovery

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

DBBackedOCIDiscovery is an artifact discovery utilizing an OCI image which contains an SQLite database describing the content of the plugin discovery.

func (*DBBackedOCIDiscovery) GetGroups added in v0.90.0

func (od *DBBackedOCIDiscovery) GetGroups() ([]*plugininventory.PluginGroup, error)

GetGroups is a method of the DBBackedOCIDiscovery struct that retrieves the plugin groups defined in the discovery. It returns a slice of PluginGroup pointers and an error if any occurs during the process.

func (*DBBackedOCIDiscovery) List

func (od *DBBackedOCIDiscovery) List() ([]Discovered, error)

List is a method of the DBBackedOCIDiscovery struct that retrieves the available plugins. It returns a slice of Discovered interfaces and an error if any occurs during the process.

func (*DBBackedOCIDiscovery) Name

func (od *DBBackedOCIDiscovery) Name() string

Name of the discovery.

func (*DBBackedOCIDiscovery) Type

func (od *DBBackedOCIDiscovery) Type() string

Type of the discovery.

type Discovered

type Discovered struct {
	// Description is the plugin's description.
	Name string

	// Description is the plugin's description.
	Description string

	// RecommendedVersion is the version that Tanzu CLI should use if available.
	// The value should be a valid semantic version as defined in
	// https://semver.org/. E.g., 2.0.1
	RecommendedVersion string

	// InstalledVersion is the version that Tanzu CLI should use if available.
	// The value should be a valid semantic version as defined in
	// https://semver.org/. E.g., 2.0.1
	InstalledVersion string

	// SupportedVersions determines the list of supported CLI plugin versions.
	// The values are sorted in the semver prescribed order as defined in
	// https://github.com/Masterminds/semver#sorting-semantic-versions.
	SupportedVersions []string

	// Distribution is an interface to download a single plugin binary.
	Distribution distribution.Distribution

	// Optional specifies whether the plugin is mandatory or optional
	// If optional, the plugin will not get auto-downloaded as part of
	// `tanzu login` or `tanzu plugin sync` command
	// To view the list of plugin, user can use `tanzu plugin list` and
	// to download a specific plugin run, `tanzu plugin install <plugin-name>`
	Optional bool

	// Scope is the context association level of the plugin.
	Scope string

	// Source is the name of the discovery source from where the plugin was
	// discovered.
	Source string

	// ContextName is the name of the context from where the plugin was discovered.
	ContextName string

	// DiscoveryType defines the type of the discovery. Possible values are
	// oci, local or kubernetes
	DiscoveryType string

	// Target defines the target to which this plugin is applicable to
	Target configtypes.Target

	// Status is the installed/uninstalled status of the plugin.
	Status string
}

Discovered defines discovered plugin resource

func DiscoveredFromK8sV1alpha1

func DiscoveredFromK8sV1alpha1(p *cliv1alpha1.CLIPlugin) (Discovered, error)

DiscoveredFromK8sV1alpha1 returns discovered plugin object from k8sV1alpha1

func DiscoveredFromK8sV1alpha1WithImageRepositoryOverride

func DiscoveredFromK8sV1alpha1WithImageRepositoryOverride(p *cliv1alpha1.CLIPlugin, imageRepoOverride map[string]string) (Discovered, error)

DiscoveredFromK8sV1alpha1WithImageRepositoryOverride returns discovered plugin object from k8sV1alpha1

func DiscoveredFromREST

func DiscoveredFromREST(p *Plugin) (Discovered, error)

DiscoveredFromREST returns discovered plugin object from a REST API.

type DiscoveredSorter

type DiscoveredSorter []Discovered

DiscoveredSorter sorts discovered objects.

func (DiscoveredSorter) Len

func (d DiscoveredSorter) Len() int

func (DiscoveredSorter) Less

func (d DiscoveredSorter) Less(i, j int) bool

func (DiscoveredSorter) Swap

func (d DiscoveredSorter) Swap(i, j int)

type Discovery

type Discovery interface {
	// Name of the repository.
	Name() string

	// List available plugins.
	List() ([]Discovered, error)

	// Type returns type of discovery.
	Type() string
}

Discovery is the interface to fetch the list of available plugins

func CreateDiscoveryFromV1alpha1

func CreateDiscoveryFromV1alpha1(pd configtypes.PluginDiscovery, options ...DiscoveryOptions) (Discovery, error)

CreateDiscoveryFromV1alpha1 creates discovery interface from v1alpha1 API

func NewKubernetesDiscovery

func NewKubernetesDiscovery(name, kubeconfigPath, kubecontext string, kubeconfigBytes []byte) Discovery

NewKubernetesDiscovery returns a new kubernetes repository

func NewLocalDiscovery

func NewLocalDiscovery(name, localPath string) Discovery

NewLocalDiscovery returns a new local repository. If provided localPath is not an absolute path search under `xdg.ConfigHome/tanzu-plugin/discovery` directory

func NewOCIDiscovery

func NewOCIDiscovery(name, image string, options ...DiscoveryOptions) Discovery

NewOCIDiscovery returns a new Discovery using the specified OCI image.

func NewRESTDiscovery

func NewRESTDiscovery(name, endpoint, basePath string) Discovery

NewRESTDiscovery returns a new kubernetes repository

type DiscoveryOptions added in v1.0.0

type DiscoveryOptions func(options *DiscoveryOpts)

func WithForceRefresh added in v1.2.0

func WithForceRefresh() DiscoveryOptions

WithForceRefresh used to force a refresh of the plugin inventory data even when the cache's TTL has not expired

func WithGroupDiscoveryCriteria added in v1.0.0

func WithGroupDiscoveryCriteria(criteria *GroupDiscoveryCriteria) DiscoveryOptions

WithGroupDiscoveryCriteria used to specify the group discovery criteria

func WithPluginDiscoveryCriteria added in v1.0.0

func WithPluginDiscoveryCriteria(criteria *PluginDiscoveryCriteria) DiscoveryOptions

WithPluginDiscoveryCriteria used to specify the plugin discovery criteria

func WithUseLocalCacheOnly added in v1.0.0

func WithUseLocalCacheOnly() DiscoveryOptions

WithUseLocalCacheOnly used to get the plugin inventory data without first refreshing the cache even if the cache's TTL has expired

type DiscoveryOpts added in v1.0.0

type DiscoveryOpts struct {
	UseLocalCacheOnly       bool // UseLocalCacheOnly used to pull the plugin data from the cache
	ForceRefresh            bool // ForceRefresh used to force a refresh of the plugin data
	PluginDiscoveryCriteria *PluginDiscoveryCriteria
	GroupDiscoveryCriteria  *GroupDiscoveryCriteria
}

DiscoveryOpts used to customize the plugin discovery process or mechanism

func NewDiscoveryOpts added in v1.0.0

func NewDiscoveryOpts() *DiscoveryOpts

type GroupDiscovery added in v0.0.4

type GroupDiscovery interface {
	// Name of the discovery
	Name() string

	// GetGroups returns the plugin groups defined in the discovery
	GetGroups() ([]*plugininventory.PluginGroup, error)
}

func CreateGroupDiscovery added in v0.90.0

func CreateGroupDiscovery(pd configtypes.PluginDiscovery, options ...DiscoveryOptions) (GroupDiscovery, error)

func NewOCIGroupDiscovery added in v0.90.0

func NewOCIGroupDiscovery(name, image string, options ...DiscoveryOptions) GroupDiscovery

NewOCIGroupDiscovery returns a new plugn group Discovery using the specified OCI image.

type GroupDiscoveryCriteria added in v0.90.0

type GroupDiscoveryCriteria struct {
	// Vendor of the group
	Vendor string
	// Publisher of the group
	Publisher string
	// Name of the group
	Name string
	// Version is the version for the group
	Version string
}

GroupDiscoveryCriteria provides criteria to look for plugin groups in a discovery.

type KubernetesDiscovery

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

KubernetesDiscovery is an artifact discovery utilizing CLIPlugin API in kubernetes cluster

func (*KubernetesDiscovery) GetDiscoveredPlugins

func (k *KubernetesDiscovery) GetDiscoveredPlugins(clusterClient cluster.Client) ([]Discovered, error)

GetDiscoveredPlugins returns the list of discovered plugin from a kubernetes cluster

func (*KubernetesDiscovery) List

func (k *KubernetesDiscovery) List() ([]Discovered, error)

List available plugins.

func (*KubernetesDiscovery) Manifest

func (k *KubernetesDiscovery) Manifest() ([]Discovered, error)

Manifest returns the manifest for a kubernetes repository.

func (*KubernetesDiscovery) Name

func (k *KubernetesDiscovery) Name() string

Name of the repository.

func (*KubernetesDiscovery) Type

func (k *KubernetesDiscovery) Type() string

Type of the repository.

type ListPluginsResponse

type ListPluginsResponse struct {
	Plugins []Plugin `json:"plugins"`
}

ListPluginsResponse defines the response from List Plugins API.

type LocalDiscovery

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

LocalDiscovery is an artifact discovery endpoint utilizing a local host os.

func (*LocalDiscovery) List

func (l *LocalDiscovery) List() ([]Discovered, error)

List available plugins.

func (*LocalDiscovery) Manifest

func (l *LocalDiscovery) Manifest() ([]Discovered, error)

Manifest returns the manifest for a local repository.

func (*LocalDiscovery) Name

func (l *LocalDiscovery) Name() string

Name of the repository.

func (*LocalDiscovery) Type

func (l *LocalDiscovery) Type() string

Type of the repository.

type Plugin

type Plugin struct {
	// Name of the plugin.
	Name string `json:"name"`

	// Description is the plugin's description.
	Description string `json:"description"`

	// Recommended version that Tanzu CLI should use if available.
	// The value should be a valid semantic version as defined in
	// https://semver.org/. E.g., 2.0.1
	RecommendedVersion string `json:"recommendedVersion"`

	// Artifacts contains an artifact list for every supported version.
	Artifacts map[string]cliv1alpha1.ArtifactList `json:"artifacts"`

	// Optional specifies whether the plugin is mandatory or optional
	// If optional, the plugin will not get auto-downloaded as part of
	// `tanzu login` or `tanzu plugin sync` command
	// To view the list of plugin, user can use `tanzu plugin list` and
	// to download a specific plugin run, `tanzu plugin install <plugin-name>`
	Optional bool `json:"optional"`

	// Target the target of the plugin
	Target configtypes.Target `json:"target"`
}

Plugin contains information about a Tanzu CLI plugin discovered via a REST API.

type PluginDiscoveryCriteria added in v0.0.4

type PluginDiscoveryCriteria struct {
	// Name is the name of the plugin
	Name string
	// Target is the target of the plugin
	Target configtypes.Target
	// Version is the version for the plugin
	Version string
	// OS of the plugin binary in `GOOS` format.
	OS string
	// Arch of the plugin binary in `GOARCH` format.
	Arch string
}

PluginDiscoveryCriteria provides criteria to look for plugins in a discovery.

type RESTDiscovery

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

RESTDiscovery is an artifact discovery utilizing CLIPlugin API in kubernetes cluster

func (*RESTDiscovery) List

func (d *RESTDiscovery) List() ([]Discovered, error)

List available plugins.

func (*RESTDiscovery) Name

func (d *RESTDiscovery) Name() string

Name of the repository.

func (*RESTDiscovery) Type

func (d *RESTDiscovery) Type() string

Type of the repository.

Jump to

Keyboard shortcuts

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