Documentation ¶
Index ¶
- Constants
- Variables
- func AddIndex(paths *Paths, name, url string) error
- func CanonicalPluginName(in string) (string, string)
- func DeleteIndex(paths *Paths, name string) error
- func EnsureDirs(paths ...string) error
- func InitPlugin()
- func Install(p *Paths, plugin Plugin, indexName string, opts InstallOpts) error
- func IsSubPath(basePath, subPath string) (string, bool)
- func NewPluginCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginDescribeCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginIndexAddCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginIndexCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginIndexDeleteCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginIndexListCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginIndexPrinter(out io.Writer) *printer.TablePrinter
- func NewPluginIndexUpdateCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginInstallCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginListCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginPrinter(out io.Writer) *printer.TablePrinter
- func NewPluginSearchCmd(streams genericclioptions.IOStreams) *cobra.Command
- func NewPluginSearchPrinter(out io.Writer) *printer.TablePrinter
- func NewPluginUninstallCmd(_ genericclioptions.IOStreams) *cobra.Command
- func NewPluginUpgradeCmd(streams genericclioptions.IOStreams) *cobra.Command
- func ReplaceBase(path, old, replacement string) (string, error)
- func StoreReceipt(receipt Receipt, dest string) error
- func Upgrade(p *Paths, plugin Plugin, indexName string) error
- func ValidatePlugin(name string, p Plugin) error
- type CommandOverrideVerifier
- type FileOperation
- type Index
- type InstallOpts
- type OSArchPair
- type PathVerifier
- type Paths
- func (p *Paths) BasePath() string
- func (p *Paths) BinPath() string
- func (p *Paths) IndexBase() string
- func (p *Paths) IndexPath(name string) string
- func (p *Paths) IndexPluginsPath(name string) []string
- func (p *Paths) InstallPath() string
- func (p *Paths) InstallReceiptsPath() string
- func (p *Paths) PluginInstallPath(plugin string) string
- func (p *Paths) PluginInstallReceiptPath(plugin string) string
- func (p *Paths) PluginVersionInstallPath(plugin, version string) string
- type Platform
- type Plugin
- type PluginIndexOptions
- type PluginInstallOption
- type PluginListOptions
- type PluginSpec
- type Receipt
- type ReceiptStatus
- type SourceIndex
- type UpgradeOptions
Constants ¶
const ( DefaultIndexURI = "https://github.com/apecloud/block-index.git" DefaultIndexName = "default" KrewIndexURI = "https://github.com/kubernetes-sigs/krew-index.git" KrewIndexName = "krew" ManifestExtension = ".yaml" PluginKind = "Plugin" )
Variables ¶
var ( ErrIsAlreadyInstalled = errors.New("can't install, the newest version is already installed") ErrIsNotInstalled = errors.New("plugin is not installed") ErrIsAlreadyUpgraded = errors.New("can't upgrade, the newest version is already installed") )
var SupportAPIVersion = []string{
"krew.googlecontainertools.github.com/v1alpha2",
}
var (
ValidPluginFilenamePrefixes = []string{"kbcli", "kubectl"}
)
Functions ¶
func CanonicalPluginName ¶
CanonicalPluginName resolves a plugin's index and name from input string. If an index is not specified, the default index name is assumed.
func DeleteIndex ¶
DeleteIndex removes specified index name. If index does not exist, returns an error that can be tested by os.IsNotExist.
func EnsureDirs ¶
func InitPlugin ¶
func InitPlugin()
func Install ¶
func Install(p *Paths, plugin Plugin, indexName string, opts InstallOpts) error
Install downloads and installs a plugin. The operation tries to keep the plugin dir in a healthy state if it fails during the process.
func IsSubPath ¶
IsSubPath checks if the extending path is an extension of the basePath, it will return the extending path elements. Both paths have to be absolute or have the same root directory. The remaining path elements
func NewPluginCmd ¶
func NewPluginCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginDescribeCmd ¶
func NewPluginDescribeCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginIndexAddCmd ¶
func NewPluginIndexAddCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginIndexCmd ¶
func NewPluginIndexCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginIndexDeleteCmd ¶
func NewPluginIndexDeleteCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginIndexListCmd ¶
func NewPluginIndexListCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginIndexPrinter ¶
func NewPluginIndexPrinter(out io.Writer) *printer.TablePrinter
func NewPluginIndexUpdateCmd ¶
func NewPluginIndexUpdateCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginInstallCmd ¶
func NewPluginInstallCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginListCmd ¶
func NewPluginListCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginPrinter ¶
func NewPluginPrinter(out io.Writer) *printer.TablePrinter
func NewPluginSearchCmd ¶
func NewPluginSearchCmd(streams genericclioptions.IOStreams) *cobra.Command
func NewPluginSearchPrinter ¶
func NewPluginSearchPrinter(out io.Writer) *printer.TablePrinter
func NewPluginUninstallCmd ¶
func NewPluginUninstallCmd(_ genericclioptions.IOStreams) *cobra.Command
func NewPluginUpgradeCmd ¶
func NewPluginUpgradeCmd(streams genericclioptions.IOStreams) *cobra.Command
func ReplaceBase ¶
ReplaceBase returns a replacement path with replacement as a base of the path instead of the old base. a/b/c, a, d -> d/b/c
func StoreReceipt ¶
func Upgrade ¶
Upgrade reinstalls and deletes the old plugin. The operation tries to keep dir in a healthy state if it fails during the process.
func ValidatePlugin ¶
Types ¶
type CommandOverrideVerifier ¶
type CommandOverrideVerifier struct {
// contains filtered or unexported fields
}
func (*CommandOverrideVerifier) Verify ¶
func (v *CommandOverrideVerifier) Verify(path string) []error
Verify implements PathVerifier and determines if a given path is valid depending on whether it overwrites an existing kbcli command path, or a previously seen plugin.
type FileOperation ¶
FileOperation specifies a file copying operation from plugin archive to the installation directory.
type Index ¶
func ListIndexes ¶
ListIndexes returns a slice of Index objects. The path argument is used as the base path of the index.
type InstallOpts ¶
type InstallOpts struct {
ArchiveFileOverride string
}
type OSArchPair ¶
type OSArchPair struct {
OS, Arch string
}
OSArchPair is wrapper around operating system and architecture
func OSArch ¶
func OSArch() OSArchPair
OSArch returns the OS/arch combination to be used on the current system. It can be overridden by setting KREW_OS and/or KREW_ARCH environment variables.
func (OSArchPair) String ¶
func (p OSArchPair) String() string
String converts environment into a string
type PathVerifier ¶
PathVerifier receives a path and validates it.
type Paths ¶
type Paths struct {
// contains filtered or unexported fields
}
func GetKbcliPluginPath ¶
func GetKbcliPluginPath() *Paths
func (*Paths) IndexPluginsPath ¶
func (*Paths) InstallPath ¶
func (*Paths) InstallReceiptsPath ¶
func (*Paths) PluginInstallPath ¶
func (*Paths) PluginInstallReceiptPath ¶
func (*Paths) PluginVersionInstallPath ¶
type Platform ¶
type Platform struct { URI string `json:"uri,omitempty"` Sha256 string `json:"sha256,omitempty"` Selector *metav1.LabelSelector `json:"selector,omitempty"` Files []FileOperation `json:"files"` // Bin specifies the path to the plugin executable. // The path is relative to the root of the installation folder. // The binary will be linked after all FileOperations are executed. Bin string `json:"bin"` }
Platform describes how to perform an installation on a specific platform and how to match the target platform (os, arch).
type Plugin ¶
type Plugin struct { metav1.TypeMeta `json:",inline" yaml:",inline"` metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata"` Spec PluginSpec `json:"spec"` }
func LoadPluginByName ¶
LoadPluginByName loads plugin from index repository
func LoadPluginListFromFS ¶
LoadPluginListFromFS will parse and retrieve all plugin files.
func ReadPluginFromFile ¶
type PluginIndexOptions ¶
type PluginIndexOptions struct { IndexName string URL string genericclioptions.IOStreams }
func (*PluginIndexOptions) AddIndex ¶
func (o *PluginIndexOptions) AddIndex() error
func (*PluginIndexOptions) DeleteIndex ¶
func (o *PluginIndexOptions) DeleteIndex() error
func (*PluginIndexOptions) ListIndex ¶
func (o *PluginIndexOptions) ListIndex() error
func (*PluginIndexOptions) UpdateIndex ¶
func (o *PluginIndexOptions) UpdateIndex() error
type PluginInstallOption ¶
type PluginInstallOption struct { genericclioptions.IOStreams // contains filtered or unexported fields }
func (*PluginInstallOption) Complete ¶
func (o *PluginInstallOption) Complete(names []string) error
func (*PluginInstallOption) Install ¶
func (o *PluginInstallOption) Install() error
type PluginListOptions ¶
type PluginListOptions struct { Verifier PathVerifier PluginPaths []string genericclioptions.IOStreams }
func (*PluginListOptions) ListPlugins ¶
func (o *PluginListOptions) ListPlugins() ([]string, []error)
func (*PluginListOptions) Run ¶
func (o *PluginListOptions) Run() error
type PluginSpec ¶
type PluginSpec struct { Version string `json:"version,omitempty"` ShortDescription string `json:"shortDescription,omitempty"` Description string `json:"description,omitempty"` Caveats string `json:"caveats,omitempty"` Homepage string `json:"homepage,omitempty"` Platforms []Platform `json:"platforms,omitempty"` }
PluginSpec is the plugin specification.
type Receipt ¶
type Receipt struct { Plugin `json:",inline" yaml:",inline"` Status ReceiptStatus `json:"status"` }
Receipt describes a plugin receipt file.
func GetInstalledPluginReceipts ¶
GetInstalledPluginReceipts returns a list of receipts.
func NewReceipt ¶
NewReceipt returns a new receipt with the given plugin and index name.
func ReadReceiptFromFile ¶
type ReceiptStatus ¶
type ReceiptStatus struct {
Source SourceIndex `json:"source"`
}
ReceiptStatus contains information about the installed plugin.
type SourceIndex ¶
type SourceIndex struct { // Name is the configured name of an index a plugin was installed from. Name string `json:"name"` }
SourceIndex contains information about the index a plugin was installed from.
type UpgradeOptions ¶
type UpgradeOptions struct { genericclioptions.IOStreams // contains filtered or unexported fields }
func (*UpgradeOptions) Complete ¶
func (o *UpgradeOptions) Complete(args []string) error
func (*UpgradeOptions) Run ¶
func (o *UpgradeOptions) Run() error