Skip to content

Commit b4b9a24

Browse files
authored
feat: add the type definition of file metadata annotation (#49)
Signed-off-by: chlins <[email protected]>
1 parent e043eed commit b4b9a24

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

docs/annotations.md

+32
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,35 @@ This property contains arbitrary metadata, and SHOULD follow the rules of [OCI i
77
### Layer Annotation Keys
88

99
- **`org.cnai.model.filepath`**: Specifies the file path of the layer (string).
10+
11+
- **`org.cnai.model.file.metadata`**: Specifies the metadata of the file (string), value is the JSON string of [File Metadata Annotation Value](#File-Metadata-Annotation-Value).
12+
13+
### Layer Annotation Values
14+
15+
#### File Metadata Annotation Value
16+
17+
```go
18+
// FileMetadata represents the metadata of file, which is the value definition of AnnotationFileMetadata.
19+
type FileMetadata struct {
20+
// File name
21+
Name string `json:"name"`
22+
23+
// File permission mode (e.g., Unix permission bits)
24+
Mode uint32 `json:"mode"`
25+
26+
// User ID (identifier of the file owner)
27+
Uid uint32 `json:"uid"`
28+
29+
// Group ID (identifier of the file's group)
30+
Gid uint32 `json:"gid"`
31+
32+
// File size (in bytes)
33+
Size int64 `json:"size"`
34+
35+
// File last modification time
36+
ModTime time.Time `json:"mtime"`
37+
38+
// File type flag (e.g., regular file, directory, etc.)
39+
Typeflag byte `json:"typeflag"`
40+
}
41+
```

specs-go/v1/annotations.go

+29
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,36 @@
1616

1717
package v1
1818

19+
import "time"
20+
1921
const (
2022
// AnnotationFilepath is the annotation key for the file path of the layer.
2123
AnnotationFilepath = "org.cnai.model.filepath"
24+
25+
// AnnotationFileMetadata is the annotation key for the file metadata of the layer.
26+
AnnotationFileMetadata = "org.cnai.model.file.metadata"
2227
)
28+
29+
// FileMetadata represents the metadata of file, which is the value definition of AnnotationFileMetadata.
30+
type FileMetadata struct {
31+
// File name
32+
Name string `json:"name"`
33+
34+
// File permission mode (e.g., Unix permission bits)
35+
Mode uint32 `json:"mode"`
36+
37+
// User ID (identifier of the file owner)
38+
Uid uint32 `json:"uid"`
39+
40+
// Group ID (identifier of the file's group)
41+
Gid uint32 `json:"gid"`
42+
43+
// File size (in bytes)
44+
Size int64 `json:"size"`
45+
46+
// File last modification time
47+
ModTime time.Time `json:"mtime"`
48+
49+
// File type flag (e.g., regular file, directory, etc.)
50+
Typeflag byte `json:"typeflag"`
51+
}

0 commit comments

Comments
 (0)