Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 1.88 KB

README.md

File metadata and controls

59 lines (42 loc) · 1.88 KB

kn Plugins

Plugins follow a similar architecture to kubectl plugins with some small differences. One key difference is that kn plugins can either live in your PATH or in a chosen and specified directory. Kn plugins show how to install and create new plugins as well as gives some examples and best practices.

To see what plugins are installed on your machine, you can use the plugin command group's list command.

Plugins provide extended functionality that is not part of the core kn command-line distribution.

Please refer to the documentation and examples for more information on how to write your own plugins.

Plugin Inlining

It is possible to inline plugins that are written in golang. The following steps are required:

  • In your plugin project, create a implementation of the Plugin interface and add it to the global plugin.InternalPlugins slice in your init() method, like in this example:
package plugin

import (
	"knative.dev/client/pkg/kn/plugin"
)

func init() {
	plugin.InternalPlugins = append(plugin.InternalPlugins, &myPlugin{})
}
  • In your fork of the kn client, add a file plugin_register.go to the root package directory which imports your plugin's implementation package:
package root

import (
        _ "github.com/rhuss/myplugin/plugin"
)

// RegisterInlinePlugins is an empty function which however forces the
// compiler to run all init() methods of the registered imports
func RegisterInlinePlugins() {}
  • Update you go.mod file with the new dependency and build your custom distribution of kn