Files
ssh-netbox-wrapper/internal/config/operations.go
T
Sebastian Unterschütz e5bde9c61f
Test / test (push) Successful in 4m4s
Release / release (push) Successful in 7m39s
feat: add host actions, lifecycle hooks and operational tools
2026-11-18 10:41:36 +01:00

35 lines
899 B
Go

package config
import (
"fmt"
"strings"
)
type TUIConfig struct {
HistoryLimit int `mapstructure:"history_limit"`
}
type ActivityConfig struct {
Enabled bool `mapstructure:"enabled"`
RetentionDays int `mapstructure:"retention_days"`
MaxEntries int `mapstructure:"max_entries"`
}
func (c *Config) ValidateOperations() error {
if c.TUI.HistoryLimit < 0 {
return fmt.Errorf("tui.history_limit must be >= 0 (0 = all)")
}
if c.Activity.RetentionDays < 0 || c.Activity.MaxEntries < 0 {
return fmt.Errorf("activity retention_days and max_entries must be >= 0")
}
return nil
}
func (m SSHMatch) Matches(host SSHHost) bool { return m == (SSHMatch{}) || m.matches(host) }
func (c HostCommand) Allowed(host SSHHost) bool { return c.Match.Matches(host) }
func HookCommand(s string) string {
s = strings.TrimSpace(s)
if strings.EqualFold(s, "none") {
return ""
}
return s
}