Documentation
¶
Overview ¶
Package plugin provides functions to create new CLI plugins.
Index ¶
Constants ¶
const ( // NativePluginCompletion indicates command line completion is determined using the built in // cobra.Command __complete mechanism. NativePluginCompletion PluginCompletionType = iota // StaticPluginCompletion indicates command line completion will be done by using a statically // defined list of options. StaticPluginCompletion // DynamicPluginCompletion indicates command line completion will be retrieved from the plugin // at runtime. DynamicPluginCompletion // RunCmdGroup are commands associated with Tanzu Run. RunCmdGroup CmdGroup = "Run" // ManageCmdGroup are commands associated with Tanzu Manage. ManageCmdGroup CmdGroup = "Manage" // BuildCmdGroup are commands associated with Tanzu Build. BuildCmdGroup CmdGroup = "Build" // ObserveCmdGroup are commands associated with Tanzu Observe. ObserveCmdGroup CmdGroup = "Observe" // SystemCmdGroup are system commands. SystemCmdGroup CmdGroup = "System" // TargetCmdGroup are various target commands. TargetCmdGroup CmdGroup = "Target" // VersionCmdGroup are version commands. VersionCmdGroup CmdGroup = "Version" // AdminCmdGroup are admin commands. AdminCmdGroup CmdGroup = "Admin" // TestCmdGroup is the test command group. TestCmdGroup CmdGroup = "Test" // ExtraCmdGroup is the extra command group. ExtraCmdGroup CmdGroup = "Extra" )
const CmdTemplate = `` /* 1462-byte string literal not displayed */
CmdTemplate is the template for plugin commands.
const DefaultDocsDir = "docs/cli/commands"
DefaultDocsDir is the base docs directory
const ErrorDocsOutputFolderNotExists = "" /* 137-byte string literal not displayed */
const (
PluginRuntimeModulePath = "github.com/vmware-tanzu/tanzu-plugin-runtime"
)
Variables ¶
var TemplateFuncs = template.FuncMap{ "rpad": component.Rpad, "bold": component.Bold, "underline": component.Underline, "trimTrailingWhitespaces": component.TrimRightSpace, "beginsWith": component.BeginsWith, }
TemplateFuncs are the template usage funcs.
var UsageFunc = func(c *cobra.Command) error { t, err := template.New("usage").Funcs(TemplateFuncs).Parse(CmdTemplate) if err != nil { return err } return t.Execute(os.Stdout, c) }
UsageFunc is the usage func for a plugin.
Functions ¶
func ApplyDefaultConfig ¶
func ApplyDefaultConfig(p *PluginDescriptor)
ApplyDefaultConfig applies default configurations to plugin descriptor.
func SyncPluginsForTarget ¶ added in v0.90.0
SyncPluginsForTarget will attempt to install plugins required by the active Context of the provided target. This is most useful for any plugin implementation which creates a new Context or updates an existing one as part of its operation, and prefers that the plugins appropriate for the Context are immediately available for use.
Note: This API is considered EXPERIMENTAL. Both the function's signature and implementation are subjected to change/removal if an alternative means to provide equivalent functionality can be introduced.
The output of the plugin syncing will be return as a string.
func ValidatePlugin ¶
func ValidatePlugin(p *PluginDescriptor) (err error)
ValidatePlugin validates the plugin descriptor.
Types ¶
type Plugin ¶
Plugin is a Tanzu CLI plugin.
func NewPlugin ¶
func NewPlugin(descriptor *PluginDescriptor) (*Plugin, error)
NewPlugin creates an instance of Plugin.
func (*Plugin) AddCommands ¶
AddCommands adds commands to the plugin.
type PluginCompletionType ¶
type PluginCompletionType int
PluginCompletionType is the mechanism used for determining command line completion options.
type PluginDescriptor ¶
type PluginDescriptor struct { // Name is the name of the plugin. Name string `json:"name" yaml:"name"` // Description is the plugin's description. Description string `json:"description" yaml:"description"` // Target is the target to which plugin is applicable. Target types.Target `json:"target" yaml:"target"` // Version of the plugin. Must be a valid semantic version https://semver.org/ Version string `json:"version" yaml:"version"` // BuildSHA is the git commit hash the plugin was built with. BuildSHA string `json:"buildSHA" yaml:"buildSHA"` // Digest is the SHA256 hash of the plugin binary. Digest string `json:"digest" yaml:"digest"` // Command group for the plugin. Group CmdGroup `json:"group" yaml:"group"` // DocURL for the plugin. DocURL string `json:"docURL" yaml:"docURL"` // Hidden tells whether the plugin should be hidden from the help command. Hidden bool `json:"hidden,omitempty" yaml:"hidden,omitempty"` // CompletionType determines how command line completion will be determined. CompletionType PluginCompletionType `json:"completionType" yaml:"completionType"` // CompletionArgs contains the valid command line completion values if `CompletionType` // is set to `StaticPluginCompletion`. CompletionArgs []string `json:"completionArgs,omitempty" yaml:"completionArgs,omitempty"` // CompletionCommand is the command to call from the plugin to retrieve a list of // valid completion nouns when `CompletionType` is set to `DynamicPluginCompletion`. CompletionCommand string `json:"completionCmd,omitempty" yaml:"completionCmd,omitempty"` // Aliases are other text strings used to call this command Aliases []string `json:"aliases,omitempty" yaml:"aliases,omitempty"` // PostInstallHook is function to be run post install of a plugin. PostInstallHook Hook `json:"-" yaml:"-"` // DefaultFeatureFlags is default featureflags to be configured if missing when invoking plugin DefaultFeatureFlags map[string]bool `json:"defaultFeatureFlags,omitempty" yaml:"defaultFeatureFlags,omitempty"` }
PluginDescriptor describes a plugin binary.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package buildinfo holds global variables set at build time to provide information about the plugin build.
|
Package buildinfo holds global variables set at build time to provide information about the plugin build. |
Package lint provides linters to run against CLI plugins.
|
Package lint provides linters to run against CLI plugins. |