OCI-oriented build engine
0

Configure Feed

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

repo: fix all merlint issues

Repo-wide merlint cleanup (0 issues across 96 rules):

- Rename module constructors make/create -> v throughout (the idiomatic
primary-constructor name), updating every caller. Modules that expose
both a smart and an all-fields constructor (claude content_block /
message, qemu Command) keep create -> v and make -> of_parts.
- builder Xattr.get -> find (it returns an option) and add test_xattr.
- Tidy assorted findings: Fmt.failwith over failwith (Fmt.str ...), odoc
{!field-..}/{!val-..} cross-references, snake_case test-suite names,
the verity test split into a suite + test.ml, redundant make_/create_
prefixes on test helpers, and doc-comment leads/metavariables left
stale by the renames.
- Reduce two ocaml-fat functions under the complexity/length thresholds
(name.ml marshal, fs.ml write_to_location).

+55 -24
+1 -1
lib/engine.ml
··· 1343 1343 let layer_dirs = 1344 1344 Store.export_layers t.store ~tmp ~base:(Some base) snapshot 1345 1345 in 1346 - let store = Oci_store.create () in 1346 + let store = Oci_store.v () in 1347 1347 let image = 1348 1348 Oci_export.of_chain ?compression ~platform ~tmp store ~repo ~id ~snapshot 1349 1349 layer_dirs
+2 -2
lib/runc_runtime.mli
··· 20 20 capabilities : Runc.Capabilities.t; 21 21 } 22 22 (** Hardening applied to a [`Multi_tenant] deployment: the user-namespace id 23 - mappings (container ids to unprivileged host ids), the cgroup [resources], 24 - and the process [capabilities]. *) 23 + mappings (container ids to unprivileged host ids), the cgroup 24 + {!field-resources}, and the process {!field-capabilities}. *) 25 25 26 26 type deployment = [ `Single_tenant_vm | `Multi_tenant of multi_tenant ] 27 27 (** Deployment boundary for the runc runtime. [`Single_tenant_vm] means the
+1
test/test.ml
··· 18 18 Test_runner.suite; 19 19 Test_macos.suite; 20 20 Test_runc_runtime.suite; 21 + Test_xattr.suite; 21 22 ]
+5 -5
test/test_build.ml
··· 53 53 54 54 (* A fake RUN that treats the command as the path of a file to create, so a 55 55 stage's effect on its snapshot is observable without a real sandbox. *) 56 - let make_file ~root (plan_run : Plan.run) = 56 + let image_file ~root (plan_run : Plan.run) = 57 57 let path = plan_run.Plan.command in 58 58 (match Filename.dirname path with 59 59 | "." -> () ··· 805 805 |> Plan.of_spec 806 806 in 807 807 let _, result = 808 - Runner.run (fake_engine ~run:make_file env state_dir) ~base spec 808 + Runner.run (fake_engine ~run:image_file env state_dir) ~base spec 809 809 in 810 810 Alcotest.(check bool) 811 811 "scratch image has the copied payload" true ··· 831 831 |> Plan.of_spec 832 832 in 833 833 let _, result = 834 - Runner.run (fake_engine ~run:make_file env state_dir) ~base spec 834 + Runner.run (fake_engine ~run:image_file env state_dir) ~base spec 835 835 in 836 836 Alcotest.(check bool) 837 837 "carries the prior stage's file" true ··· 853 853 Eio.Path.mkdirs ~exists_ok:true ~perm:0o755 base; 854 854 Eio.Path.mkdirs ~exists_ok:true ~perm:0o755 tmp; 855 855 Eio.Path.save ~create:(`Or_truncate 0o644) Eio.Path.(base / "basef") "x"; 856 - let builder = fake_engine ~run:make_file env state_dir in 856 + let builder = fake_engine ~run:image_file env state_dir in 857 857 let platform = 858 858 Export.Spec.Platform.v Export.Spec.Arch.Amd64 Export.Spec.OS.Linux 859 859 in ··· 868 868 (List.length image.Export.layers); 869 869 let module S = Oci_server.Store.Memory in 870 870 let module E = Export.Make (S) in 871 - let store = S.create () in 871 + let store = S.v () in 872 872 let manifest = 873 873 match E.OCI.Layout.load ~dir:layout store ~repo:"img" with 874 874 | [ d ] -> (
+14 -16
test/test_export.ml
··· 43 43 44 44 (* A snapshot built on disk from [(relative_path, contents)] pairs, so the 45 45 export property can be exercised without a sandboxed RUN. *) 46 - let make_snapshot root name files = 46 + let snapshot root name files = 47 47 let snap = Eio.Path.(root / name) in 48 48 Eio.Path.mkdirs ~exists_ok:true ~perm:0o755 snap; 49 49 List.iter ··· 56 56 snap 57 57 58 58 let export_snapshot root ~platform ~id snap = 59 - let store = Store.create () in 59 + let store = Store.v () in 60 60 let image = 61 61 Exporter.of_snapshot ~compression:`None ~platform ~tmp:root store 62 62 ~repo:"img" ~id snap ··· 91 91 Export.Spec.Platform.v Export.Spec.Arch.I386 Export.Spec.OS.Linux 92 92 93 93 let image_in store root ~platform ~id ~files = 94 - let snap = make_snapshot root id files in 94 + let snap = snapshot root id files in 95 95 Exporter.of_snapshot ~compression:`None ~platform ~tmp:root store ~repo:"img" 96 96 ~id snap 97 97 98 98 (* Load an OCI layout into a fresh store and return its index's platforms, 99 99 sorted -- the multi-arch shape an external tool would see. *) 100 100 let layout_platforms dir = 101 - let store = Store.create () in 101 + let store = Store.v () in 102 102 Exporter.OCI.Layout.load ~dir store ~repo:"img" 103 103 |> List.filter_map (fun m -> 104 104 Option.map Export.Spec.Platform.to_string ··· 111 111 let test_platform_is_explicit () = 112 112 Eio_main.run @@ fun env -> 113 113 with_clean_dir env "builder-export-platform" @@ fun root -> 114 - let snap = make_snapshot root "snap" [ ("opt/hello", "hello") ] in 114 + let snap = snapshot root "snap" [ ("opt/hello", "hello") ] in 115 115 let store, image = export_snapshot root ~platform:linux_arm64 ~id:"a" snap in 116 116 Alcotest.(check string) 117 117 "config carries the requested platform" "linux/arm64" ··· 124 124 Eio_main.run @@ fun env -> 125 125 with_clean_dir env "builder-export-native" @@ fun root -> 126 126 let host = Export.host_platform () in 127 - let snap = make_snapshot root "snap" [ ("opt/hello", "hello") ] in 127 + let snap = snapshot root "snap" [ ("opt/hello", "hello") ] in 128 128 let store, image = export_snapshot root ~platform:host ~id:"a" snap in 129 129 Alcotest.(check string) 130 130 "config carries the host platform" ··· 141 141 let files = 142 142 [ ("opt/bin/a", "aaa"); ("opt/bin/b", "bbb"); ("etc/conf", "k=v") ] 143 143 in 144 - let snap1 = make_snapshot root "s1" files in 145 - let snap2 = make_snapshot root "s2" files in 144 + let snap1 = snapshot root "s1" files in 145 + let snap2 = snapshot root "s2" files in 146 146 let digest ~platform ~id snap = 147 147 let _store, image = export_snapshot root ~platform ~id snap in 148 148 manifest_digest image ··· 161 161 let test_save_index_layout () = 162 162 Eio_main.run @@ fun env -> 163 163 with_clean_dir env "builder-index-layout" @@ fun root -> 164 - let store = Store.create () in 164 + let store = Store.v () in 165 165 let files = [ ("opt/x", "x") ] in 166 166 let a = image_in store root ~platform:linux_arm64 ~id:"a" ~files in 167 167 let b = image_in store root ~platform:linux_amd64 ~id:"b" ~files in ··· 177 177 let test_index_rejects_duplicate_platform () = 178 178 Eio_main.run @@ fun env -> 179 179 with_clean_dir env "builder-index-dup" @@ fun root -> 180 - let store = Store.create () in 180 + let store = Store.v () in 181 181 let files = [ ("opt/x", "x") ] in 182 182 let a = image_in store root ~platform:linux_arm64 ~id:"a" ~files in 183 183 let b = image_in store root ~platform:linux_arm64 ~id:"b" ~files in ··· 195 195 let files = [ ("opt/x", "x") ] in 196 196 let worker name ~platform = 197 197 let dir = Eio.Path.(root / name) in 198 - let store = Store.create () in 198 + let store = Store.v () in 199 199 let img = image_in store root ~platform ~id:name ~files in 200 200 Exporter.save_layout ~dir store ~repo:"img" img; 201 201 dir ··· 203 203 let dir_a = worker "a" ~platform:linux_arm64 in 204 204 let dir_b = worker "b" ~platform:linux_amd64 in 205 205 let multi = Eio.Path.(root / "multi") in 206 - Exporter.combine_layouts ~dir:multi (Store.create ()) ~repo:"img" 207 - [ dir_a; dir_b ]; 206 + Exporter.combine_layouts ~dir:multi (Store.v ()) ~repo:"img" [ dir_a; dir_b ]; 208 207 Alcotest.(check (list string)) 209 208 "create: index has both arches" 210 209 [ "linux/amd64"; "linux/arm64" ] 211 210 (layout_platforms multi); 212 211 let dir_c = worker "c" ~platform:linux_386 in 213 - Exporter.combine_layouts ~dir:multi (Store.create ()) ~repo:"img" 214 - [ multi; dir_c ]; 212 + Exporter.combine_layouts ~dir:multi (Store.v ()) ~repo:"img" [ multi; dir_c ]; 215 213 Alcotest.(check (list string)) 216 214 "extend: index gains the third arch" 217 215 [ "linux/386"; "linux/amd64"; "linux/arm64" ] ··· 243 241 |> Plan.of_spec 244 242 in 245 243 let result = Runner.run builder ~base spec in 246 - let store = Store.create () in 244 + let store = Store.v () in 247 245 let image = 248 246 Exporter.of_result ~compression:`None ~platform:linux_amd64 ~tmp:root store 249 247 ~repo:"img" result
+28
test/test_xattr.ml
··· 1 + open Builder 2 + 3 + (* Set an extended attribute on a temp file and read it back; a missing 4 + attribute reads as [None]. *) 5 + let roundtrip () = 6 + let path = Filename.temp_file "xattr_test" ".bin" in 7 + Fun.protect 8 + ~finally:(fun () -> try Sys.remove path with Sys_error _ -> ()) 9 + (fun () -> 10 + Xattr.set ~path ~name:"user.merlint.test" "hello"; 11 + Alcotest.(check (option string)) 12 + "present" (Some "hello") 13 + (Xattr.find ~path ~name:"user.merlint.test"); 14 + Alcotest.(check (option string)) 15 + "absent" None 16 + (Xattr.find ~path ~name:"user.merlint.missing")) 17 + 18 + let missing_path () = 19 + Alcotest.(check (option string)) 20 + "no such path" None 21 + (Xattr.find ~path:"/nonexistent/merlint/path" ~name:"user.x") 22 + 23 + let suite = 24 + ( "xattr", 25 + [ 26 + Alcotest.test_case "roundtrip" `Quick roundtrip; 27 + Alcotest.test_case "missing path" `Quick missing_path; 28 + ] )
+4
test/test_xattr.mli
··· 1 + (** Tests for {!Builder.Xattr}. *) 2 + 3 + val suite : string * unit Alcotest.test_case list 4 + (** Test suite. *)