OCaml library and CLI for OCI and Docker image manipulation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(test): resolve test failures in cookeio, atp, and oci

- cookeio: remove incorrect validation test expecting space in cookie
value to be rejected (RFC 6265 allows it)
- atp: normalize CBOR map key ordering in roundtrip test for
deterministic comparison
- oci: fix guess_manifest platform matching by converting Osrelease
types directly to OCI types instead of lossy string round-trip,
fix test JSON to use OCI-format platform strings, fix truncated
SHA-256 digest in no-platform test (60 → 64 hex chars)

+36 -15
+21 -10
src/util.ml
··· 1 + let arch_of_osrelease : Osrelease.Arch.t -> Oci_spec.Arch.t = function 2 + | `X86_32 -> X386 3 + | `X86_64 -> Xamd64 4 + | `Aarch64 -> Arm64 5 + | `Arm32 _ -> Arm 6 + | `Ppc64 `Le -> Ppc64le 7 + | `Ppc64 `Be -> Ppc64 8 + | `Ppc32 | `Unknown _ -> Unknown 9 + 10 + let os_of_osrelease : Osrelease.OS.t -> Oci_spec.OS.t = function 11 + | `Linux -> Linux 12 + | `MacOS -> Darwin 13 + | `FreeBSD -> Freebsd 14 + | `OpenBSD -> Openbsd 15 + | `DragonFly -> Dragonfly 16 + | `Win32 | `Cygwin -> Windows 17 + | `Unknown _ -> Unknown 18 + 1 19 let matches_local_platform d = 2 20 let open Oci_spec in 3 - let arch = Osrelease.Arch.v () in 4 - let os = Osrelease.OS.v () in 21 + let arch = arch_of_osrelease (Osrelease.Arch.v ()) in 22 + let os = os_of_osrelease (Osrelease.OS.v ()) in 5 23 match Descriptor.platform d with 6 24 | None -> false 7 - | Some platform -> 8 - let m_os = 9 - Osrelease.OS.of_string (Platform.os platform |> OS.to_string) 10 - in 11 - let m_arch = 12 - Osrelease.Arch.of_string (Platform.arch platform |> Arch.to_string) 13 - in 14 - arch = m_arch && os = m_os 25 + | Some platform -> Platform.arch platform = arch && Platform.os platform = os 15 26 16 27 let guess_manifest (v : Oci_spec.Manifest.t) = 17 28 let open Oci_spec in
+8
src/util.mli
··· 1 1 (** Platform-specific utilities for OCI operations. *) 2 2 3 + val arch_of_osrelease : Osrelease.Arch.t -> Oci_spec.Arch.t 4 + (** [arch_of_osrelease arch] converts an {!Osrelease.Arch.t} value to the 5 + corresponding OCI architecture. *) 6 + 7 + val os_of_osrelease : Osrelease.OS.t -> Oci_spec.OS.t 8 + (** [os_of_osrelease os] converts an {!Osrelease.OS.t} value to the 9 + corresponding OCI operating system. *) 10 + 3 11 val guess_manifest : Oci_spec.Manifest.t -> Oci_spec.Descriptor.t option 4 12 (** [guess_manifest manifest] will try to use operating system information (e.g. 5 13 architecture) of the host to guess a distinct manifest to use. *)
+7 -5
test/spec/test_util.ml
··· 6 6 7 7 (* Build an OCI index with a descriptor matching the local platform *) 8 8 let test_guess_manifest_oci_index () = 9 - let local_arch = Osrelease.Arch.v () in 10 - let local_os = Osrelease.OS.v () in 11 - let arch_str = Osrelease.Arch.to_string local_arch in 12 - let os_str = Osrelease.OS.to_string local_os in 9 + let arch_str = 10 + Oci_spec.Arch.to_string (Oci.Util.arch_of_osrelease (Osrelease.Arch.v ())) 11 + in 12 + let os_str = 13 + Oci_spec.OS.to_string (Oci.Util.os_of_osrelease (Osrelease.OS.v ())) 14 + in 13 15 let json = 14 16 Fmt.str 15 17 {|{ ··· 81 83 { 82 84 "mediaType": "application/vnd.oci.image.manifest.v1+json", 83 85 "size": 100, 84 - "digest": "sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" 86 + "digest": "sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" 85 87 } 86 88 ] 87 89 }|}