|
| 1 | +//! CentOS Automotive Suite OCI constant |
| 2 | +//! |
| 3 | +
|
| 4 | +/// OCI annotation keys used by automotive images for partition mapping |
| 5 | +pub mod annotations { |
| 6 | + pub const PARTITION_ANNOTATION: &str = "automotive.sdv.cloud.redhat.com/partition"; |
| 7 | + |
| 8 | + pub const DECOMPRESSED_SIZE: &str = "automotive.sdv.cloud.redhat.com/decompressed-size"; |
| 9 | + |
| 10 | + pub const TARGET: &str = "automotive.sdv.cloud.redhat.com/target"; |
| 11 | + |
| 12 | + pub const ARCH: &str = "automotive.sdv.cloud.redhat.com/arch"; |
| 13 | + |
| 14 | + pub const DISTRO: &str = "automotive.sdv.cloud.redhat.com/distro"; |
| 15 | + |
| 16 | + pub const MULTI_LAYER: &str = "automotive.sdv.cloud.redhat.com/multi-layer"; |
| 17 | + |
| 18 | + pub const PARTS: &str = "automotive.sdv.cloud.redhat.com/parts"; |
| 19 | +} |
| 20 | + |
| 21 | +pub mod targets { |
| 22 | + pub const RIDESX4: &str = "ridesx4"; |
| 23 | + pub const AUTOSD: &str = "autosd"; |
| 24 | +} |
| 25 | + |
| 26 | +/// Extract partition name from layer annotations |
| 27 | +pub fn extract_partition_name( |
| 28 | + layer_annotations: &std::collections::HashMap<String, String>, |
| 29 | +) -> Option<String> { |
| 30 | + layer_annotations |
| 31 | + .get(annotations::PARTITION_ANNOTATION) |
| 32 | + .cloned() |
| 33 | +} |
| 34 | + |
| 35 | +/// Extract decompressed size from layer annotations |
| 36 | +pub fn extract_decompressed_size( |
| 37 | + layer_annotations: &std::collections::HashMap<String, String>, |
| 38 | +) -> Option<u64> { |
| 39 | + layer_annotations |
| 40 | + .get(annotations::DECOMPRESSED_SIZE) |
| 41 | + .and_then(|s| s.parse().ok()) |
| 42 | +} |
| 43 | + |
| 44 | +/// Extract target platform from OCI annotations |
| 45 | +pub fn extract_target_from_annotations( |
| 46 | + annotations: &std::collections::HashMap<String, String>, |
| 47 | +) -> Option<String> { |
| 48 | + annotations.get(annotations::TARGET).cloned() |
| 49 | +} |
0 commit comments