Fix run log ingest and terminal console layout

This commit is contained in:
npc0-hue
2026-08-03 12:49:46 +08:00
parent 1d5fb586d0
commit a1bf3aa86a
15 changed files with 390 additions and 34 deletions
+13 -1
View File
@@ -68,7 +68,7 @@ func ValidateLogBatchIngest(batch domain.LogBatchIngest) error {
computed, err := LogEntriesChecksum(batch.Entries)
if err != nil {
violations = append(violations, "checksum cannot be computed")
} else if batch.Checksum != computed {
} else if batch.Checksum != computed && !logLineChecksumMatches(batch) {
violations = append(violations, "checksum does not match entries")
}
}
@@ -107,6 +107,18 @@ func LogEntriesChecksum(entries []domain.LogEntry) (string, error) {
return "sha256:" + hex.EncodeToString(sum[:]), nil
}
func logLineChecksumMatches(batch domain.LogBatchIngest) bool {
if len(batch.Entries) != 1 {
return false
}
return batch.Checksum == LogLineChecksum(batch.Entries[0].Line)
}
func LogLineChecksum(value string) string {
sum := sha256.Sum256([]byte(value))
return "sha256:" + hex.EncodeToString(sum[:])
}
type logEntryChecksumBody struct {
Seq uint64 `json:"seq"`
Timestamp string `json:"timestamp"`
+1 -1
View File
@@ -2355,7 +2355,7 @@ func validArtifactState(state domain.ArtifactState) bool {
func validLogStreamSource(source domain.LogStreamSource) bool {
switch source {
case domain.LogStreamSourceProcess, domain.LogStreamSourceFile, domain.LogStreamSourcePlugin:
case domain.LogStreamSourceProcess, domain.LogStreamSourceFile, domain.LogStreamSourcePlugin, domain.LogStreamSourceManagementProgram:
return true
default:
return strings.TrimSpace(string(source)) != ""