Skip to content

Commit b94b99d

Browse files
Merge pull request #2982 from dmcgowan/metadata-structure-documentation
Add structure documentation for metadata
2 parents a410405 + d25007e commit b94b99d

1 file changed

Lines changed: 83 additions & 7 deletions

File tree

metadata/buckets.go

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
limitations under the License.
1515
*/
1616

17-
package metadata
18-
19-
import (
20-
digest "github.com/opencontainers/go-digest"
21-
bolt "go.etcd.io/bbolt"
22-
)
23-
17+
// Package metadata stores all labels and object specific metadata by namespace.
18+
// This package also contains the main garbage collection logic for cleaning up
19+
// resources consistently and atomically. Resources used by backends will be
20+
// tracked in the metadata store to be exposed to consumers of this package.
21+
//
2422
// The layout where a "/" delineates a bucket is described in the following
2523
// section. Please try to follow this as closely as possible when adding
2624
// functionality. We can bolster this with helpers and more structure if that
@@ -43,6 +41,84 @@ import (
4341
//
4442
// key: object-specific key identifying the storage bucket for the objects
4543
// contents.
44+
//
45+
// Below is the current database schema. This should be updated each time
46+
// the structure is changed in addition to adding a migration and incrementing
47+
// the database version. Note that `╘══*...*` refers to maps with arbitrary
48+
// keys.
49+
// ├──version : <varint> - Latest version, see migrations
50+
// └──v1 - Schema version bucket
51+
// ╘══*namespace*
52+
// ├──labels
53+
// │  ╘══*key* : <string> - Label value
54+
// ├──image
55+
// │  ╘══*image name*
56+
// │   ├──createdat : <binary time> - Created at
57+
// │   ├──updatedat : <binary time> - Updated at
58+
// │   ├──target
59+
// │   │  ├──digest : <digest> - Descriptor digest
60+
// │   │  ├──mediatype : <string> - Descriptor media type
61+
// │   │  └──size : <varint> - Descriptor size
62+
// │   └──labels
63+
// │   ╘══*key* : <string> - Label value
64+
// ├──containers
65+
// │  ╘══*container id*
66+
// │   ├──createdat : <binary time> - Created at
67+
// │   ├──updatedat : <binary time> - Updated at
68+
// │   ├──spec : <binary> - Proto marshaled spec
69+
// │   ├──image : <string> - Image name
70+
// │   ├──snapshotter : <string> - Snapshotter name
71+
// │   ├──snapshotKey : <string> - Snapshot key
72+
// │   ├──runtime
73+
// │   │  ├──name : <string> - Runtime name
74+
// │   │  ├──extensions
75+
// │   │  │  ╘══*name* : <binary> - Proto marshaled extension
76+
// │   │  └──options : <binary> - Proto marshaled options
77+
// │   └──labels
78+
// │   ╘══*key* : <string> - Label value
79+
// ├──snapshots
80+
// │  ╘══*snapshotter*
81+
// │   ╘══*snapshot key*
82+
// │    ├──name : <string> - Snapshot name in backend
83+
// │   ├──createdat : <binary time> - Created at
84+
// │   ├──updatedat : <binary time> - Updated at
85+
// │    ├──parent : <string> - Parent snapshot name
86+
// │   ├──children
87+
// │   │  ╘══*snapshot key* : <nil> - Child snapshot reference
88+
// │   └──labels
89+
// │   ╘══*key* : <string> - Label value
90+
// ├──content
91+
// │  ├──blob
92+
// │  │ ╘══*blob digest*
93+
// │  │ ├──createdat : <binary time> - Created at
94+
// │  │ ├──updatedat : <binary time> - Updated at
95+
// │  │   ├──size : <varint> - Blob size
96+
// │  │ └──labels
97+
// │  │ ╘══*key* : <string> - Label value
98+
// │  └──ingests
99+
// │   ╘══*ingest reference*
100+
// │    ├──ref : <string> - Ingest reference in backend
101+
// │   ├──expireat : <binary time> - Time to expire ingest
102+
// │   └──expected : <digest> - Expected commit digest
103+
// └──leases
104+
// ╘══*lease id*
105+
//   ├──createdat : <binary time> - Created at
106+
// ├──labels
107+
// │ ╘══*key* : <string> - Label value
108+
//   ├──snapshots
109+
// │  ╘══*snapshotter*
110+
// │   ╘══*snapshot key* : <nil> - Snapshot reference
111+
//   ├──content
112+
// │  ╘══*blob digest* : <nil> - Content blob reference
113+
// └──ingests
114+
//   ╘══*ingest reference* : <nil> - Content ingest reference
115+
package metadata
116+
117+
import (
118+
digest "github.com/opencontainers/go-digest"
119+
bolt "go.etcd.io/bbolt"
120+
)
121+
46122
var (
47123
bucketKeyVersion = []byte(schemaVersion)
48124
bucketKeyDBVersion = []byte("version") // stores the version of the schema

0 commit comments

Comments
 (0)