This commit is contained in:
Julian Sommer
2026-02-19 13:17:20 +10:00
parent a330e35d5f
commit 17c011e9db
@@ -2,12 +2,15 @@ package gateway_ec2_instance
import (
"encoding/json"
"errors"
"fmt"
"log/slog"
"time"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/nats-io/nats.go"
"github.com/mulgadc/hive/hive/utils"
)
// GetConsoleOutput retrieves console output for a specific instance via NATS.
@@ -31,6 +34,12 @@ func GetConsoleOutput(input *ec2.GetConsoleOutputInput, natsConn *nats.Conn) (*e
return nil, fmt.Errorf("failed to get console output: %w", err)
}
responseError, parseErr := utils.ValidateErrorPayload(msg.Data)
if parseErr != nil {
slog.Error("GetConsoleOutput: Daemon returned error", "instance_id", *input.InstanceId, "code", *responseError.Code)
return nil, errors.New(*responseError.Code)
}
var output ec2.GetConsoleOutputOutput
if err := json.Unmarshal(msg.Data, &output); err != nil {
slog.Error("GetConsoleOutput: Failed to unmarshal response", "err", err)