From 0e74d15259e64311bad7f68ee85c979027ef9865 Mon Sep 17 00:00:00 2001 From: Ashlie Martinez Date: Fri, 31 Mar 2023 12:32:10 -0700 Subject: [PATCH] Add structs for kopia manifests --- src/cmd/jsondebug/common/helpers.go | 76 +++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/src/cmd/jsondebug/common/helpers.go b/src/cmd/jsondebug/common/helpers.go index 08e77de0a..6b2a6e29b 100644 --- a/src/cmd/jsondebug/common/helpers.go +++ b/src/cmd/jsondebug/common/helpers.go @@ -3,14 +3,18 @@ package common import ( "encoding/json" "fmt" + "math/rand" "runtime" "time" ) const ( - NumItems = 300000 - ItemSize = 1024 - FileName = "input.json" + NumItems = 300000 + ItemSize = 1024 + GzipSuffix = ".gz" + FileName = "input.json" + + ManifestFileName = "manifest-input.json" ) type FooArray struct { @@ -30,6 +34,72 @@ type Content struct { Data []byte `json:"data"` } +type Manifest struct { + Entries []*ManifestEntry `json:"entries"` +} + +type ManifestEntry struct { + ID string `json:"id"` + Labels map[string]string `json:"labels"` + ModTime time.Time `json:"modified"` + Deleted bool `json:"deleted,omitempty"` + Content json.RawMessage `json:"data"` +} + +type SnapManifest struct { + ID string `json:"id"` + Source SourceInfo `json:"source"` + Description string `json:"description"` + StartTime int64 `json:"startTime"` + EndTime int64 `json:"endTime"` + Stats StatsS `json:"stats,omitempty"` + IncompleteReason string `json:"incomplete,omitempty"` + RootEntry *DirEntry `json:"rootEntry"` + Tags map[string]string `json:"tags,omitempty"` +} + +type SourceInfo struct { + Host string `json:"host"` + UserName string `json:"userName"` + Path string `json:"path"` +} + +type StatsS struct { + TotalFileSize int64 `json:"totalSize"` + ExcludedTotalFileSize int64 `json:"excludedTotalSize"` + TotalFileCount int32 `json:"fileCount"` + CachedFiles int32 `json:"cachedFiles"` + NonCachedFiles int32 `json:"nonCachedFiles"` + TotalDirectoryCount int32 `json:"dirCount"` + ExcludedFileCount int32 `json:"excludedFileCount"` + ExcludedDirCount int32 `json:"excludedDirCount"` + IgnoredErrorCount int32 `json:"ignoredErrorCount"` + ErrorCount int32 `json:"errorCount"` +} + +type DirEntry struct { + Name string `json:"name,omitempty"` + EntryType string `json:"type,omitempty"` + Permissions int `json:"mode,omitempty"` + FileSize int64 `json:"size,omitempty"` + ModTime int64 `json:"mtime,omitempty"` + UserID int32 `json:"uid,omitempty"` + GroupID int32 `json:"gid,omitempty"` + ObjectID string `json:"obj,omitempty"` + DirSummary *DirectorySummary `json:"summ,omitempty"` +} + +type DirectorySummary struct { + TotalFileSize int64 `json:"size"` + TotalFileCount int64 `json:"files"` + TotalSymlinkCount int64 `json:"symlinks"` + TotalDirCount int64 `json:"dirs"` + MaxModTime int64 `json:"maxTime"` + IncompleteReason string `json:"incomplete,omitempty"` + FatalErrorCount int `json:"numFailed"` + IgnoredErrorCount int `json:"numIgnoredErrors,omitempty"` +} + func PrintMemUsage() { var m runtime.MemStats