Добавлены новые возможности для работы с файловыми логами Docker-сервисов: - Эндпоинты для получения списка логов и хвоста лог-файла. - Очистка лог-файлов с возможностью выбора режима (truncate или delete) и запись в аудит очистки. - Обновлена документация и конфигурация для поддержки новых функций. Co-authored-by: Cursor <[email protected]>
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
package store
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// Runtime log cleanup actions (runtime_log_cleanup_audit.action).
|
|
const (
|
|
RuntimeLogCleanupTruncate = "truncate"
|
|
RuntimeLogCleanupDelete = "delete"
|
|
)
|
|
|
|
// RuntimeLogFile describes a file in EVOBGP_RUNTIME_LOGS_DIR (API DTO).
|
|
type RuntimeLogFile struct {
|
|
Name string `json:"name"`
|
|
SizeBytes int64 `json:"size_bytes"`
|
|
ModifiedAt time.Time `json:"modified_at"`
|
|
}
|
|
|
|
// RuntimeLogTail is a tail/preview fragment of a runtime log file.
|
|
type RuntimeLogTail struct {
|
|
Filename string `json:"filename"`
|
|
Content string `json:"content"`
|
|
Truncated bool `json:"truncated"`
|
|
LinesReturned int `json:"lines_returned"`
|
|
}
|
|
|
|
// RuntimeLogCleanupAudit is a persisted cleanup operation log entry.
|
|
type RuntimeLogCleanupAudit struct {
|
|
ID string `json:"id"`
|
|
TenantID string `json:"tenant_id"`
|
|
ActorPrefix string `json:"actor_prefix"`
|
|
Filename string `json:"filename"`
|
|
Action string `json:"action"`
|
|
SizeBefore int64 `json:"size_before"`
|
|
SizeAfter *int64 `json:"size_after,omitempty"`
|
|
Detail map[string]any `json:"detail,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// ValidRuntimeLogCleanupAction reports whether action is truncate or delete.
|
|
func ValidRuntimeLogCleanupAction(action string) bool {
|
|
switch strings.TrimSpace(action) {
|
|
case RuntimeLogCleanupTruncate, RuntimeLogCleanupDelete:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|