Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions pkg/store/kubeconfig_store_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"os/exec"

"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -49,6 +50,22 @@ func NewPluginStore(store types.KubeconfigStore) (*PluginStore, error) {
}, nil
}

func convertLogrusLevelToHclogLevel(level logrus.Level) hclog.Level {
switch level {
case logrus.TraceLevel:
return hclog.Trace
case logrus.DebugLevel:
return hclog.Debug
case logrus.InfoLevel:
return hclog.Info
case logrus.WarnLevel:
return hclog.Warn
default:
// Default to Error level for any other logrus levels (e.g. Fatal or Panic)
return hclog.Error
}
}

// InitializePluginStore initializes the plugin store
func (s *PluginStore) InitializePluginStore() error {

Expand All @@ -58,6 +75,11 @@ func (s *PluginStore) InitializePluginStore() error {
Cmd: exec.Command(s.Config.CmdPath, s.Config.Args...),
AllowedProtocols: []plugin.Protocol{
plugin.ProtocolNetRPC, plugin.ProtocolGRPC},
Logger: hclog.New(&hclog.LoggerOptions{
Output: hclog.DefaultOutput,
Level: convertLogrusLevelToHclogLevel(s.Logger.Level),
Name: "plugin",
}),
})

// Connect via RPC
Expand Down