refactor: Add JSON serialization tags to OCI spec fields

- Add `json` tags for `oci_version` and `no_new_privileges`
- Add `json` tag for `additional_gids` in `User` struct
- Add `json` tags for `typ` in `Rlimit`, `Mount`, `LinuxNamespace`
- Add `json` tags for path and ID mapping fields in `Linux`
- Add `json` tags for `file_mode`, `container_id`, `host_id`
This commit is contained in:
Mahmoud-Emad
2025-09-10 11:54:38 +03:00
parent 7635732952
commit 2ddec79102

View File

@@ -3,7 +3,7 @@ module crun
// OCI Runtime Spec structures that can be directly encoded to JSON
pub struct Spec {
pub mut:
oci_version string
oci_version string @[json: 'ociVersion']
platform Platform
process Process
root Root
@@ -28,14 +28,14 @@ pub mut:
cwd string = '/'
capabilities Capabilities
rlimits []Rlimit
no_new_privileges bool
no_new_privileges bool @[json: 'noNewPrivileges']
}
pub struct User {
pub mut:
uid u32
gid u32
additional_gids []u32
additional_gids []u32 @[json: 'additionalGids']
}
pub struct Capabilities {
@@ -49,7 +49,7 @@ pub mut:
pub struct Rlimit {
pub mut:
typ string
typ string @[json: 'type']
hard u64
soft u64
}
@@ -63,7 +63,7 @@ pub mut:
pub struct Mount {
pub mut:
destination string
typ string
typ string @[json: 'type']
source string
options []string
}
@@ -73,15 +73,15 @@ pub mut:
namespaces []LinuxNamespace
resources LinuxResources
devices []LinuxDevice
masked_paths []string
readonly_paths []string
uid_mappings []LinuxIDMapping
gid_mappings []LinuxIDMapping
masked_paths []string @[json: 'maskedPaths']
readonly_paths []string @[json: 'readonlyPaths']
uid_mappings []LinuxIDMapping @[json: 'uidMappings']
gid_mappings []LinuxIDMapping @[json: 'gidMappings']
}
pub struct LinuxNamespace {
pub mut:
typ string
typ string @[json: 'type']
path string
}
@@ -124,18 +124,18 @@ pub mut:
pub struct LinuxDevice {
pub mut:
path string
typ string
typ string @[json: 'type']
major i64
minor i64
file_mode u32
file_mode u32 @[json: 'fileMode']
uid u32
gid u32
}
pub struct LinuxIDMapping {
pub mut:
container_id u32
host_id u32
container_id u32 @[json: 'containerID']
host_id u32 @[json: 'hostID']
size u32
}