Fix plugin trying to run --debug event and not logging to files

Args[0] is no longer guaranteed to be the event's name. We have a proper
command now.

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
Dimitris Karakasilis
2025-09-26 15:49:31 +03:00
parent ecfd56d260
commit 012bfa2fae
2 changed files with 8 additions and 14 deletions

View File

@@ -20,9 +20,6 @@ import (
"github.com/kairos-io/kairos-challenger/pkg/constants"
)
// Because of how go-pluggable works, we can't just print to stdout
const LOGFILE = "/tmp/kcrypt-challenger-client.log"
// Retry delays for different failure types
const (
TPMRetryDelay = 100 * time.Millisecond // Brief delay for TPM hardware busy/unavailable
@@ -45,17 +42,12 @@ func NewClientWithLogger(logger types.KairosLogger) (*Client, error) {
return &Client{Config: conf, Logger: logger}, nil
}
func (c *Client) Start() error {
if err := os.RemoveAll(LOGFILE); err != nil { // Start fresh
return fmt.Errorf("removing the logfile: %w", err)
}
func (c *Client) Start(eventType pluggable.EventType) error {
factory := pluggable.NewPluginFactory()
// Input: bus.EventInstallPayload
// Expected output: map[string]string{}
factory.Add(bus.EventDiscoveryPassword, func(e *pluggable.Event) pluggable.EventResponse {
b := &block.Partition{}
err := json.Unmarshal([]byte(e.Data), b)
if err != nil {
@@ -77,7 +69,7 @@ func (c *Client) Start() error {
}
})
return factory.Run(pluggable.EventType(os.Args[1]), os.Stdin, os.Stdout)
return factory.Run(eventType, os.Stdin, c.Logger)
}
// echo '{ "data": "{ \\"label\\": \\"LABEL\\" }"}' | sudo -E WSS_SERVER="http://localhost:8082/challenge" ./challenger "discovery.password"