mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
Basic support for kubectl plugins
This commit is contained in:
@@ -21,12 +21,14 @@ package util
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/kubectl/plugins"
|
||||
"k8s.io/kubernetes/pkg/kubectl/resource"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
)
|
||||
@@ -130,3 +132,22 @@ func (f *ring2Factory) NewBuilder() *resource.Builder {
|
||||
|
||||
return resource.NewBuilder(mapper, categoryExpander, typer, resource.ClientMapperFunc(f.objectMappingFactory.ClientForMapping), f.clientAccessFactory.Decoder(true))
|
||||
}
|
||||
|
||||
// PluginLoader loads plugins from a path set by the KUBECTL_PLUGINS_PATH env var.
|
||||
// If this env var is not set, it defaults to
|
||||
// "~/.kube/plugins", plus
|
||||
// "./kubectl/plugins" directory under the "data dir" directory specified by the XDG
|
||||
// system directory structure spec for the given platform.
|
||||
func (f *ring2Factory) PluginLoader() plugins.PluginLoader {
|
||||
if len(os.Getenv("KUBECTL_PLUGINS_PATH")) > 0 {
|
||||
return plugins.PluginsEnvVarPluginLoader()
|
||||
}
|
||||
return plugins.TolerantMultiPluginLoader{
|
||||
plugins.XDGDataPluginLoader(),
|
||||
plugins.UserDirPluginLoader(),
|
||||
}
|
||||
}
|
||||
|
||||
func (f *ring2Factory) PluginRunner() plugins.PluginRunner {
|
||||
return &plugins.ExecPluginRunner{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user