mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-21 17:45:43 +02:00
feat(agent)!: add support for mTLS authentication in gRPC server (#54)
* refactor(fancontroller): improve fan controller validation logic and error handling for temperature steps * refactor(agent): restructure gRPC server implementation by moving it to a new api package for better organization and maintainability * feat(agent): implement gRPC server for managing compute blade agents and add graceful shutdown support refactor(agent): restructure agent code by moving API logic to a dedicated file and improving error handling fix(agent): update logging messages for clarity and consistency across the agent's operations chore(agent): remove unused API code and consolidate event handling logic for better maintainability style(agent): improve code formatting and organization for better readability and adherence to conventions * feat(agent): add support for TLS configuration in gRPC server * feat(api): add gRPC server authentication * fix * feat(config): add listen mode configuration to support tcp or unix sockets feat(agent): implement listen mode in gRPC service to allow flexible socket types feat(bladectl): enhance configuration loading and add support for TLS credentials fix(bladectl): improve error handling for gRPC connection and event emission style(logging): change log level from Warn to Info for better clarity in logs * add logging middleware + fixes * fix remote-connection to gRPC API Server debugging the SAN issues took the soul out of me... And then the stupid mistake in cmd_root where I didn't construct the TLS credentials correctly... Oh dear... * cleanup * cleanup * cleanup commands * cleanup * make README.md nicer * Update cmd/agent/main.go Co-authored-by: Matthias Riegler <github@m4tbit.de> * Update cmd/bladectl/cmd_root.go Co-authored-by: Matthias Riegler <github@m4tbit.de> * move bladectl config into correct directory * fix bugs * // FIXME: No dead code * nit: code style * nit(YAGNI): you aint gonna need it. Don't make life harder than it needs to be * nit(YAGNI): you aint gonna need it. Don't make life harder than it needs to be * nit(YAGNI): you aint gonna need it. Don't make life harder than it needs to be * nit(cmd_identify) --------- Co-authored-by: Matthias Riegler <github@m4tbit.de>
This commit is contained in:
@@ -5,9 +5,9 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/uptime-induestries/compute-blade-agent/pkg/hal"
|
||||
"github.com/uptime-induestries/compute-blade-agent/pkg/hal/led"
|
||||
"github.com/uptime-induestries/compute-blade-agent/pkg/util"
|
||||
"github.com/uptime-industries/compute-blade-agent/pkg/hal"
|
||||
"github.com/uptime-industries/compute-blade-agent/pkg/hal/led"
|
||||
"github.com/uptime-industries/compute-blade-agent/pkg/util"
|
||||
)
|
||||
|
||||
// LedEngine is the interface for controlling effects on the computeblade RGB LEDs
|
||||
@@ -36,21 +36,21 @@ type BlinkPattern struct {
|
||||
Delays []time.Duration
|
||||
}
|
||||
|
||||
func mapBrighnessUint8(brightness float64) uint8 {
|
||||
func mapBrightnessUint8(brightness float64) uint8 {
|
||||
return uint8(255.0 * brightness)
|
||||
}
|
||||
|
||||
func LedColorPurple(brightness float64) led.Color {
|
||||
return led.Color{
|
||||
Red: mapBrighnessUint8(brightness),
|
||||
Red: mapBrightnessUint8(brightness),
|
||||
Green: 0,
|
||||
Blue: mapBrighnessUint8(brightness),
|
||||
Blue: mapBrightnessUint8(brightness),
|
||||
}
|
||||
}
|
||||
|
||||
func LedColorRed(brightness float64) led.Color {
|
||||
return led.Color{
|
||||
Red: mapBrighnessUint8(brightness),
|
||||
Red: mapBrightnessUint8(brightness),
|
||||
Green: 0,
|
||||
Blue: 0,
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func LedColorRed(brightness float64) led.Color {
|
||||
func LedColorGreen(brightness float64) led.Color {
|
||||
return led.Color{
|
||||
Red: 0,
|
||||
Green: mapBrighnessUint8(brightness),
|
||||
Green: mapBrightnessUint8(brightness),
|
||||
Blue: 0,
|
||||
}
|
||||
}
|
||||
@@ -101,17 +101,7 @@ func NewSlowBlinkPattern(baseColor led.Color, activeColor led.Color) BlinkPatter
|
||||
}
|
||||
}
|
||||
|
||||
// LedEngineOpts are the options for the LedEngine
|
||||
type LedEngineOpts struct {
|
||||
// LedIdx is the index of the LED to control
|
||||
LedIdx uint
|
||||
// Hal is the computeblade hardware abstraction layer
|
||||
Hal hal.ComputeBladeHal
|
||||
// Clock is the clock used for timing
|
||||
Clock util.Clock
|
||||
}
|
||||
|
||||
func NewLedEngine(opts LedEngineOpts) *ledEngineImpl {
|
||||
func NewLedEngine(opts Options) LedEngine {
|
||||
clock := opts.Clock
|
||||
if clock == nil {
|
||||
clock = util.RealClock{}
|
||||
@@ -119,7 +109,7 @@ func NewLedEngine(opts LedEngineOpts) *ledEngineImpl {
|
||||
return &ledEngineImpl{
|
||||
ledIdx: opts.LedIdx,
|
||||
hal: opts.Hal,
|
||||
restart: make(chan struct{}), // restart channel controls cancelation of any pattern
|
||||
restart: make(chan struct{}), // restart channel controls cancellation of any pattern
|
||||
pattern: NewStaticPattern(led.Color{}), // Turn off LEDs by default
|
||||
clock: clock,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user