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 ¶
- func CheckDiscoveryName(ds configtypes.PluginDiscovery, dn string) bool
- func CompareDiscoverySource(ds1, ds2 configtypes.PluginDiscovery, dsType string) bool
- func UpdateArtifactsBasedOnImageRepositoryOverride(p *cliv1alpha1.CLIPlugin, imageRepoOverride map[string]string)
- type DBBackedOCIDiscovery
- type Discovered
- type DiscoveredSorter
- type Discovery
- func CreateDiscoveryFromV1alpha1(pd configtypes.PluginDiscovery, options ...DiscoveryOptions) (Discovery, error)
- func NewKubernetesDiscovery(name, kubeconfigPath, kubecontext string) Discovery
- func NewLocalDiscovery(name, localPath string) Discovery
- func NewOCIDiscovery(name, image string, options ...DiscoveryOptions) Discovery
- func NewRESTDiscovery(name, endpoint, basePath string) Discovery
- type DiscoveryOptions
- type DiscoveryOpts
- type GroupDiscovery
- type GroupDiscoveryCriteria
- type KubernetesDiscovery
- func (k *KubernetesDiscovery) GetDiscoveredPlugins(clusterClient cluster.Client) ([]Discovered, error)
- func (k *KubernetesDiscovery) List() ([]Discovered, error)
- func (k *KubernetesDiscovery) Manifest() ([]Discovered, error)
- func (k *KubernetesDiscovery) Name() string
- func (k *KubernetesDiscovery) Type() string
- type ListPluginsResponse
- type LocalDiscovery
- type Plugin
- type PluginDiscoveryCriteria
- type RESTDiscovery
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 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 ¶
NewKubernetesDiscovery returns a new kubernetes repository
func NewLocalDiscovery ¶
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 ¶
NewRESTDiscovery returns a new kubernetes repository
type DiscoveryOptions ¶ added in v1.0.0
type DiscoveryOptions func(options *DiscoveryOpts)
func WithGroupDiscoveryCriteria ¶ added in v1.0.0
func WithGroupDiscoveryCriteria(criteria *GroupDiscoveryCriteria) DiscoveryOptions
func WithPluginDiscoveryCriteria ¶ added in v1.0.0
func WithPluginDiscoveryCriteria(criteria *PluginDiscoveryCriteria) DiscoveryOptions
func WithUseLocalCacheOnly ¶ added in v1.0.0
func WithUseLocalCacheOnly() DiscoveryOptions
type DiscoveryOpts ¶ added in v1.0.0
type DiscoveryOpts struct {
UseLocalCacheOnly bool // UseLocalCacheOnly used to pull the plugin data from the cache
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.
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.