catalog

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package catalog implements catalog management functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanCatalogCache

func CleanCatalogCache() error

CleanCatalogCache cleans the catalog cache

func DeleteIncorrectPluginEntriesFromCatalog added in v0.90.0

func DeleteIncorrectPluginEntriesFromCatalog()

DeleteIncorrectPluginEntriesFromCatalog deletes the old plugin entries associated with 'global' target if a plugin with the same name and different target already exists This can happen because of an existing bug in v0.28.x and v0.29.x version of tanzu-cli where we allow plugins to be installed when target value is different even if target values of “(empty), `global` and `kubernetes` can correspond to same root level command

func MigrateContextPluginsAsStandaloneIfNeeded added in v1.3.0

func MigrateContextPluginsAsStandaloneIfNeeded()

MigrateContextPluginsAsStandaloneIfNeeded updates the catalog cache to move all the context-scoped plugins associated with the active context as standalone plugins and removes the context-scoped plugin mapping from the catalog cache. This is to ensure backwards compatibility when user migrates from pre v1.3 version of the CLI, the context-scoped plugins are still gets shown as installed

func PluginNameTarget

func PluginNameTarget(pluginName string, target configtypes.Target) string

PluginNameTarget constructs a string to uniquely refer to a plugin associated with a specific target when target is provided.

Types

type Catalog

type Catalog struct {
	// PluginInfos is a list of PluginInfo
	PluginInfos []*cli.PluginInfo `json:"pluginInfos,omitempty" yaml:"pluginInfos,omitempty"`

	// IndexByPath of PluginInfos for all installed plugins by installation path.
	IndexByPath map[string]cli.PluginInfo `json:"indexByPath,omitempty" yaml:"indexByPath,omitempty"`
	// IndeByName of all plugin installation paths by name.
	IndexByName map[string][]string `json:"indexByName,omitempty" yaml:"indexByName,omitempty"`
	// StandAlonePlugins is a set of stand-alone plugin installations aggregated across all context types.
	// Note: Shall be reduced to only those stand-alone plugins that are common to all context types.
	StandAlonePlugins PluginAssociation `json:"standAlonePlugins,omitempty" yaml:"standAlonePlugins,omitempty"`
	// ServerPlugins links a server and a set of associated plugin installations.
	ServerPlugins map[string]PluginAssociation `json:"serverPlugins,omitempty" yaml:"serverPlugins,omitempty"`
}

Catalog is the Schema for the plugin catalog data

type CatalogList

type CatalogList struct {
	Items []Catalog `json:"items"`
}

CatalogList contains a list of Catalog

type ContextCatalog

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

ContextCatalog denotes a local plugin catalog for a given context or stand-alone.

func (*ContextCatalog) Delete

func (c *ContextCatalog) Delete(plugin string) error

Delete deletes the given plugin from the catalog, but it does not delete the installation.

func (*ContextCatalog) Get

func (c *ContextCatalog) Get(plugin string) (cli.PluginInfo, bool)

Get looks up the descriptor of a plugin given its name.

func (*ContextCatalog) List

func (c *ContextCatalog) List() []cli.PluginInfo

List returns the list of active plugins. Active plugin means the plugin that are available to the user based on the current logged-in server.

func (*ContextCatalog) Unlock added in v1.1.0

func (c *ContextCatalog) Unlock()

Unlock unlocks the catalog for other process to read/write After Unlock() is called, the ContextCatalog object can no longer be used, and a new one must be obtained for any further operation on the catalog

func (*ContextCatalog) Upsert

func (c *ContextCatalog) Upsert(plugin *cli.PluginInfo) error

Upsert inserts/updates the given plugin.

type PluginAssociation

type PluginAssociation map[string]string

PluginAssociation is a set of plugin names and their associated installation paths.

func (PluginAssociation) Add

func (pa PluginAssociation) Add(pluginName, installationPath string)

Add adds plugin entry to the map

func (PluginAssociation) Get

func (pa PluginAssociation) Get(pluginName string) string

Get returns installation path for the plugin If plugin doesn't exists in map it will return empty string

func (PluginAssociation) Map

func (pa PluginAssociation) Map() map[string]string

Map returns associated list of plugins as a map

func (PluginAssociation) Remove

func (pa PluginAssociation) Remove(pluginName string)

Remove deletes plugin entry from the map

type PluginCatalogReader added in v1.1.0

type PluginCatalogReader interface {
	// Get looks up the info of a plugin given its name.
	Get(pluginName string) (cli.PluginInfo, bool)

	// List returns the list of active plugins.
	// Active plugin means the plugin that are available to the user
	// based on the current logged-in server.
	List() []cli.PluginInfo
}

PluginCatalogReader is the interface to a read collection of installed plugins.

func NewContextCatalog

func NewContextCatalog(context string) (PluginCatalogReader, error)

NewContextCatalog creates context-aware catalog for reading the catalog

type PluginCatalogUpdater added in v1.1.0

type PluginCatalogUpdater interface {
	PluginCatalogReader

	// Upsert inserts/updates the given plugin.
	Upsert(plugin *cli.PluginInfo) error

	// Delete deletes the given plugin from the catalog, but it does not delete the installation.
	Delete(plugin string) error

	// Unlock unlocks the catalog for other process to read/write
	// After Unlock() is called, the ContextCatalog object can no longer be used,
	// and a new one must be obtained for any further operation on the catalog
	Unlock()
}

PluginCatalogUpdater is the interface to read and update a collection of installed plugins.

func NewContextCatalogUpdater added in v1.1.0

func NewContextCatalogUpdater(context string) (PluginCatalogUpdater, error)

NewContextCatalogUpdater creates context-aware catalog for reading/updating the catalog When using this API invoker needs to call `Unlock` API to unlock the WriteLock acquired to update the catalog After Unlock() is called, the ContextCatalog object can no longer be used, and a new one must be obtained for any further operation on the catalog

type PluginSupplier

type PluginSupplier interface {
	// GetInstalledPlugins returns a list of installed plugins
	GetInstalledPlugins() ([]*cli.PluginInfo, error)
}

PluginSupplier is responsible for keeping an inventory of installed plugins

Jump to

Keyboard shortcuts

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