chore: remove extranious comments

This commit is contained in:
jamesread 2026-02-13 23:36:16 +00:00
parent 254c4a6a15
commit 1248ee8765
2 changed files with 6 additions and 13 deletions

View File

@ -710,7 +710,11 @@ func (api *oliveTinAPI) DumpVars(ctx ctx.Context, req *connect.Request[apiv1.Dum
return connect.NewResponse(res), nil return connect.NewResponse(res), nil
} }
jsonstring, _ := json.MarshalIndent(tpl.GetNewGeneralTemplateContext(), "", " ") jsonstring, err := json.MarshalIndent(tpl.GetNewGeneralTemplateContext(), "", " ")
if err != nil {
log.WithError(err).Error("DumpVars: failed to marshal template context from GetNewGeneralTemplateContext")
return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("dump vars: marshal template context: %w", err))
}
fmt.Printf("%s", jsonstring) fmt.Printf("%s", jsonstring)
res.Alert = "Dumping variables has been enabled in the configuration. Please set InsecureAllowDumpVars = false again after you don't need it anymore" res.Alert = "Dumping variables has been enabled in the configuration. Please set InsecureAllowDumpVars = false again after you don't need it anymore"

View File

@ -37,7 +37,6 @@ func (e *Executor) LoadLogsFromDisk() {
}).Info("Finished loading persisted logs from disk") }).Info("Finished loading persisted logs from disk")
} }
// readLogDirectory reads the log directory and returns entries, or nil if the directory doesn't exist or can't be read.
func (e *Executor) readLogDirectory(resultsDir string) ([]os.DirEntry, int) { func (e *Executor) readLogDirectory(resultsDir string) ([]os.DirEntry, int) {
if _, err := os.Stat(resultsDir); os.IsNotExist(err) { if _, err := os.Stat(resultsDir); os.IsNotExist(err) {
log.WithFields(log.Fields{ log.WithFields(log.Fields{
@ -62,7 +61,6 @@ func (e *Executor) readLogDirectory(resultsDir string) ([]os.DirEntry, int) {
return entries, 0 return entries, 0
} }
// parseLogFiles parses YAML log files from the directory entries.
func (e *Executor) parseLogFiles(resultsDir string, entries []os.DirEntry, skippedCount int) ([]*InternalLogEntry, int) { func (e *Executor) parseLogFiles(resultsDir string, entries []os.DirEntry, skippedCount int) ([]*InternalLogEntry, int) {
loadedLogs := make([]*InternalLogEntry, 0) loadedLogs := make([]*InternalLogEntry, 0)
@ -81,12 +79,10 @@ func (e *Executor) parseLogFiles(resultsDir string, entries []os.DirEntry, skipp
return loadedLogs, skippedCount return loadedLogs, skippedCount
} }
// shouldProcessLogEntry checks if a directory entry should be processed as a log file.
func (e *Executor) shouldProcessLogEntry(entry os.DirEntry) bool { func (e *Executor) shouldProcessLogEntry(entry os.DirEntry) bool {
return !entry.IsDir() && strings.HasSuffix(entry.Name(), ".yaml") return !entry.IsDir() && strings.HasSuffix(entry.Name(), ".yaml")
} }
// processLogFileEntry processes a single log file entry and returns the log entry or nil if it should be skipped.
func (e *Executor) processLogFileEntry(resultsDir, filename string) (*InternalLogEntry, int) { func (e *Executor) processLogFileEntry(resultsDir, filename string) (*InternalLogEntry, int) {
logEntry, ok := e.loadLogFileFromPath(resultsDir, filename) logEntry, ok := e.loadLogFileFromPath(resultsDir, filename)
if !ok { if !ok {
@ -104,7 +100,6 @@ func (e *Executor) processLogFileEntry(resultsDir, filename string) (*InternalLo
return logEntry, 0 return logEntry, 0
} }
// loadLogFileFromPath loads and unmarshals a single log file.
func (e *Executor) loadLogFileFromPath(resultsDir, filename string) (*InternalLogEntry, bool) { func (e *Executor) loadLogFileFromPath(resultsDir, filename string) (*InternalLogEntry, bool) {
filepath := filepath.Join(resultsDir, filename) filepath := filepath.Join(resultsDir, filename)
data, err := os.ReadFile(filepath) data, err := os.ReadFile(filepath)
@ -128,7 +123,7 @@ func (e *Executor) loadLogFileFromPath(resultsDir, filename string) (*InternalLo
return &logEntry, true return &logEntry, true
} }
// restoreBindingForLogEntry attempts to restore the binding for a log entry if it's missing or invalid. // Skipped when the entry already has a valid binding or has no ActionConfigTitle (e.g. action/entity removed from config).
func (e *Executor) restoreBindingForLogEntry(logEntry *InternalLogEntry, filepath string) { func (e *Executor) restoreBindingForLogEntry(logEntry *InternalLogEntry, filepath string) {
if e.hasValidBinding(logEntry) || logEntry.ActionConfigTitle == "" { if e.hasValidBinding(logEntry) || logEntry.ActionConfigTitle == "" {
return return
@ -144,12 +139,10 @@ func (e *Executor) restoreBindingForLogEntry(logEntry *InternalLogEntry, filepat
logEntry.Binding = nil logEntry.Binding = nil
} }
// hasValidBinding checks if a log entry has a valid binding.
func (e *Executor) hasValidBinding(logEntry *InternalLogEntry) bool { func (e *Executor) hasValidBinding(logEntry *InternalLogEntry) bool {
return logEntry.Binding != nil && logEntry.Binding.Action != nil return logEntry.Binding != nil && logEntry.Binding.Action != nil
} }
// logBindingNotFound logs a debug message when a binding cannot be found for a log entry.
func (e *Executor) logBindingNotFound(logEntry *InternalLogEntry, filepath string) { func (e *Executor) logBindingNotFound(logEntry *InternalLogEntry, filepath string) {
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"file": filepath, "file": filepath,
@ -159,7 +152,6 @@ func (e *Executor) logBindingNotFound(logEntry *InternalLogEntry, filepath strin
}).Debug("Could not find binding for log entry, loading without binding") }).Debug("Could not find binding for log entry, loading without binding")
} }
// restoreLogsToExecutor restores loaded logs to the executor's internal structures.
func (e *Executor) restoreLogsToExecutor(loadedLogs []*InternalLogEntry, skippedCount int) int { func (e *Executor) restoreLogsToExecutor(loadedLogs []*InternalLogEntry, skippedCount int) int {
e.logmutex.Lock() e.logmutex.Lock()
defer e.logmutex.Unlock() defer e.logmutex.Unlock()
@ -185,7 +177,6 @@ func (e *Executor) restoreLogsToExecutor(loadedLogs []*InternalLogEntry, skipped
return skippedCount return skippedCount
} }
// addLogToBindingMap adds a log entry to the LogsByBindingId map.
func (e *Executor) addLogToBindingMap(logEntry *InternalLogEntry) { func (e *Executor) addLogToBindingMap(logEntry *InternalLogEntry) {
if _, containsKey := e.LogsByBindingId[logEntry.Binding.ID]; !containsKey { if _, containsKey := e.LogsByBindingId[logEntry.Binding.ID]; !containsKey {
e.LogsByBindingId[logEntry.Binding.ID] = make([]*InternalLogEntry, 0) e.LogsByBindingId[logEntry.Binding.ID] = make([]*InternalLogEntry, 0)
@ -193,7 +184,6 @@ func (e *Executor) addLogToBindingMap(logEntry *InternalLogEntry) {
e.LogsByBindingId[logEntry.Binding.ID] = append(e.LogsByBindingId[logEntry.Binding.ID], logEntry) e.LogsByBindingId[logEntry.Binding.ID] = append(e.LogsByBindingId[logEntry.Binding.ID], logEntry)
} }
// findBindingByActionTitle attempts to find a binding by matching the action config title and entity prefix.
func (e *Executor) findBindingByActionTitle(actionConfigTitle string, entityPrefix string) *ActionBinding { func (e *Executor) findBindingByActionTitle(actionConfigTitle string, entityPrefix string) *ActionBinding {
e.MapActionBindingsLock.RLock() e.MapActionBindingsLock.RLock()
defer e.MapActionBindingsLock.RUnlock() defer e.MapActionBindingsLock.RUnlock()
@ -207,7 +197,6 @@ func (e *Executor) findBindingByActionTitle(actionConfigTitle string, entityPref
return nil return nil
} }
// matchesEntityPrefix checks if a binding matches the given entity prefix.
func (e *Executor) matchesEntityPrefix(binding *ActionBinding, entityPrefix string) bool { func (e *Executor) matchesEntityPrefix(binding *ActionBinding, entityPrefix string) bool {
if entityPrefix == "" { if entityPrefix == "" {
return binding.Entity == nil return binding.Entity == nil