Documentation ¶
Index ¶
Constants ¶
const ( // Install is executed after the plugin is added. Install = "install" // Delete is executed after the plugin is removed. Delete = "delete" // Update is executed after the plugin is updated. Update = "update" )
Types of hooks
const PluginFileName = "plugin.yaml"
Variables ¶
This section is empty.
Functions ¶
func PrepareCommands ¶
func PrepareCommands(cmds []PlatformCommand, expandArgs bool, extraArgs []string) (string, []string, error)
PrepareCommands takes a []Plugin.PlatformCommand and prepares the command and arguments for execution.
It merges extraArgs into any arguments supplied in the plugin. It returns the main command and an args array.
The result is suitable to pass to exec.Command.
func SetupPluginEnv ¶
func SetupPluginEnv(settings *cli.EnvSettings, name, base string)
SetupPluginEnv prepares os.Env for plugins. It operates on os.Env because the plugin subsystem itself needs access to the environment variables created here.
Types ¶
type Downloaders ¶
type Downloaders struct { // Protocols are the list of schemes from the charts URL. Protocols []string `json:"protocols"` // Command is the executable path with which the plugin performs // the actual download for the corresponding Protocols Command string `json:"command"` }
Downloaders represents the plugins capability if it can retrieve charts from special sources
type Metadata ¶
type Metadata struct { // Name is the name of the plugin Name string `json:"name"` // Version is a SemVer 2 version of the plugin. Version string `json:"version"` // Usage is the single-line usage text shown in help Usage string `json:"usage"` // Description is a long description shown in places like `helm help` Description string `json:"description"` // PlatformCommand is the plugin command, with a platform selector and support for args. // // The command and args will be passed through environment expansion, so env vars can // be present in this command. Unless IgnoreFlags is set, this will // also merge the flags passed from Helm. // // Note that the command is not executed in a shell. To do so, we suggest // pointing the command to a shell script. // // The following rules will apply to processing platform commands: // - If PlatformCommand is present, it will be used // - If both OS and Arch match the current platform, search will stop and the command will be executed // - If OS matches and Arch is empty, the command will be executed // - If no OS/Arch match is found, the default command will be executed // - If no matches are found in platformCommand, Helm will exit with an error PlatformCommand []PlatformCommand `json:"platformCommand"` // Command is the plugin command, as a single string. // Providing a command will result in an error if PlatformCommand is also set. // // The command will be passed through environment expansion, so env vars can // be present in this command. Unless IgnoreFlags is set, this will // also merge the flags passed from Helm. // // Note that command is not executed in a shell. To do so, we suggest // pointing the command to a shell script. // // DEPRECATED: Use PlatformCommand instead. Remove in Helm 4. Command string `json:"command"` // IgnoreFlags ignores any flags passed in from Helm // // For example, if the plugin is invoked as `helm --debug myplugin`, if this // is false, `--debug` will be appended to `--command`. If this is true, // the `--debug` flag will be discarded. IgnoreFlags bool `json:"ignoreFlags"` // PlatformHooks are commands that will run on plugin events, with a platform selector and support for args. // // The command and args will be passed through environment expansion, so env vars can // be present in the command. // // Note that the command is not executed in a shell. To do so, we suggest // pointing the command to a shell script. // // The following rules will apply to processing platform hooks: // - If PlatformHooks is present, it will be used // - If both OS and Arch match the current platform, search will stop and the command will be executed // - If OS matches and Arch is empty, the command will be executed // - If no OS/Arch match is found, the default command will be executed // - If no matches are found in platformHooks, Helm will skip the event PlatformHooks PlatformHooks `json:"platformHooks"` // Hooks are commands that will run on plugin events, as a single string. // Providing a hooks will result in an error if PlatformHooks is also set. // // The command will be passed through environment expansion, so env vars can // be present in this command. // // Note that the command is executed in the sh shell. // // DEPRECATED: Use PlatformHooks instead. Remove in Helm 4. Hooks Hooks // Downloaders field is used if the plugin supply downloader mechanism // for special protocols. Downloaders []Downloaders `json:"downloaders"` // UseTunnelDeprecated indicates that this command needs a tunnel. // Setting this will cause a number of side effects, such as the // automatic setting of HELM_HOST. // DEPRECATED and unused, but retained for backwards compatibility with Helm 2 plugins. Remove in Helm 4 UseTunnelDeprecated bool `json:"useTunnel,omitempty"` }
Metadata describes a plugin.
This is the plugin equivalent of a chart.Metadata.
type PlatformCommand ¶
type PlatformCommand struct { OperatingSystem string `json:"os"` Architecture string `json:"arch"` Command string `json:"command"` Args []string `json:"args"` }
PlatformCommand represents a command for a particular operating system and architecture
type PlatformHooks ¶
type PlatformHooks map[string][]PlatformCommand
PlatformHooks is a map of events to a command for a particular operating system and architecture.
type Plugin ¶
type Plugin struct { // Metadata is a parsed representation of a plugin.yaml Metadata *Metadata // Dir is the string path to the directory that holds the plugin. Dir string }
Plugin represents a plugin.
func FindPlugins ¶
FindPlugins returns a list of YAML files that describe plugins.
func LoadAll ¶
LoadAll loads all plugins found beneath the base directory.
This scans only one directory level.
func (*Plugin) PrepareCommand ¶
PrepareCommand gets the correct command and arguments for a plugin.
It merges extraArgs into any arguments supplied in the plugin. It returns the name of the command and an args array.
The result is suitable to pass to exec.Command.