Documentation ¶
Overview ¶
Package plugininventory implements an interface to deal with a plugin inventory. It encapsulates the logic that deals with how plugin inventories are stored so that other entities can use the plugin inventory without knowing its implementation details.
Index ¶
- Constants
- Variables
- func PluginGroupToID(pg *PluginGroup) string
- func PluginToID(p *PluginInventoryEntry) string
- type PluginGroup
- type PluginGroupFilter
- type PluginGroupIdentifier
- type PluginGroupPluginEntry
- type PluginGroupSorter
- type PluginIdentifier
- type PluginInventory
- type PluginInventoryEntry
- type PluginInventoryFilter
- type PluginInventoryMetadata
- type SQLiteInventory
- func (b *SQLiteInventory) CreateSchema() error
- func (b *SQLiteInventory) GetAllPlugins() ([]*PluginInventoryEntry, error)
- func (b *SQLiteInventory) GetPluginGroups(filter PluginGroupFilter) ([]*PluginGroup, error)
- func (b *SQLiteInventory) GetPlugins(filter *PluginInventoryFilter) ([]*PluginInventoryEntry, error)
- func (b *SQLiteInventory) InsertPlugin(pluginInventoryEntry *PluginInventoryEntry) error
- func (b *SQLiteInventory) InsertPluginGroup(pg *PluginGroup, override bool) error
- func (b *SQLiteInventory) UpdatePluginActivationState(pluginInventoryEntry *PluginInventoryEntry) error
- func (b *SQLiteInventory) UpdatePluginGroupActivationState(pg *PluginGroup) error
- type SQLiteInventoryMetadata
- func (b *SQLiteInventoryMetadata) CreateInventoryMetadataDBSchema() error
- func (b *SQLiteInventoryMetadata) InsertPluginGroupIdentifier(pgi *PluginGroupIdentifier) error
- func (b *SQLiteInventoryMetadata) InsertPluginIdentifier(pi *PluginIdentifier) error
- func (b *SQLiteInventoryMetadata) MergeInventoryMetadataDatabase(additionalMetadataDBFilePath string) error
- func (b *SQLiteInventoryMetadata) UpdatePluginInventoryDatabase(pluginInventoryDBFilePath string) error
Constants ¶
const ( // SQliteDBFileName is the name of the DB file that is stored in // the OCI image describing the inventory of plugins. SQliteDBFileName = "plugin_inventory.db" )
const ( // SQliteInventoryMetadataDBFileName is the name of the DB file that is stored in // the OCI image describing the plugin inventory metadata. SQliteInventoryMetadataDBFileName = "plugin_inventory_metadata.db" )
Variables ¶
var ( // CreateTablesSchema defines the database schema to create sqlite database CreateTablesSchema = strings.TrimSpace(createTablesSchema) // PluginInventoryMetadataCreateTablesSchema defines the database schema to create sqlite database for available plugins PluginInventoryMetadataCreateTablesSchema = strings.TrimSpace(pluginInventoryMetadataCreateTablesSchema) )
Functions ¶
func PluginGroupToID ¶ added in v0.90.0
func PluginGroupToID(pg *PluginGroup) string
func PluginToID ¶ added in v1.3.0
func PluginToID(p *PluginInventoryEntry) string
Types ¶
type PluginGroup ¶ added in v0.0.4
type PluginGroup struct { // Vendor of the group Vendor string // Publisher of the group Publisher string // Name of the group Name string // Description of the group Description string // Hidden tells whether the plugin-group should be ignored by the CLI. Hidden bool // Recommended version that the Tanzu CLI should install by default. // The value should be a valid semantic version as defined in // https://semver.org/. E.g., 2.0.1 RecommendedVersion string // Map of version to list of plugins Versions map[string][]*PluginGroupPluginEntry }
PluginGroup represents a list of plugins. The user will specify a group using "<Vendor>-<Publisher>/<Name>:<Version> e.g., "vmware-tkg/default:v2.1.0"
func RemoveDuplicatePluginGroups ¶ added in v1.2.0
func RemoveDuplicatePluginGroups(groups []*PluginGroup) []*PluginGroup
RemoveDuplicatePluginGroups removes the duplicate pluginGroups from the list based on Vendor, Publisher, Name and RecommendedVersion fields.
type PluginGroupFilter ¶ added in v0.90.0
type PluginGroupFilter struct { // Vendor of the group to look for Vendor string // Publisher of the group to look for Publisher string // Name of the group to look for Name string // Version of the group Version string // IncludeHidden indicates if hidden plugin groups should be included IncludeHidden bool }
PluginGroupFilter allows to specify different criteria for looking up plugin group entries.
type PluginGroupIdentifier ¶ added in v0.90.0
type PluginGroupIdentifier struct { // Vendor of the group Vendor string // Publisher of the group Publisher string // Name of the group Name string // Version of the group Version string }
PluginGroupIdentifier uniquely identifies a single version of a specific plugin group
func PluginGroupIdentifierFromID ¶ added in v0.90.0
func PluginGroupIdentifierFromID(id string) *PluginGroupIdentifier
PluginGroupIdentifierFromID converts a plugin group id into a PluginGroupIdentifier structure. A group id can be of the forms:
- vendor-publisher/name:version
- vendor-publisher/name, in which case the version field is left empty
Returns nil if 'id' is not of the expected format.
type PluginGroupPluginEntry ¶ added in v0.0.11
type PluginGroupPluginEntry struct { // The plugin version of this plugin entry PluginIdentifier // Mandatory specifies if the plugin is required to be installed or not Mandatory bool }
PluginGroupPluginEntry represents a plugin entry within a plugin group
type PluginGroupSorter ¶ added in v1.1.0
type PluginGroupSorter []*PluginGroup
PluginGroupSorter sorts PluginGroup objects.
func (PluginGroupSorter) Len ¶ added in v1.1.0
func (p PluginGroupSorter) Len() int
func (PluginGroupSorter) Less ¶ added in v1.1.0
func (p PluginGroupSorter) Less(i, j int) bool
func (PluginGroupSorter) Swap ¶ added in v1.1.0
func (p PluginGroupSorter) Swap(i, j int)
type PluginIdentifier ¶ added in v0.0.4
type PluginIdentifier 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 }
PluginIdentifier uniquely identifies a single version of a specific plugin
type PluginInventory ¶
type PluginInventory interface { // GetAllPlugins returns all plugins found in the inventory. GetAllPlugins() ([]*PluginInventoryEntry, error) // GetPlugins returns the plugins found in the inventory that match the provided filter. GetPlugins(*PluginInventoryFilter) ([]*PluginInventoryEntry, error) // GetPluginGroups returns the plugin groups found in the inventory that match the provided filter. GetPluginGroups(PluginGroupFilter) ([]*PluginGroup, error) // CreateSchema creates table schemas to the provided database. // returns error if table creation fails for any reason CreateSchema() error // InsertPlugin inserts plugin to the inventory InsertPlugin(*PluginInventoryEntry) error // InsertPluginGroup inserts plugin-group to the inventory // if override is true, it will update the existing plugin by // updating the metadata and the plugin associated with the plugin-group InsertPluginGroup(pg *PluginGroup, override bool) error // UpdatePluginActivationState updates plugin metadata to activate or deactivate plugin UpdatePluginActivationState(*PluginInventoryEntry) error // UpdatePluginGroupActivationState updates plugin-group metadata to activate or deactivate the plugin-group UpdatePluginGroupActivationState(*PluginGroup) error }
PluginInventory is the interface to interact with a plugin inventory. It can be used to get the plugin information for plugins in the inventory based on different criteria.
func NewSQLiteInventory ¶
func NewSQLiteInventory(inventoryFile, prefix string) PluginInventory
NewSQLiteInventory returns a new PluginInventory connected to the data found at 'inventoryFile'.
type PluginInventoryEntry ¶
type PluginInventoryEntry struct { // Name of the plugin Name string // Target to which the plugin applies Target configtypes.Target // Description of the plugin Description string // Publisher is the name of the publisher of this plugin // (e.g., a product group within a company) Publisher string // Vendor is the name of the vendor of this plugin (e.g., a company's name) Vendor string // Recommended version that Tanzu CLI should install by default. // The value should be a valid semantic version as defined in // https://semver.org/. E.g., 2.0.1 RecommendedVersion string // Hidden tells whether the plugin is marked as hidden or not. Hidden bool // Artifacts contains an artifact list for every available version. Artifacts distribution.Artifacts }
PluginInventoryEntry represents the inventory information about a single plugin as found by the inventory backend.
func RemoveDuplicatePluginInventoryEntries ¶ added in v1.2.0
func RemoveDuplicatePluginInventoryEntries(entries []*PluginInventoryEntry) []*PluginInventoryEntry
RemoveDuplicatePluginInventoryEntries removes the duplicate PluginInventoryEntries based on Name, Target and RecommendedVersion fields.
type PluginInventoryFilter ¶ added in v0.0.4
type PluginInventoryFilter struct { // Name of the plugin to look for Name string // Target to which the plugins apply Target configtypes.Target // Version for the plugins to look for Version string // OS of the plugin binary in `GOOS` format. OS string // Arch of the plugin binary in `GOARCH` format. Arch string // Publisher of the plugins to look for Publisher string // Vendor of the plugins to look for Vendor string // IncludeHidden indicates if hidden plugins should be included IncludeHidden bool }
PluginInventoryFilter allows to specify different criteria for looking up plugin entries.
type PluginInventoryMetadata ¶ added in v0.90.0
type PluginInventoryMetadata interface { // CreateInventoryMetadataDBSchema creates table schemas for // plugin inventory metadata database // returns error if table creation fails for any reason CreateInventoryMetadataDBSchema() error // InsertPluginIdentifier inserts the PluginIdentifier entry to the // AvailablePluginBinaries table InsertPluginIdentifier(*PluginIdentifier) error // InsertPluginGroupIdentifier inserts the PluginGroupIdentifier entry to the // AvailablePluginGroups table InsertPluginGroupIdentifier(*PluginGroupIdentifier) error // MergeInventoryMetadataDatabase merges two inventory metadata database by // merging the content of AvailablePluginBinaries and AvailablePluginGroups tables MergeInventoryMetadataDatabase(additionalMetadataDBFilePath string) error // UpdatePluginInventoryDatabase updates the plugin inventory database based // on the plugin inventory metadata database by deleting entries that don't // exists in plugin inventory metadata database UpdatePluginInventoryDatabase(pluginInventoryDBFilePath string) error }
PluginInventoryMetadata is the interface to interact with a plugin inventory metadata database and plugin inventory database. It can be used to create database schema for metadata db, insert plugin and plugin group identifier and merging metadata database This interface also provides function to update plugin inventory database based on the plugin inventory metadata database
func NewSQLiteInventoryMetadata ¶ added in v0.90.0
func NewSQLiteInventoryMetadata(inventoryMetadataDBFile string) PluginInventoryMetadata
NewSQLiteInventoryMetadata returns a new PluginInventoryMetadata connected to the data found at 'inventoryMetadataDBFile'.
type SQLiteInventory ¶
type SQLiteInventory struct {
// contains filtered or unexported fields
}
SQLiteInventory is an inventory stored using SQLite
func (*SQLiteInventory) CreateSchema ¶ added in v0.0.4
func (b *SQLiteInventory) CreateSchema() error
CreateSchema creates table schemas to the provided database. returns error if table creation fails for any reason
func (*SQLiteInventory) GetAllPlugins ¶
func (b *SQLiteInventory) GetAllPlugins() ([]*PluginInventoryEntry, error)
GetAllPlugins returns all plugins found in the inventory.
func (*SQLiteInventory) GetPluginGroups ¶ added in v0.90.0
func (b *SQLiteInventory) GetPluginGroups(filter PluginGroupFilter) ([]*PluginGroup, error)
func (*SQLiteInventory) GetPlugins ¶ added in v0.0.4
func (b *SQLiteInventory) GetPlugins(filter *PluginInventoryFilter) ([]*PluginInventoryEntry, error)
GetPlugins returns the plugin found in the inventory that matches the provided parameters.
func (*SQLiteInventory) InsertPlugin ¶ added in v0.0.4
func (b *SQLiteInventory) InsertPlugin(pluginInventoryEntry *PluginInventoryEntry) error
InsertPlugin inserts plugin to the inventory
func (*SQLiteInventory) InsertPluginGroup ¶ added in v0.0.11
func (b *SQLiteInventory) InsertPluginGroup(pg *PluginGroup, override bool) error
InsertPluginGroup inserts plugin-group to the inventory specifying override will delete the existing plugin-group and add new one
func (*SQLiteInventory) UpdatePluginActivationState ¶ added in v0.0.4
func (b *SQLiteInventory) UpdatePluginActivationState(pluginInventoryEntry *PluginInventoryEntry) error
UpdatePluginActivationState updates plugin metadata to activate or deactivate plugin
func (*SQLiteInventory) UpdatePluginGroupActivationState ¶ added in v0.0.11
func (b *SQLiteInventory) UpdatePluginGroupActivationState(pg *PluginGroup) error
type SQLiteInventoryMetadata ¶ added in v0.90.0
type SQLiteInventoryMetadata struct {
// contains filtered or unexported fields
}
SQLiteInventoryMetadata is an inventory metadata stored using SQLite
func (*SQLiteInventoryMetadata) CreateInventoryMetadataDBSchema ¶ added in v0.90.0
func (b *SQLiteInventoryMetadata) CreateInventoryMetadataDBSchema() error
CreateInventoryMetadataDBSchema creates table schemas for plugin inventory metadata database returns error if table creation fails for any reason
func (*SQLiteInventoryMetadata) InsertPluginGroupIdentifier ¶ added in v0.90.0
func (b *SQLiteInventoryMetadata) InsertPluginGroupIdentifier(pgi *PluginGroupIdentifier) error
InsertPluginGroupIdentifier inserts the PluginGroupIdentifier entry to the AvailablePluginGroups table
func (*SQLiteInventoryMetadata) InsertPluginIdentifier ¶ added in v0.90.0
func (b *SQLiteInventoryMetadata) InsertPluginIdentifier(pi *PluginIdentifier) error
InsertPluginIdentifier inserts the PluginIdentifier entry to the AvailablePluginBinaries table
func (*SQLiteInventoryMetadata) MergeInventoryMetadataDatabase ¶ added in v0.90.0
func (b *SQLiteInventoryMetadata) MergeInventoryMetadataDatabase(additionalMetadataDBFilePath string) error
MergeInventoryMetadataDatabase merges two inventory metadata database by merging the content of AvailablePluginBinaries and AvailablePluginGroups tables
func (*SQLiteInventoryMetadata) UpdatePluginInventoryDatabase ¶ added in v0.90.0
func (b *SQLiteInventoryMetadata) UpdatePluginInventoryDatabase(pluginInventoryDBFilePath string) error
UpdatePluginInventoryDatabase updates the plugin inventory database based on the plugin inventory metadata database by deleting entries that don't exists in plugin inventory metadata database